Skip to content

Commit

Permalink
Rename with_hash_function as rebind_hash_function
Browse files Browse the repository at this point in the history
  • Loading branch information
PointKernel committed Sep 1, 2024
1 parent 4454de4 commit d49ff64
Show file tree
Hide file tree
Showing 12 changed files with 125 additions and 74 deletions.
12 changes: 2 additions & 10 deletions include/cuco/detail/probing_scheme/probing_scheme_impl.inl
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ __host__ __device__ constexpr linear_probing<CGSize, Hash>::linear_probing(Hash

template <int32_t CGSize, typename Hash>
template <typename NewHash>
__host__ __device__ constexpr auto linear_probing<CGSize, Hash>::with_hash_function(
__host__ __device__ constexpr auto linear_probing<CGSize, Hash>::rebind_hash_function(
NewHash const& hash) const noexcept
{
return linear_probing<cg_size, NewHash>{hash};
Expand Down Expand Up @@ -148,17 +148,9 @@ __host__ __device__ constexpr double_hashing<CGSize, Hash1, Hash2>::double_hashi
{
}

template <int32_t CGSize, typename Hash1, typename Hash2>
template <typename NewHash1, typename NewHash2>
__host__ __device__ constexpr auto double_hashing<CGSize, Hash1, Hash2>::with_hash_function(
NewHash1 const& hash1, NewHash2 const& hash2) const noexcept
{
return double_hashing<cg_size, NewHash1, NewHash2>{hash1, hash2};
}

template <int32_t CGSize, typename Hash1, typename Hash2>
template <typename NewHash, typename Enable>
__host__ __device__ constexpr auto double_hashing<CGSize, Hash1, Hash2>::with_hash_function(
__host__ __device__ constexpr auto double_hashing<CGSize, Hash1, Hash2>::rebind_hash_function(
NewHash const& hash) const
{
static_assert(cuco::is_tuple_like<NewHash>::value,
Expand Down
44 changes: 33 additions & 11 deletions include/cuco/detail/static_map/static_map_ref.inl
Original file line number Diff line number Diff line change
Expand Up @@ -311,22 +311,44 @@ template <typename Key,
typename StorageRef,
typename... Operators>
template <typename... NewOperators>
__host__ __device__ auto constexpr static_map_ref<Key,
T,
Scope,
KeyEqual,
ProbingScheme,
StorageRef,
Operators...>::with_operators(NewOperators...)
const noexcept
__host__ __device__ constexpr auto
static_map_ref<Key, T, Scope, KeyEqual, ProbingScheme, StorageRef, Operators...>::with_operators(
NewOperators...) const noexcept
{
return static_map_ref<Key, T, Scope, KeyEqual, ProbingScheme, StorageRef, NewOperators...>{
cuco::empty_key<Key>{this->empty_key_sentinel()},
cuco::empty_value<T>{this->empty_value_sentinel()},
this->key_eq(),
this->impl_.probing_scheme(),
this->probing_scheme(),
{},
this->impl_.storage_ref()};
this->storage_ref()};
}

template <typename Key,
typename T,
cuda::thread_scope Scope,
typename KeyEqual,
typename ProbingScheme,
typename StorageRef,
typename... Operators>
template <typename NewHash>
__host__ __device__ constexpr auto
static_map_ref<Key, T, Scope, KeyEqual, ProbingScheme, StorageRef, Operators...>::
rebind_hash_function(NewHash const& hash) const
{
auto const probing_scheme = this->probing_scheme().rebind_hash_function(hash);
return static_map_ref<Key,
T,
Scope,
KeyEqual,
cuda::std::decay_t<decltype(probing_scheme)>,
StorageRef,
Operators...>{cuco::empty_key<Key>{this->empty_key_sentinel()},
cuco::empty_value<T>{this->empty_value_sentinel()},
this->key_eq(),
probing_scheme,
{},
this->storage_ref()};
}

template <typename Key,
Expand All @@ -349,7 +371,7 @@ static_map_ref<Key, T, Scope, KeyEqual, ProbingScheme, StorageRef, Operators...>
cuco::empty_value<T>{this->empty_value_sentinel()},
cuco::erased_key<Key>{this->erased_key_sentinel()},
this->key_eq(),
this->impl_.probing_scheme(),
this->probing_scheme(),
scope,
storage_ref_type{this->window_extent(), memory_to_use}};
}
Expand Down
27 changes: 27 additions & 0 deletions include/cuco/detail/static_multimap/static_multimap_ref.inl
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,33 @@ __host__ __device__ auto constexpr static_multimap_ref<
impl_.storage_ref()};
}

template <typename Key,
typename T,
cuda::thread_scope Scope,
typename KeyEqual,
typename ProbingScheme,
typename StorageRef,
typename... Operators>
template <typename NewHash>
__host__ __device__ constexpr auto
static_multimap_ref<Key, T, Scope, KeyEqual, ProbingScheme, StorageRef, Operators...>::
rebind_hash_function(NewHash const& hash) const
{
auto const probing_scheme = this->probing_scheme().rebind_hash_function(hash);
return static_multimap_ref<Key,
T,
Scope,
KeyEqual,
cuda::std::decay_t<decltype(probing_scheme)>,
StorageRef,
Operators...>{cuco::empty_key<Key>{this->empty_key_sentinel()},
cuco::empty_value<T>{this->empty_value_sentinel()},
this->key_eq(),
probing_scheme,
{},
this->storage_ref()};
}

template <typename Key,
typename T,
cuda::thread_scope Scope,
Expand Down
4 changes: 2 additions & 2 deletions include/cuco/detail/static_multiset/static_multiset.inl
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ static_multiset<Key, Extent, Scope, KeyEqual, ProbingScheme, Allocator, Storage>
{
return impl_->count(first,
last,
ref(op::count).with_key_eq(probe_key_equal).with_hash_function(probe_hash),
ref(op::count).with_key_eq(probe_key_equal).rebind_hash_function(probe_hash),
stream);
}

Expand All @@ -333,7 +333,7 @@ static_multiset<Key, Extent, Scope, KeyEqual, ProbingScheme, Allocator, Storage>
return impl_->count_outer(
first,
last,
ref(op::count).with_key_eq(probe_key_equal).with_hash_function(probe_hash),
ref(op::count).with_key_eq(probe_key_equal).rebind_hash_function(probe_hash),
stream);
}

Expand Down
16 changes: 8 additions & 8 deletions include/cuco/detail/static_multiset/static_multiset_ref.inl
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,9 @@ static_multiset_ref<Key, Scope, KeyEqual, ProbingScheme, StorageRef, Operators..
return static_multiset_ref<Key, Scope, KeyEqual, ProbingScheme, StorageRef, NewOperators...>{
cuco::empty_key<Key>{this->empty_key_sentinel()},
this->key_eq(),
this->impl_.probing_scheme(),
this->probing_scheme(),
{},
this->impl_.storage_ref()};
this->storage_ref()};
}

template <typename Key,
Expand All @@ -291,9 +291,9 @@ static_multiset_ref<Key, Scope, KeyEqual, ProbingScheme, StorageRef, Operators..
return static_multiset_ref<Key, Scope, NewKeyEqual, ProbingScheme, StorageRef, Operators...>{
cuco::empty_key<Key>{this->empty_key_sentinel()},
key_equal,
this->impl_.probing_scheme(),
this->probing_scheme(),
{},
this->impl_.storage_ref()};
this->storage_ref()};
}

template <typename Key,
Expand All @@ -305,19 +305,19 @@ template <typename Key,
template <typename NewHash>
__host__ __device__ constexpr auto
static_multiset_ref<Key, Scope, KeyEqual, ProbingScheme, StorageRef, Operators...>::
with_hash_function(NewHash const& hash) const
rebind_hash_function(NewHash const& hash) const
{
auto const probing_scheme = this->impl_.probing_scheme().with_hash_function(hash);
auto const probing_scheme = this->probing_scheme().rebind_hash_function(hash);
return static_multiset_ref<Key,
Scope,
KeyEqual,
cuda::std::decay_t<decltype(probing_scheme)>,
StorageRef,
Operators...>{cuco::empty_key<Key>{this->empty_key_sentinel()},
this->impl_.key_eq(),
this->key_eq(),
probing_scheme,
{},
this->impl_.storage_ref()};
this->storage_ref()};
}

