GPU-Accelerated Cuckoo Filter
Loading...
Searching...
No Matches
Static Public Member Functions | Static Public Attributes | List of all members
cuckoogpu::XorAltBucketPolicy< KeyType, TagType, bitsPerTag, bucketSize > Struct Template Reference

Default XOR-based hashing strategy for cuckoo filters. More...

Static Public Member Functions

template<typename H >
static __host__ __device__ uint64_t hash64 (const H &key)
 Computes a 64-bit hash of the key.
 
static __host__ __device__ cuda::std::tuple< size_t, size_t, TagType, TagType > getCandidateBucketsAndFPs (const KeyType &key, size_t numBuckets)
 Performs partial-key cuckoo hashing to find the fingerprint and both bucket indices for a given key.
 
static __host__ __device__ size_t getAlternateBucket (size_t bucket, TagType fp, size_t numBuckets)
 Computes the alternate bucket index using XOR.
 
static size_t calculateNumBuckets (size_t capacity)
 The number of buckets is enforced to be a power of two in order to allow for efficient modulo on the bucket indices with XOR-based hashing.
 

Static Public Attributes

static constexpr size_t fpMask = (1ULL << bitsPerTag) - 1
 
static constexpr bool usesChoiceBit = false
 
static constexpr char name [] = "XorAltBucketPolicy"
 

Detailed Description

template<typename KeyType, typename TagType, size_t bitsPerTag, size_t bucketSize>
struct cuckoogpu::XorAltBucketPolicy< KeyType, TagType, bitsPerTag, bucketSize >

Default XOR-based hashing strategy for cuckoo filters.

This uses the traditional partial-key cuckoo hashing with XOR operation to compute alternate bucket indices.

Definition at line 17 of file bucket_policies.cuh.

Member Function Documentation

◆ calculateNumBuckets()

template<typename KeyType , typename TagType , size_t bitsPerTag, size_t bucketSize>
static size_t cuckoogpu::XorAltBucketPolicy< KeyType, TagType, bitsPerTag, bucketSize >::calculateNumBuckets ( size_t  capacity)
inlinestatic

The number of buckets is enforced to be a power of two in order to allow for efficient modulo on the bucket indices with XOR-based hashing.

Definition at line 82 of file bucket_policies.cuh.

82 {
83 auto requiredBuckets = std::ceil(static_cast<double>(capacity) / bucketSize);
84 return detail::nextPowerOfTwo(requiredBuckets);
85 }
constexpr size_t nextPowerOfTwo(size_t n)
Calculates the next power of two greater than or equal to n.
Definition helpers.cuh:33
Here is the call graph for this function:

◆ getAlternateBucket()

template<typename KeyType , typename TagType , size_t bitsPerTag, size_t bucketSize>
static __host__ __device__ size_t cuckoogpu::XorAltBucketPolicy< KeyType, TagType, bitsPerTag, bucketSize >::getAlternateBucket ( size_t  bucket,
TagType  fp,
size_t  numBuckets 
)
inlinestatic

Computes the alternate bucket index using XOR.

Parameters
bucketCurrent bucket index.
fpFingerprint.
numBucketsTotal number of buckets (must be power of 2).
Returns
size_t Alternate bucket index.

Definition at line 74 of file bucket_policies.cuh.

74 {
75 return bucket ^ (hash64(fp) & (numBuckets - 1));
76 }
static __host__ __device__ uint64_t hash64(const H &key)
Computes a 64-bit hash of the key.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCandidateBucketsAndFPs()

template<typename KeyType , typename TagType , size_t bitsPerTag, size_t bucketSize>
static __host__ __device__ cuda::std::tuple< size_t, size_t, TagType, TagType > cuckoogpu::XorAltBucketPolicy< KeyType, TagType, bitsPerTag, bucketSize >::getCandidateBucketsAndFPs ( const KeyType &  key,
size_t  numBuckets 
)
inlinestatic

Performs partial-key cuckoo hashing to find the fingerprint and both bucket indices for a given key.

We derive the fingerprint and bucket indices from different parts of the key's hash to greatly reduce the number of collisions. The fingerprint value 0 is reserved to indicate an empty slot, so we use 1 if the computed fingerprint is 0.

Parameters
keyKey to hash
numBucketsNumber of buckets in the filter
Returns
A tuple of (bucket1, bucket2, fingerprintForBucket1, fingerprintForBucket2)

Definition at line 48 of file bucket_policies.cuh.

48 {
49 const uint64_t h = hash64(key);
50
51 // Upper 32 bits for the fingerprint
52 const uint32_t h_fp = h >> 32;
53 const uint32_t masked = h_fp & fpMask;
54
55 const auto fp = TagType(masked == 0 ? 1 : masked);
56
57 // Lower 32 bits for the bucket indices
58 const uint32_t h_bucket = h & 0xFFFFFFFF;
59 const size_t i1 = h_bucket & (numBuckets - 1);
60 const size_t i2 = getAlternateBucket(i1, fp, numBuckets);
61
62 return {i1, i2, fp, fp};
63 }
static constexpr size_t fpMask
static __host__ __device__ size_t getAlternateBucket(size_t bucket, TagType fp, size_t numBuckets)
Computes the alternate bucket index using XOR.
Here is the call graph for this function:

◆ hash64()

template<typename KeyType , typename TagType , size_t bitsPerTag, size_t bucketSize>
template<typename H >
static __host__ __device__ uint64_t cuckoogpu::XorAltBucketPolicy< KeyType, TagType, bitsPerTag, bucketSize >::hash64 ( const H &  key)
inlinestatic

Computes a 64-bit hash of the key.

Template Parameters
HType of the key.
Parameters
keyThe key to hash.
Returns
uint64_t The 64-bit hash value.

Definition at line 31 of file bucket_policies.cuh.

31 {
32 return xxhash::xxhash64(key);
33 }
__host__ __device__ uint64_t xxhash64(const T &key, uint64_t seed=0)
Definition hashutil.cuh:71
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ fpMask

template<typename KeyType , typename TagType , size_t bitsPerTag, size_t bucketSize>
constexpr size_t cuckoogpu::XorAltBucketPolicy< KeyType, TagType, bitsPerTag, bucketSize >::fpMask = (1ULL << bitsPerTag) - 1
staticconstexpr

Definition at line 18 of file bucket_policies.cuh.

◆ name

template<typename KeyType , typename TagType , size_t bitsPerTag, size_t bucketSize>
constexpr char cuckoogpu::XorAltBucketPolicy< KeyType, TagType, bitsPerTag, bucketSize >::name[] = "XorAltBucketPolicy"
staticconstexpr

Definition at line 22 of file bucket_policies.cuh.

◆ usesChoiceBit

template<typename KeyType , typename TagType , size_t bitsPerTag, size_t bucketSize>
constexpr bool cuckoogpu::XorAltBucketPolicy< KeyType, TagType, bitsPerTag, bucketSize >::usesChoiceBit = false
staticconstexpr

Definition at line 20 of file bucket_policies.cuh.


The documentation for this struct was generated from the following file: