35 #ifndef HIPCUB_ROCPRIM_BLOCK_RADIX_RANK_SORT_OPERATIONS_HPP_
36 #define HIPCUB_ROCPRIM_BLOCK_RADIX_RANK_SORT_OPERATIONS_HPP_
38 #include <type_traits>
40 #include "../../../config.hpp"
42 #include <rocprim/config.hpp>
43 #include <rocprim/type_traits.hpp>
44 #include <rocprim/detail/various.hpp>
46 BEGIN_HIPCUB_NAMESPACE
49 template <
bool IS_DESCENDING,
typename KeyT>
52 typedef Traits<KeyT> TraitsT;
53 typedef typename TraitsT::UnsignedBits UnsignedBits;
54 static HIPCUB_HOST_DEVICE __forceinline__ UnsignedBits In(UnsignedBits key)
56 key = TraitsT::TwiddleIn(key);
57 if (IS_DESCENDING) key = ~key;
60 static HIPCUB_HOST_DEVICE __forceinline__ UnsignedBits Out(UnsignedBits key)
62 if (IS_DESCENDING) key = ~key;
63 key = TraitsT::TwiddleOut(key);
66 static HIPCUB_HOST_DEVICE __forceinline__ UnsignedBits DefaultKey()
68 return Out(~UnsignedBits(0));
88 template <
typename KeyT>
91 typedef Traits<KeyT> TraitsT;
92 typedef typename TraitsT::UnsignedBits UnsignedBits;
96 FLOAT_KEY = TraitsT::CATEGORY == FLOATING_POINT,
99 static __device__ __forceinline__ UnsignedBits ProcessFloatMinusZero(UnsignedBits key)
104 UnsignedBits TWIDDLED_MINUS_ZERO_BITS =
105 TraitsT::TwiddleIn(UnsignedBits(1) << UnsignedBits(8 *
sizeof(UnsignedBits) - 1));
106 UnsignedBits TWIDDLED_ZERO_BITS = TraitsT::TwiddleIn(0);
107 return key == TWIDDLED_MINUS_ZERO_BITS ? TWIDDLED_ZERO_BITS : key;
114 template <
typename KeyT>
117 using typename BaseDigitExtractor<KeyT>::UnsignedBits;
119 uint32_t bit_start, num_bits;
121 uint32_t bit_start = 0, uint32_t num_bits = 0)
122 : bit_start(bit_start), num_bits(num_bits)
125 __device__ __forceinline__ uint32_t Digit(UnsignedBits key)
127 return BFE(this->ProcessFloatMinusZero(key), bit_start, num_bits);
133 template <
typename KeyT>
136 using typename BaseDigitExtractor<KeyT>::UnsignedBits;
138 uint32_t bit_start, mask;
140 uint32_t bit_start = 0, uint32_t num_bits = 0)
141 : bit_start(bit_start), mask((1 << num_bits) - 1)
144 __device__ __forceinline__ uint32_t Digit(UnsignedBits key)
146 return uint32_t(this->ProcessFloatMinusZero(key) >> UnsignedBits(bit_start)) & mask;
Twiddling keys for radix sort.
Definition: radix_rank_sort_operations.hpp:51