namespace detail {
Expand Down
18 changes: 9 additions & 9 deletions include/cuco/detail/static_set/static_set_ref.inl
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,9 @@ static_set_ref<Key, Scope, KeyEqual, ProbingScheme, StorageRef, Operators...>::w
return static_set_ref<Key, Scope, KeyEqual, ProbingScheme, StorageRef, NewOperators...>{
cuco::empty_key<Key>{this->empty_key_sentinel()},
this->key_eq(),
this->impl_.probing_scheme(),
this->probing_scheme(),
{},
this->impl_.storage_ref()};
this->storage_ref()};
}

template <typename Key,
Expand All @@ -288,9 +288,9 @@ static_set_ref<Key, Scope, KeyEqual, ProbingScheme, StorageRef, Operators...>::w
return static_set_ref<Key, Scope, NewKeyEqual, ProbingScheme, StorageRef, Operators...>{
cuco::empty_key<Key>{this->empty_key_sentinel()},
key_equal,
this->impl_.probing_scheme(),
this->probing_scheme(),
{},
this->impl_.storage_ref()};
this->storage_ref()};
}

template <typename Key,
Expand All @@ -301,20 +301,20 @@ template <typename Key,
typename... Operators>
template <typename NewHash>
__host__ __device__ constexpr auto
static_set_ref<Key, Scope, KeyEqual, ProbingScheme, StorageRef, Operators...>::with_hash_function(
static_set_ref<Key, Scope, KeyEqual, ProbingScheme, StorageRef, Operators...>::rebind_hash_function(
NewHash const& hash) const
{
auto const probing_scheme = this->impl_.probing_scheme().with_hash_function(hash);
auto const probing_scheme = this->probing_scheme().rebind_hash_function(hash);
return static_set_ref<Key,
Scope,
KeyEqual,
cuda::std::decay_t<decltype(probing_scheme)>,
StorageRef,
Operators...>{cuco::empty_key<Key>{this->empty_key_sentinel()},
this->impl_.key_eq(),
this->key_eq(),
probing_scheme,
{},
this->impl_.storage_ref()};
this->storage_ref()};
}

