Skip to content

Commit

Permalink
Replace the old with function with rebind_operators
Browse files Browse the repository at this point in the history
  • Loading branch information
PointKernel committed Sep 1, 2024
1 parent 75e1ac3 commit 55c593d
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 71 deletions.
4 changes: 2 additions & 2 deletions include/cuco/detail/static_map/kernels.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ CUCO_KERNEL __launch_bounds__(BlockSize) void insert_or_apply_shmem(
ref.probing_scheme(),
{},
storage};
auto shared_map_ref = std::move(shared_map).with(cuco::op::insert_or_apply);
auto shared_map_ref = shared_map.rebind_operators(cuco::op::insert_or_apply);
shared_map_ref.initialize(block);
block.sync();

Expand Down Expand Up @@ -262,4 +262,4 @@ CUCO_KERNEL __launch_bounds__(BlockSize) void insert_or_apply_shmem(
}
}
}
} // namespace cuco::static_map_ns::detail
} // namespace cuco::static_map_ns::detail
14 changes: 10 additions & 4 deletions include/cuco/detail/static_map/static_map_ref.inl
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,17 @@ template <typename Key,
typename StorageRef,
typename... Operators>
template <typename... NewOperators>
auto static_map_ref<Key, T, Scope, KeyEqual, ProbingScheme, StorageRef, Operators...>::with(
NewOperators...) && 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...>{
std::move(*this)};
cuco::empty_key<Key>{this->empty_key_sentinel()},
cuco::empty_value<T>{this->empty_value_sentinel()},
this->key_eq(),
this->probing_scheme(),
{},
this->storage_ref()};
}

