- Bloom filters are a probabilistic data-structure useful to conservatively represent membership in a set using less than 1 bit per set item.
- NVBIO provides two simple generic classes to incrementally build and work with standard and blocked Bloom filters both on the host and the device:
Example
template <typename bloom_filter_type, typename T>
__global__
void populate_kernel(
const uint32 N,
const T* vector, bloom_filter_type filter)
{
const uint32 i = threadIdx.x + blockIdx.x * blockDim.x;
if (i < N)
filter.insert( vector[i] );
}
bool bloom_test()
{
for (
uint32 i = 0; i < N; ++i)
h_vector[i] = rand();
typedef bloom_filter<2,hash_functor1,hash_functor2,uint32*> bloom_filter_type;
const uint32 filter_words = N;
bloom_filter_type d_filter(
filter_words * 32,
populate_kernel<<<util::divide_ri(N,128),128>>>( N,
plain_view( d_vector ), d_filter );
bloom_filter_type h_filter(
filter_words * 32,
return h_filter.has( 42 );
}