template <typename Key,
Expand All @@ -335,7 +335,7 @@ static_set_ref<Key, Scope, KeyEqual, ProbingScheme, StorageRef, Operators...>::m
cuco::empty_key<Key>{this->empty_key_sentinel()},
cuco::erased_key<Key>{this->erased_key_sentinel()},
this->key_eq(),
this->impl_.probing_scheme(),
this->probing_scheme(),
scope,
storage_ref_type{this->window_extent(), memory_to_use}};
}
Expand Down
20 changes: 2 additions & 18 deletions include/cuco/probing_scheme.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class linear_probing : private detail::probing_scheme_base<CGSize> {
* @return Copy of the current probing method
*/
template <typename NewHash>
[[nodiscard]] __host__ __device__ constexpr auto with_hash_function(
[[nodiscard]] __host__ __device__ constexpr auto rebind_hash_function(
NewHash const& hash) const noexcept;

/**
Expand Down Expand Up @@ -145,22 +145,6 @@ class double_hashing : private detail::probing_scheme_base<CGSize> {
*/
__host__ __device__ constexpr double_hashing(cuco::pair<Hash1, Hash2> const& hash);

/**
*@brief Makes a copy of the current probing method with the given hasher
*
* @tparam NewHash1 First new hasher type
* @tparam NewHash2 Second new hasher type
*
* @param hash1 First hasher
* @param hash2 second hasher
*
* @return Copy of the current probing method
*/
template <typename NewHash1, typename NewHash2 = NewHash1>
[[nodiscard]] __host__ __device__ constexpr auto with_hash_function(NewHash1 const& hash1,
NewHash2 const& hash2 = {
1}) const noexcept;

/**
*@brief Makes a copy of the current probing method with the given hasher
*
Expand All @@ -174,7 +158,7 @@ class double_hashing : private detail::probing_scheme_base<CGSize> {
*/
template <typename NewHash,
typename Enable = cuda::std::enable_if_t<cuco::is_tuple_like<NewHash>::value>>
[[nodiscard]] __host__ __device__ constexpr auto with_hash_function(NewHash const& hash) const;
[[nodiscard]] __host__ __device__ constexpr auto rebind_hash_function(NewHash const& hash) const;

/**
* @brief Operator to return a probing iterator
Expand Down
12 changes: 12 additions & 0 deletions include/cuco/static_map_ref.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,18 @@ class static_map_ref
[[nodiscard]] __host__ __device__ constexpr auto with_operators(
NewOperators... ops) const noexcept;

/**
* @brief Makes a copy of the current device reference with the given hasher
*
* @tparam NewHash The new hasher type
*
* @param hash New hasher
*
* @return Copy of the current device ref
*/
template <typename NewHash>
[[nodiscard]] __host__ __device__ constexpr auto rebind_hash_function(NewHash const& hash) const;

/**
* @brief Makes a copy of the current device reference using non-owned memory
*
Expand Down
12 changes: 12 additions & 0 deletions include/cuco/static_multimap_ref.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,18 @@ class static_multimap_ref
[[nodiscard]] __host__ __device__ constexpr auto with_operators(
NewOperators... ops) const noexcept;

/**
* @brief Makes a copy of the current device reference with the given hasher
*
* @tparam NewHash The new hasher type
*
* @param hash New hasher
*
* @return Copy of the current device ref
*/
template <typename NewHash>
[[nodiscard]] __host__ __device__ constexpr auto rebind_hash_function(NewHash const& hash) const;

/**
* @brief Makes a copy of the current device reference using non-owned memory
*
Expand Down
4 changes: 2 additions & 2 deletions include/cuco/static_multiset_ref.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ class static_multiset_ref
NewKeyEqual const& key_equal) const noexcept;

/**
* @brief Makes a copy of the current device reference with given hasher
* @brief Makes a copy of the current device reference with the given hasher
*
* @tparam NewHash The new hasher type
*
Expand All @@ -263,7 +263,7 @@ class static_multiset_ref
* @return Copy of the current device ref
*/
template <typename NewHash>
[[nodiscard]] __host__ __device__ constexpr auto with_hash_function(NewHash const& hash) const;
[[nodiscard]] __host__ __device__ constexpr auto rebind_hash_function(NewHash const& hash) const;

private:
impl_type impl_;
Expand Down
4 changes: 2 additions & 2 deletions include/cuco/static_set_ref.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ class static_set_ref
NewKeyEqual const& key_equal) const noexcept;

/**
* @brief Makes a copy of the current device reference with given hasher
* @brief Makes a copy of the current device reference with the given hasher
*
* @tparam NewHash The new hasher type
*
Expand All @@ -261,7 +261,7 @@ class static_set_ref
* @return Copy of the current device ref
*/
template <typename NewHash>
[[nodiscard]] __host__ __device__ constexpr auto with_hash_function(NewHash const& hash) const;
[[nodiscard]] __host__ __device__ constexpr auto rebind_hash_function(NewHash const& hash) const;

/**
* @brief Makes a copy of the current device reference using non-owned memory
Expand Down
Loading

0 comments on commit d49ff64

Please sign in to comment.