From 65edea2758a0cf314f8349da59756a31f9957979 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Mon, 7 Mar 2022 11:51:49 -0800 Subject: [PATCH] Apply some reverted changed related to code organization. --- .../cudf/detail/utilities/hash_functions.cuh | 68 +++++++++---------- 1 file changed, 31 insertions(+), 37 deletions(-) diff --git a/cpp/include/cudf/detail/utilities/hash_functions.cuh b/cpp/include/cudf/detail/utilities/hash_functions.cuh index 1a56410e846..7eefdc90f4b 100644 --- a/cpp/include/cudf/detail/utilities/hash_functions.cuh +++ b/cpp/include/cudf/detail/utilities/hash_functions.cuh @@ -192,28 +192,25 @@ hash_value_type __device__ inline MurmurHash3_32::operator()(bool const& k return this->compute(static_cast(key)); } -/** - * @brief Specialization of MurmurHash3_32 operator for strings. - */ template <> -hash_value_type __device__ inline MurmurHash3_32::operator()( - cudf::string_view const& key) const +hash_value_type __device__ inline MurmurHash3_32::operator()(float const& key) const { - auto const data = reinterpret_cast(key.data()); - auto const len = key.size_bytes(); - return this->compute_bytes(data, len); + return this->compute_floating_point(key); } template <> -hash_value_type __device__ inline MurmurHash3_32::operator()(float const& key) const +hash_value_type __device__ inline MurmurHash3_32::operator()(double const& key) const { return this->compute_floating_point(key); } template <> -hash_value_type __device__ inline MurmurHash3_32::operator()(double const& key) const +hash_value_type __device__ inline MurmurHash3_32::operator()( + cudf::string_view const& key) const { - return this->compute_floating_point(key); + auto const data = reinterpret_cast(key.data()); + auto const len = key.size_bytes(); + return this->compute_bytes(data, len); } template <> @@ -260,9 +257,9 @@ struct SparkMurmurHash3_32 { SparkMurmurHash3_32() = default; constexpr SparkMurmurHash3_32(uint32_t seed) : m_seed(seed) {} - __device__ inline uint32_t rotl32(uint32_t x, int8_t r) const + [[nodiscard]] __device__ inline uint32_t rotl32(uint32_t x, uint32_t r) const { - return (x << r) | (x >> (32 - r)); + return __funnelshift_l(x, x, r); // Equivalent to (x << r) | (x >> (32 - r)) } __device__ inline uint32_t fmix32(uint32_t h) const @@ -382,6 +379,27 @@ hash_value_type __device__ inline SparkMurmurHash3_32::operator()( return this->compute(key); } +template <> +hash_value_type __device__ inline SparkMurmurHash3_32::operator()(float const& key) const +{ + return this->compute_floating_point(key); +} + +template <> +hash_value_type __device__ inline SparkMurmurHash3_32::operator()(double const& key) const +{ + return this->compute_floating_point(key); +} + +template <> +hash_value_type __device__ inline SparkMurmurHash3_32::operator()( + cudf::string_view const& key) const +{ + auto const data = reinterpret_cast(key.data()); + auto const len = key.size_bytes(); + return this->compute_bytes(data, len); +} + template <> hash_value_type __device__ inline SparkMurmurHash3_32::operator()( numeric::decimal32 const& key) const @@ -454,30 +472,6 @@ hash_value_type __device__ inline SparkMurmurHash3_32::operat return 0; } -/** - * @brief Specialization of MurmurHash3_32 operator for strings. - */ -template <> -hash_value_type __device__ inline SparkMurmurHash3_32::operator()( - cudf::string_view const& key) const -{ - auto const data = reinterpret_cast(key.data()); - auto const len = key.size_bytes(); - return this->compute_bytes(data, len); -} - -template <> -hash_value_type __device__ inline SparkMurmurHash3_32::operator()(float const& key) const -{ - return this->compute_floating_point(key); -} - -template <> -hash_value_type __device__ inline SparkMurmurHash3_32::operator()(double const& key) const -{ - return this->compute_floating_point(key); -} - /** * @brief This hash function simply returns the value that is asked to be hash * reinterpreted as the result_type of the functor.