template <typename Key,
Expand All @@ -312,7 +318,7 @@ template <typename Key,
typename... Operators>
template <typename... NewOperators>
__host__ __device__ constexpr auto
static_map_ref<Key, T, Scope, KeyEqual, ProbingScheme, StorageRef, Operators...>::with_operators(
static_map_ref<Key, T, Scope, KeyEqual, ProbingScheme, StorageRef, Operators...>::rebind_operators(
NewOperators...) const noexcept
{
return static_map_ref<Key, T, Scope, KeyEqual, ProbingScheme, StorageRef, NewOperators...>{
Expand Down
19 changes: 15 additions & 4 deletions include/cuco/detail/static_multimap/static_multimap_ref.inl
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,22 @@ template <typename Key,
typename StorageRef,
typename... Operators>
template <typename... NewOperators>
auto static_multimap_ref<Key, T, Scope, KeyEqual, ProbingScheme, StorageRef, Operators...>::with(
NewOperators...) && noexcept
__host__ __device__ auto constexpr static_multimap_ref<
Key,
T,
Scope,
KeyEqual,
ProbingScheme,
StorageRef,
Operators...>::with_operators(NewOperators...) const noexcept
{
return static_multimap_ref<Key, T, Scope, KeyEqual, ProbingScheme, StorageRef, NewOperators...>{
std::move(*this)};
cuco::empty_key<Key>{this->empty_key_sentinel()},
cuco::empty_value<T>{this->empty_value_sentinel()},
this->key_eq(),
impl_.probing_scheme(),
{},
impl_.storage_ref()};
}

template <typename Key,
Expand All @@ -316,7 +327,7 @@ __host__ __device__ auto constexpr static_multimap_ref<
KeyEqual,
ProbingScheme,
StorageRef,
Operators...>::with_operators(NewOperators...) const noexcept
Operators...>::rebind_operators(NewOperators...) const noexcept
{
return static_multimap_ref<Key, T, Scope, KeyEqual, ProbingScheme, StorageRef, NewOperators...>{
cuco::empty_key<Key>{this->empty_key_sentinel()},
Expand Down
15 changes: 10 additions & 5 deletions include/cuco/detail/static_multiset/static_multiset_ref.inl
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,16 @@ template <typename Key,
typename StorageRef,
typename... Operators>
template <typename... NewOperators>
auto static_multiset_ref<Key, Scope, KeyEqual, ProbingScheme, StorageRef, Operators...>::with(
NewOperators...) && noexcept
__host__ __device__ constexpr auto
static_multiset_ref<Key, Scope, KeyEqual, ProbingScheme, StorageRef, Operators...>::with_operators(
NewOperators...) const noexcept
{
return static_multiset_ref<Key, Scope, KeyEqual, ProbingScheme, StorageRef, NewOperators...>{
std::move(*this)};
cuco::empty_key<Key>{this->empty_key_sentinel()},
this->key_eq(),
this->probing_scheme(),
{},
this->storage_ref()};
}

template <typename Key,
Expand All @@ -266,8 +271,8 @@ template <typename Key,
typename... Operators>
template <typename... NewOperators>
__host__ __device__ constexpr auto
static_multiset_ref<Key, Scope, KeyEqual, ProbingScheme, StorageRef, Operators...>::with_operators(
NewOperators...) const noexcept
static_multiset_ref<Key, Scope, KeyEqual, ProbingScheme, StorageRef, Operators...>::
rebind_operators(NewOperators...) const noexcept
{
return static_multiset_ref<Key, Scope, KeyEqual, ProbingScheme, StorageRef, NewOperators...>{
cuco::empty_key<Key>{this->empty_key_sentinel()},
Expand Down
13 changes: 9 additions & 4 deletions include/cuco/detail/static_set/static_set_ref.inl
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,16 @@ template <typename Key,
typename StorageRef,
typename... Operators>
template <typename... NewOperators>
auto static_set_ref<Key, Scope, KeyEqual, ProbingScheme, StorageRef, Operators...>::with(
NewOperators...) && noexcept
__host__ __device__ constexpr auto
static_set_ref<Key, Scope, KeyEqual, ProbingScheme, StorageRef, Operators...>::with_operators(
NewOperators...) const noexcept
{
return static_set_ref<Key, Scope, KeyEqual, ProbingScheme, StorageRef, NewOperators...>{
std::move(*this)};
cuco::empty_key<Key>{this->empty_key_sentinel()},
this->key_eq(),
this->probing_scheme(),
{},
this->storage_ref()};
}

template <typename Key,
Expand All @@ -263,7 +268,7 @@ template <typename Key,
typename... Operators>
template <typename... NewOperators>
__host__ __device__ constexpr auto
static_set_ref<Key, Scope, KeyEqual, ProbingScheme, StorageRef, Operators...>::with_operators(
static_set_ref<Key, Scope, KeyEqual, ProbingScheme, StorageRef, Operators...>::rebind_operators(
NewOperators...) const noexcept
{
return static_set_ref<Key, Scope, KeyEqual, ProbingScheme, StorageRef, NewOperators...>{
Expand Down
20 changes: 7 additions & 13 deletions include/cuco/static_map_ref.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,7 @@ class static_map_ref
[[nodiscard]] __host__ __device__ constexpr auto probing_scheme() const noexcept;

/**
* @brief Creates a reference with new operators from the current object.
*
* @deprecated This function is deprecated. Use the new `with_operators` instead.
*
* Note that this function uses move semantics and thus invalidates the current object.
* @brief Creates a reference with new operators from the current object
*
* @warning Using two or more reference objects to the same container but with
* a different operator set at the same time results in undefined behavior.
Expand All @@ -243,22 +239,20 @@ class static_map_ref
* @return `*this` with `NewOperators...`
*/
template <typename... NewOperators>
[[nodiscard]] __host__ __device__ auto with(NewOperators... ops) && noexcept;
[[nodiscard]] __host__ __device__ constexpr auto with_operators(
NewOperators... ops) const noexcept;

/**
* @brief Creates a reference with new operators from the current object
*
* @warning Using two or more reference objects to the same container but with
* a different operator set at the same time results in undefined behavior.
* @brief Creates a copy of the current non-owning reference using the given operators
*
* @tparam NewOperators List of `cuco::op::*_tag` types
*
* @param ops List of operators, e.g., `cuco::insert`
* @param ops List of operators, e.g., `cuco::op::insert`
*
* @return `*this` with `NewOperators...`
* @return Copy of the current device ref
*/
template <typename... NewOperators>
[[nodiscard]] __host__ __device__ constexpr auto with_operators(
[[nodiscard]] __host__ __device__ constexpr auto rebind_operators(
NewOperators... ops) const noexcept;

/**
Expand Down
20 changes: 7 additions & 13 deletions include/cuco/static_multimap_ref.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,7 @@ class static_multimap_ref
[[nodiscard]] __host__ __device__ constexpr auto probing_scheme() const noexcept;

/**
* @brief Creates a reference with new operators from the current object.
*
* @deprecated This function is deprecated. Use the new `with_operators` instead.
*
* Note that this function uses move semantics and thus invalidates the current object.
* @brief Creates a reference with new operators from the current object
*
* @warning Using two or more reference objects to the same container but with
* a different operator set at the same time results in undefined behavior.
Expand All @@ -242,22 +238,20 @@ class static_multimap_ref
* @return `*this` with `NewOperators...`
*/
template <typename... NewOperators>
[[nodiscard]] __host__ __device__ auto with(NewOperators... ops) && noexcept;
[[nodiscard]] __host__ __device__ constexpr auto with_operators(
NewOperators... ops) const noexcept;

/**
* @brief Creates a reference with new operators from the current object
*
* @warning Using two or more reference objects to the same container but with
* a different operator set at the same time results in undefined behavior.
* @brief Creates a copy of the current non-owning reference using the given operators
*
* @tparam NewOperators List of `cuco::op::*_tag` types
*
* @param ops List of operators, e.g., `cuco::insert`
* @param ops List of operators, e.g., `cuco::op::insert`
*
* @return `*this` with `NewOperators...`
* @return Copy of the current device ref
*/
template <typename... NewOperators>
[[nodiscard]] __host__ __device__ constexpr auto with_operators(
[[nodiscard]] __host__ __device__ constexpr auto rebind_operators(
NewOperators... ops) const noexcept;

/**
Expand Down
20 changes: 7 additions & 13 deletions include/cuco/static_multiset_ref.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,7 @@ class static_multiset_ref
[[nodiscard]] __host__ __device__ constexpr auto probing_scheme() const noexcept;

/**
* @brief Creates a reference with new operators from the current object.
*
* @deprecated This function is deprecated. Use the new `with_operators` instead.
*
* Note that this function uses move semantics and thus invalidates the current object.
* @brief Creates a reference with new operators from the current object
*
* @warning Using two or more reference objects to the same container but with
* a different operator set at the same time results in undefined behavior.
Expand All @@ -222,22 +218,20 @@ class static_multiset_ref
* @return `*this` with `NewOperators...`
*/
template <typename... NewOperators>
[[nodiscard]] __host__ __device__ auto with(NewOperators... ops) && noexcept;
[[nodiscard]] __host__ __device__ constexpr auto with_operators(
NewOperators... ops) const noexcept;

/**
* @brief Creates a reference with new operators from the current object
*
* @warning Using two or more reference objects to the same container but with
* a different operator set at the same time results in undefined behavior.
* @brief Creates a copy of the current non-owning reference using the given operators
*
* @tparam NewOperators List of `cuco::op::*_tag` types
*
* @param ops List of operators, e.g., `cuco::insert`
* @param ops List of operators, e.g., `cuco::op::insert`
*
* @return `*this` with `NewOperators...`
* @return Copy of the current device ref
*/
template <typename... NewOperators>
[[nodiscard]] __host__ __device__ constexpr auto with_operators(
[[nodiscard]] __host__ __device__ constexpr auto rebind_operators(
NewOperators... ops) const noexcept;

/**
Expand Down
20 changes: 7 additions & 13 deletions include/cuco/static_set_ref.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,7 @@ class static_set_ref
[[nodiscard]] __host__ __device__ constexpr auto probing_scheme() const noexcept;

/**
* @brief Creates a reference with new operators from the current object.
*
* @deprecated This function is deprecated. Use the new `with_operators` instead.
*
* Note that this function uses move semantics and thus invalidates the current object.
* @brief Creates a reference with new operators from the current object
*
* @warning Using two or more reference objects to the same container but with
* a different operator set at the same time results in undefined behavior.
Expand All @@ -220,22 +216,20 @@ class static_set_ref
* @return `*this` with `NewOperators...`
*/
template <typename... NewOperators>
[[nodiscard]] __host__ __device__ auto with(NewOperators... ops) && noexcept;
[[nodiscard]] __host__ __device__ constexpr auto with_operators(
NewOperators... ops) const noexcept;

/**
* @brief Creates a reference with new operators from the current object
*
* @warning Using two or more reference objects to the same container but with
* a different operator set at the same time results in undefined behavior.
* @brief Creates a copy of the current non-owning reference using the given operators
*
* @tparam NewOperators List of `cuco::op::*_tag` types
*
* @param ops List of operators, e.g., `cuco::insert`
* @param ops List of operators, e.g., `cuco::op::insert`
*
* @return `*this` with `NewOperators...`
* @return Copy of the current device ref
*/
template <typename... NewOperators>
[[nodiscard]] __host__ __device__ constexpr auto with_operators(
[[nodiscard]] __host__ __device__ constexpr auto rebind_operators(
NewOperators... ops) const noexcept;

/**
Expand Down

0 comments on commit 55c593d

Please sign in to comment.