Skip to content

Commit

Permalink
Remove the redundant thrust pair like trait
Browse files Browse the repository at this point in the history
  • Loading branch information
PointKernel authored and bdice committed Mar 5, 2024
1 parent 4f75315 commit fbc559e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 36 deletions.
4 changes: 2 additions & 2 deletions include/cuco/detail/open_addressing/functors.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ struct slot_is_filled {
auto const key = [&]() {
if constexpr (HasPayload) {
// required by thrust zip iterator in `retrieve_all`
if constexpr (cuco::detail::is_thrust_pair_like<S>::value) {
return thrust::get<0>(slot);
if constexpr (cuco::detail::is_cuda_std_pair_like<S>::value) {
return cuda::std::get<0>(slot);
} else {
return slot.first;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1071,8 +1071,6 @@ class open_addressing_ref_impl {
if constexpr (cuco::detail::is_cuda_std_pair_like<T>::value) {
return cuco::pair{cuda::std::get<0>(value),
static_cast<mapped_type>(cuda::std::get<1>(value))};
} else if constexpr (cuco::detail::is_thrust_pair_like<T>::value) {
return cuco::pair{thrust::get<0>(value), static_cast<mapped_type>(thrust::get<1>(value))};
} else {
// hail mary (convert using .first/.second members)
return cuco::pair{thrust::raw_reference_cast(value.first),
Expand Down
24 changes: 6 additions & 18 deletions include/cuco/detail/traits.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, NVIDIA CORPORATION.
* Copyright (c) 2023-2024, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,10 +16,10 @@
#pragma once

#include <thrust/device_reference.h>
#include <thrust/tuple.h>

#include <cuda/std/tuple>
#include <cuda/std/type_traits>

#include <tuple>

namespace cuco::detail {
Expand All @@ -35,32 +35,20 @@ struct is_std_pair_like<T,
conditional_t<std::tuple_size<T>::value == 2, cuda::std::true_type, cuda::std::false_type> {};

template <typename T, typename = void>
struct is_cuda_std_pair_like : cuda::std::false_type {};
struct is_cuda_std_pair_like_impl : cuda::std::false_type {};

template <typename T>
struct is_cuda_std_pair_like<
struct is_cuda_std_pair_like_impl<
T,
cuda::std::void_t<decltype(cuda::std::get<0>(cuda::std::declval<T>())),
decltype(cuda::std::get<1>(cuda::std::declval<T>()))>>
: cuda::std::conditional_t<cuda::std::tuple_size<T>::value == 2,
cuda::std::true_type,
cuda::std::false_type> {};

template <typename T, typename = void>
struct is_thrust_pair_like_impl : cuda::std::false_type {};

template <typename T>
struct is_thrust_pair_like_impl<
T,
cuda::std::void_t<decltype(thrust::get<0>(cuda::std::declval<T>())),
decltype(thrust::get<1>(cuda::std::declval<T>()))>>
: cuda::std::conditional_t<thrust::tuple_size<T>::value == 2,
cuda::std::true_type,
cuda::std::false_type> {};

template <typename T>
struct is_thrust_pair_like
: is_thrust_pair_like_impl<cuda::std::remove_reference_t<decltype(thrust::raw_reference_cast(
struct is_cuda_std_pair_like
: is_cuda_std_pair_like_impl<cuda::std::remove_reference_t<decltype(thrust::raw_reference_cast(
cuda::std::declval<T>()))>> {};

} // namespace cuco::detail
14 changes: 0 additions & 14 deletions include/cuco/pair.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,6 @@ struct alignas(detail::pair_alignment<First, Second>()) pair {
{
}

/**
* @brief Constructs a pair from the given thrust::pair-like `p`.
*
* @tparam T Type of the pair to copy from
*
* @param p The input pair to copy from
*/
template <typename T, std::enable_if_t<detail::is_thrust_pair_like<T>::value>* = nullptr>
__host__ __device__ constexpr pair(T const& p)
: pair{thrust::get<0>(thrust::raw_reference_cast(p)),
thrust::get<1>(thrust::raw_reference_cast(p))}
{
}

First first; ///< The first value in the pair
Second second; ///< The second value in the pair
};
Expand Down

0 comments on commit fbc559e

Please sign in to comment.