|
| 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) |
| | Computes fingerprint and candidate buckets using ADD/SUB operations.
|
| |
| static __host__ __device__ size_t | getAlternateBucket (size_t bucket, TagType fp, size_t numBuckets) |
| | Computes alternate bucket using ADD/SUB operations.
|
| |
| static size_t | calculateNumBuckets (size_t capacity) |
| | Calculates number of buckets without requiring power of two.
|
| |
template<typename KeyType, typename TagType, size_t bitsPerTag, size_t bucketSize>
struct cuckoogpu::AddSubAltBucketPolicy< KeyType, TagType, bitsPerTag, bucketSize >
Addition/Subtraction-based hashing strategy for cuckoo filters (ASCF).
This implements the scheme from "Additive and Subtractive Cuckoo Filters" paper which uses ADD/SUB operations instead of XOR, allowing for non-power-of-two bucket counts and better space efficiency.
The filter is conceptually divided into two blocks of equal size.
- Block 0: buckets [0, numBuckets/2)
- Block 1: buckets [numBuckets/2, numBuckets)
Definition at line 99 of file bucket_policies.cuh.
template<typename KeyType , typename TagType , size_t bitsPerTag, size_t bucketSize>
Calculates number of buckets without requiring power of two.
The total number is rounded to ensure it's even (for equal block sizes).
Definition at line 174 of file bucket_policies.cuh.
174 {
175 auto requiredBuckets = std::ceil(static_cast<double>(capacity) / bucketSize);
176
177
178 if (static_cast<size_t>(requiredBuckets) % 2 != 0) {
179 requiredBuckets += 1;
180 }
181
182 return static_cast<size_t>(requiredBuckets);
183 }
template<typename KeyType , typename TagType , size_t bitsPerTag, size_t bucketSize>
| static __host__ __device__ size_t cuckoogpu::AddSubAltBucketPolicy< KeyType, TagType, bitsPerTag, bucketSize >::getAlternateBucket |
( |
size_t |
bucket, |
|
|
TagType |
fp, |
|
|
size_t |
numBuckets |
|
) |
| |
|
inlinestatic |
Computes alternate bucket using ADD/SUB operations.
If current bucket is in block 0, alternate is in block 1 (use ADD). If current bucket is in block 1, alternate is in block 0 (use SUB).
- Parameters
-
| bucket | Current bucket index |
| fp | Fingerprint value |
| numBuckets | Total number of buckets |
- Returns
- Alternate bucket index
Definition at line 159 of file bucket_policies.cuh.
159 {
160 const size_t bucketsPerBlock = numBuckets / 2;
161 const uint64_t fpHash =
hash64(fp) % bucketsPerBlock;
162
163 if (bucket < bucketsPerBlock) {
164 return ((bucket + fpHash) % bucketsPerBlock) + bucketsPerBlock;
165 } else {
166 return (bucket - fpHash) % bucketsPerBlock;
167 }
168 }
static __host__ __device__ uint64_t hash64(const H &key)
Computes a 64-bit hash of the key.
template<typename KeyType , typename TagType , size_t bitsPerTag, size_t bucketSize>
| static __host__ __device__ cuda::std::tuple< size_t, size_t, TagType, TagType > cuckoogpu::AddSubAltBucketPolicy< KeyType, TagType, bitsPerTag, bucketSize >::getCandidateBucketsAndFPs |
( |
const KeyType & |
key, |
|
|
size_t |
numBuckets |
|
) |
| |
|
inlinestatic |
Computes fingerprint and candidate buckets using ADD/SUB operations.
The first bucket is in block 0, computed from the hash. The second bucket is in block 1, computed by adding the fingerprint hash to the first bucket index (with wraparound within block 1).
- Parameters
-
| key | Key to hash |
| numBuckets | Total number of buckets (should be even for proper block division) |
- Returns
- A tuple of (bucket1, bucket2, fingerprintForBucket1, fingerprintForBucket2)
Definition at line 129 of file bucket_policies.cuh.
129 {
130 const uint64_t h =
hash64(key);
131
132
133 const uint32_t h_fp = h >> 32;
134 const uint32_t masked = h_fp &
fpMask;
135 const auto fp = TagType(masked == 0 ? 1 : masked);
136
137
138 const uint32_t h_bucket = h & 0xFFFFFFFF;
139 const size_t bucketsPerBlock = numBuckets / 2;
140
141 const size_t i1 = h_bucket % bucketsPerBlock;
143
144 return {i1, i2, fp, fp};
145 }
static constexpr size_t fpMask
static __host__ __device__ size_t getAlternateBucket(size_t bucket, TagType fp, size_t numBuckets)
Computes alternate bucket using ADD/SUB operations.