17 #ifndef BITFILTER_HPP__
18 #define BITFILTER_HPP__
20 #include <stm/config.h>
23 #if defined(STM_USE_SSE)
24 #include <xmmintrin.h>
25 #define FILTER_ALLOC(x) _mm_malloc((x), 16)
27 #define FILTER_ALLOC(x) malloc((x))
35 template <u
int32_t BITS>
40 static const uint32_t VEC_SIZE = 8 *
sizeof(__m128i);
41 static const uint32_t VEC_BLOCKS =
BITS / VEC_SIZE;
43 static const uint32_t
WORD_SIZE = 8 *
sizeof(uintptr_t);
51 mutable __m128i vec_filter[VEC_BLOCKS];
58 static uint32_t
hash(
const void*
const key)
60 return (((uintptr_t)key) >> 3) %
BITS;
70 void add(
const void*
const val)
volatile
72 const uint32_t index =
hash(val);
74 const uint32_t offset = index %
WORD_SIZE;
82 const uint32_t index =
hash(val);
84 const uint32_t offset = index %
WORD_SIZE;
85 #if defined(STM_CPU_X86)
96 bool lookup(
const void*
const val)
const volatile
98 const uint32_t index =
hash(val);
100 const uint32_t offset = index %
WORD_SIZE;
110 for (uint32_t i = 0; i < VEC_BLOCKS; ++i)
111 vec_filter[i] = _mm_or_si128(vec_filter[i], rhs.vec_filter[i]);
124 const __m128i zero = _mm_setzero_si128();
125 for (uint32_t i = 0; i < VEC_BLOCKS; ++i)
126 vec_filter[i] = zero;
138 for (uint32_t i = 0; i < VEC_BLOCKS; ++i)
157 tmp.v = _mm_setzero_si128();
158 for (uint32_t i = 0; i < VEC_BLOCKS; ++i) {
163 tmp.v = _mm_or_si128(tmp.v, intersect);
166 return tmp.i[0]|tmp.i[1];
178 #endif // BITFILTER_HPP__
static const uint32_t WORD_SIZE
Definition: BitFilter.hpp:43
static const uint32_t WORD_BLOCKS
Definition: BitFilter.hpp:44
Definition: stm_fraser.c:61
ALWAYS_INLINE void atomic_add(const void *const val) volatile
Definition: BitFilter.hpp:80
union stm::BitFilter::@1 TM_ALIGN(16)
TM_INLINE void add(const void *const val) volatile
Definition: BitFilter.hpp:70
NOINLINE bool intersect(const BitFilter< BITS > *rhs) const volatile
Definition: BitFilter.hpp:147
ALWAYS_INLINE bool lookup(const void *const val) const volatile
Definition: BitFilter.hpp:96
#define BITS(x, k, j)
Definition: alg_radix_smp.c:76
uintptr_t word_filter[WORD_BLOCKS]
Definition: BitFilter.hpp:53
BitFilter()
Definition: BitFilter.hpp:66
static ALWAYS_INLINE uint32_t hash(const void *const key)
Definition: BitFilter.hpp:58
Definition: BitFilter.hpp:36
TM_INLINE void fastcopy(const volatile BitFilter< BITS > *rhs) volatile
Definition: BitFilter.hpp:135
TM_INLINE void unionwith(const BitFilter< BITS > &rhs)
Definition: BitFilter.hpp:107
TM_INLINE void clear() volatile
Definition: BitFilter.hpp:120