Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make murmurhash3_x64_128 compatible with existing cuco data structures #501

Merged
merged 6 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/cuco/detail/probing_scheme_impl.inl
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ __host__ __device__ constexpr auto linear_probing<CGSize, Hash>::operator()(
{
using size_type = typename Extent::value_type;
return detail::probing_iterator<Extent>{
cuco::detail::sanitize_hash<size_type>(hash_(probe_key), g.thread_rank()) % upper_bound,
cuco::detail::sanitize_hash<size_type>(hash_(probe_key), g) % upper_bound,
cg_size,
upper_bound};
}
Expand Down Expand Up @@ -164,7 +164,7 @@ __host__ __device__ constexpr auto double_hashing<CGSize, Hash1, Hash2>::operato
{
using size_type = typename Extent::value_type;
return detail::probing_iterator<Extent>{
cuco::detail::sanitize_hash<size_type>(hash1_(probe_key), g.thread_rank()) % upper_bound,
cuco::detail::sanitize_hash<size_type>(hash1_(probe_key), g) % upper_bound,
static_cast<size_type>(
(cuco::detail::sanitize_hash<size_type>(hash2_(probe_key)) % (upper_bound / cg_size - 1) +
1) *
Expand Down
15 changes: 12 additions & 3 deletions include/cuco/detail/utils.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@
#include <cuda/std/array>
srinivasyadav18 marked this conversation as resolved.
Show resolved Hide resolved
#include <cuda/std/bit>
#include <cuda/std/cmath>
#include <cuda/std/limits>
#include <cuda/std/type_traits>
#include <thrust/tuple.h>

#include <cstddef>

namespace cuco {
namespace detail {

Expand Down Expand Up @@ -122,13 +125,19 @@ __host__ __device__ constexpr SizeType sanitize_hash(HashType hash) noexcept
*
* @tparam SizeType The target type
* @tparam HashType The input type
* @tparam CG Cooperative group type
*
* @return Converted hash value
*/
template <typename SizeType, typename HashType>
__host__ __device__ constexpr SizeType sanitize_hash(HashType hash, std::uint32_t cg_rank) noexcept
template <typename SizeType, typename HashType, typename CG>
__host__ __device__ constexpr SizeType sanitize_hash(HashType hash, CG group) noexcept
srinivasyadav18 marked this conversation as resolved.
Show resolved Hide resolved
{
return sanitize_hash<SizeType>(sanitize_hash<SizeType>(hash) + cg_rank);
auto const base_hash = sanitize_hash<SizeType>(hash);
auto const max_size = cuda::std::numeric_limits<SizeType>::max();
auto const cg_rank = static_cast<SizeType>(group.thread_rank());

if (base_hash > (max_size - cg_rank)) return cg_rank - (max_size - base_hash);
sleeepyjack marked this conversation as resolved.
Show resolved Hide resolved
sleeepyjack marked this conversation as resolved.
Show resolved Hide resolved
return base_hash + cg_rank;
}

} // namespace detail
Expand Down