Skip to content

Commit 0883368

Browse files
authored
Stop requiring argument_type in bloom filter policy hashers (#825)
Per [NVIDIA/cudf#23049 (comment)](NVIDIA/cudf#23049 (comment)), `parametric_filter_policy` no longer reads `typename Hash::argument_type`: `split_hash` is templated on the key type and deduces everything from the actual call, so hashers without that alias (e.g. cudf's `XXHash_64`) work directly. `hash_result_type` is fixed to `uint64_t` with the 64-bit assert moved into `split_hash`.
1 parent 5b3d0ca commit 0883368

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

include/cuco/detail/bloom_filter/parametric_filter_policy.cuh

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ namespace cuco::detail {
4949
* coalesced loads (default: fully vertical). `PatternBits` trades false-positive rate against
5050
* space.
5151
*
52-
* @tparam Hash 64-bit hash functor whose return type satisfies `is_same_v<hash_result_type,
53-
* uint64_t>`.
52+
* @tparam Hash 64-bit hash functor whose call operator returns `uint64_t`.
5453
* @tparam Word Underlying word type of a filter block. Must be an atomically updatable integral.
5554
* @tparam WordsPerBlock Words per filter block. Must be a power of two and <= 32.
5655
* @tparam PatternBits Number of fingerprint bits (k in the paper).
@@ -80,12 +79,9 @@ template <class Hash,
8079
bool EarlyExitContains>
8180
class parametric_filter_policy {
8281
public:
83-
using hasher = Hash; ///< 64-bit hash functor type
84-
using word_type = Word; ///< Underlying filter-block word type
85-
using hash_argument_type = typename hasher::argument_type; ///< Hash function input type
86-
using hash_result_type =
87-
decltype(std::declval<hasher>()(std::declval<hash_argument_type>())); ///< Hash function
88-
///< output type
82+
using hasher = Hash; ///< 64-bit hash functor type
83+
using word_type = Word; ///< Underlying filter-block word type
84+
using hash_result_type = uint64_t; ///< Hash function output type
8985

9086
private:
9187
static constexpr uint32_t max_salts = 64;
@@ -162,11 +158,6 @@ class parametric_filter_policy {
162158
static_assert(
163159
words_per_block % (contains_horizontal_layout * contains_vertical_layout) == 0,
164160
"contains_horizontal_layout * contains_vertical_layout must evenly divide words_per_block");
165-
// The split_hash() design requires a 64-bit hash split into upper 32 bits (block selection
166-
// via multiply-shift) and lower 32 bits (pattern generation via salt-based multiplicative
167-
// hashing). This is a permanent design requirement, not a temporary limitation.
168-
static_assert(cuda::std::is_same_v<hash_result_type, uint64_t>,
169-
"parametric_filter_policy requires a 64-bit hash function");
170161
}
171162

172163
/**
@@ -175,12 +166,20 @@ class parametric_filter_policy {
175166
* The upper half is used for block selection (via multiply-shift); the lower half drives the
176167
* per-word fingerprint pattern via salt-based multiplicative hashing.
177168
*
169+
* @tparam Key Key type.
170+
*
178171
* @param key Key to hash.
179172
*
180173
* @return `{upper 32 bits, lower 32 bits}` of the 64-bit hash.
181174
*/
182-
__device__ constexpr cuda::std::pair<uint32_t, uint32_t> split_hash(hash_argument_type key) const
175+
template <class Key>
176+
__device__ constexpr cuda::std::pair<uint32_t, uint32_t> split_hash(Key const& key) const
183177
{
178+
// The split_hash() design requires a 64-bit hash split into upper 32 bits (block selection
179+
// via multiply-shift) and lower 32 bits (pattern generation via salt-based multiplicative
180+
// hashing). This is a permanent design requirement, not a temporary limitation.
181+
static_assert(cuda::std::is_same_v<decltype(hash_(key)), hash_result_type>,
182+
"parametric_filter_policy requires a 64-bit hash function");
184183
auto const hash_value = hash_(key);
185184
return {static_cast<uint32_t>(hash_value >> 32), static_cast<uint32_t>(hash_value)};
186185
}

0 commit comments

Comments
 (0)