From 55c593da044bd60a8fcb8e78fb3698d541c800a4 Mon Sep 17 00:00:00 2001 From: Yunsong Wang Date: Sat, 31 Aug 2024 23:31:13 -0700 Subject: [PATCH] Replace the old with function with rebind_operators --- include/cuco/detail/static_map/kernels.cuh | 4 ++-- .../cuco/detail/static_map/static_map_ref.inl | 14 +++++++++---- .../static_multimap/static_multimap_ref.inl | 19 ++++++++++++++---- .../static_multiset/static_multiset_ref.inl | 15 +++++++++----- .../cuco/detail/static_set/static_set_ref.inl | 13 ++++++++---- include/cuco/static_map_ref.cuh | 20 +++++++------------ include/cuco/static_multimap_ref.cuh | 20 +++++++------------ include/cuco/static_multiset_ref.cuh | 20 +++++++------------ include/cuco/static_set_ref.cuh | 20 +++++++------------ 9 files changed, 74 insertions(+), 71 deletions(-) diff --git a/include/cuco/detail/static_map/kernels.cuh b/include/cuco/detail/static_map/kernels.cuh index bf2aced70..4e4f396db 100644 --- a/include/cuco/detail/static_map/kernels.cuh +++ b/include/cuco/detail/static_map/kernels.cuh @@ -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(); @@ -262,4 +262,4 @@ CUCO_KERNEL __launch_bounds__(BlockSize) void insert_or_apply_shmem( } } } -} // namespace cuco::static_map_ns::detail \ No newline at end of file +} // namespace cuco::static_map_ns::detail diff --git a/include/cuco/detail/static_map/static_map_ref.inl b/include/cuco/detail/static_map/static_map_ref.inl index 42658401a..989880904 100644 --- a/include/cuco/detail/static_map/static_map_ref.inl +++ b/include/cuco/detail/static_map/static_map_ref.inl @@ -296,11 +296,17 @@ template template -auto static_map_ref::with( - NewOperators...) && noexcept +__host__ __device__ constexpr auto +static_map_ref::with_operators( + NewOperators...) const noexcept { return static_map_ref{ - std::move(*this)}; + cuco::empty_key{this->empty_key_sentinel()}, + cuco::empty_value{this->empty_value_sentinel()}, + this->key_eq(), + this->probing_scheme(), + {}, + this->storage_ref()}; } template template __host__ __device__ constexpr auto -static_map_ref::with_operators( +static_map_ref::rebind_operators( NewOperators...) const noexcept { return static_map_ref{ diff --git a/include/cuco/detail/static_multimap/static_multimap_ref.inl b/include/cuco/detail/static_multimap/static_multimap_ref.inl index df2c1f686..a44f40c3a 100644 --- a/include/cuco/detail/static_multimap/static_multimap_ref.inl +++ b/include/cuco/detail/static_multimap/static_multimap_ref.inl @@ -294,11 +294,22 @@ template template -auto static_multimap_ref::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{ - std::move(*this)}; + cuco::empty_key{this->empty_key_sentinel()}, + cuco::empty_value{this->empty_value_sentinel()}, + this->key_eq(), + impl_.probing_scheme(), + {}, + impl_.storage_ref()}; } template ::with_operators(NewOperators...) const noexcept + Operators...>::rebind_operators(NewOperators...) const noexcept { return static_multimap_ref{ cuco::empty_key{this->empty_key_sentinel()}, diff --git a/include/cuco/detail/static_multiset/static_multiset_ref.inl b/include/cuco/detail/static_multiset/static_multiset_ref.inl index 3ec72aac9..1cc212f14 100644 --- a/include/cuco/detail/static_multiset/static_multiset_ref.inl +++ b/include/cuco/detail/static_multiset/static_multiset_ref.inl @@ -251,11 +251,16 @@ template template -auto static_multiset_ref::with( - NewOperators...) && noexcept +__host__ __device__ constexpr auto +static_multiset_ref::with_operators( + NewOperators...) const noexcept { return static_multiset_ref{ - std::move(*this)}; + cuco::empty_key{this->empty_key_sentinel()}, + this->key_eq(), + this->probing_scheme(), + {}, + this->storage_ref()}; } template template __host__ __device__ constexpr auto -static_multiset_ref::with_operators( - NewOperators...) const noexcept +static_multiset_ref:: + rebind_operators(NewOperators...) const noexcept { return static_multiset_ref{ cuco::empty_key{this->empty_key_sentinel()}, diff --git a/include/cuco/detail/static_set/static_set_ref.inl b/include/cuco/detail/static_set/static_set_ref.inl index 9c5119f1d..a70df3d76 100644 --- a/include/cuco/detail/static_set/static_set_ref.inl +++ b/include/cuco/detail/static_set/static_set_ref.inl @@ -248,11 +248,16 @@ template template -auto static_set_ref::with( - NewOperators...) && noexcept +__host__ __device__ constexpr auto +static_set_ref::with_operators( + NewOperators...) const noexcept { return static_set_ref{ - std::move(*this)}; + cuco::empty_key{this->empty_key_sentinel()}, + this->key_eq(), + this->probing_scheme(), + {}, + this->storage_ref()}; } template template __host__ __device__ constexpr auto -static_set_ref::with_operators( +static_set_ref::rebind_operators( NewOperators...) const noexcept { return static_set_ref{ diff --git a/include/cuco/static_map_ref.cuh b/include/cuco/static_map_ref.cuh index 9161935ac..e3399a93e 100644 --- a/include/cuco/static_map_ref.cuh +++ b/include/cuco/static_map_ref.cuh @@ -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. @@ -243,22 +239,20 @@ class static_map_ref * @return `*this` with `NewOperators...` */ template - [[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 - [[nodiscard]] __host__ __device__ constexpr auto with_operators( + [[nodiscard]] __host__ __device__ constexpr auto rebind_operators( NewOperators... ops) const noexcept; /** diff --git a/include/cuco/static_multimap_ref.cuh b/include/cuco/static_multimap_ref.cuh index 802262a01..ddcf77dba 100644 --- a/include/cuco/static_multimap_ref.cuh +++ b/include/cuco/static_multimap_ref.cuh @@ -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. @@ -242,22 +238,20 @@ class static_multimap_ref * @return `*this` with `NewOperators...` */ template - [[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 - [[nodiscard]] __host__ __device__ constexpr auto with_operators( + [[nodiscard]] __host__ __device__ constexpr auto rebind_operators( NewOperators... ops) const noexcept; /** diff --git a/include/cuco/static_multiset_ref.cuh b/include/cuco/static_multiset_ref.cuh index b4de24f3c..25c98b874 100644 --- a/include/cuco/static_multiset_ref.cuh +++ b/include/cuco/static_multiset_ref.cuh @@ -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. @@ -222,22 +218,20 @@ class static_multiset_ref * @return `*this` with `NewOperators...` */ template - [[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 - [[nodiscard]] __host__ __device__ constexpr auto with_operators( + [[nodiscard]] __host__ __device__ constexpr auto rebind_operators( NewOperators... ops) const noexcept; /** diff --git a/include/cuco/static_set_ref.cuh b/include/cuco/static_set_ref.cuh index 59780d45d..fa0098ebf 100644 --- a/include/cuco/static_set_ref.cuh +++ b/include/cuco/static_set_ref.cuh @@ -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. @@ -220,22 +216,20 @@ class static_set_ref * @return `*this` with `NewOperators...` */ template - [[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 - [[nodiscard]] __host__ __device__ constexpr auto with_operators( + [[nodiscard]] __host__ __device__ constexpr auto rebind_operators( NewOperators... ops) const noexcept; /**