30 #ifndef HIPCUB_ROCPRIM_DEVICE_DEVICE_RADIX_SORT_HPP_
31 #define HIPCUB_ROCPRIM_DEVICE_DEVICE_RADIX_SORT_HPP_
33 #include "../../../config.hpp"
35 #include "../util_type.hpp"
37 #include <rocprim/device/device_radix_sort.hpp>
39 BEGIN_HIPCUB_NAMESPACE
41 struct DeviceRadixSort
43 template<
typename KeyT,
typename ValueT,
typename NumItemsT>
44 HIPCUB_RUNTIME_FUNCTION
static
45 hipError_t SortPairs(
void * d_temp_storage,
46 size_t& temp_storage_bytes,
47 const KeyT * d_keys_in,
49 const ValueT * d_values_in,
50 ValueT * d_values_out,
53 int end_bit =
sizeof(KeyT) * 8,
54 hipStream_t stream = 0,
55 bool debug_synchronous =
false)
57 return ::rocprim::radix_sort_pairs(
58 d_temp_storage, temp_storage_bytes,
59 d_keys_in, d_keys_out, d_values_in, d_values_out, num_items,
61 stream, debug_synchronous
65 template<
typename KeyT,
typename ValueT,
typename NumItemsT>
66 HIPCUB_RUNTIME_FUNCTION
static
67 hipError_t SortPairs(
void * d_temp_storage,
68 size_t& temp_storage_bytes,
69 DoubleBuffer<KeyT>& d_keys,
70 DoubleBuffer<ValueT>& d_values,
73 int end_bit =
sizeof(KeyT) * 8,
74 hipStream_t stream = 0,
75 bool debug_synchronous =
false)
77 ::rocprim::double_buffer<KeyT> d_keys_db = detail::to_double_buffer(d_keys);
78 ::rocprim::double_buffer<ValueT> d_values_db = detail::to_double_buffer(d_values);
79 hipError_t error = ::rocprim::radix_sort_pairs(
80 d_temp_storage, temp_storage_bytes,
81 d_keys_db, d_values_db, num_items,
83 stream, debug_synchronous
85 detail::update_double_buffer(d_keys, d_keys_db);
86 detail::update_double_buffer(d_values, d_values_db);
90 template<
typename KeyT,
typename ValueT,
typename NumItemsT>
91 HIPCUB_RUNTIME_FUNCTION
static
92 hipError_t SortPairsDescending(
void * d_temp_storage,
93 size_t& temp_storage_bytes,
94 const KeyT * d_keys_in,
96 const ValueT * d_values_in,
97 ValueT * d_values_out,
100 int end_bit =
sizeof(KeyT) * 8,
101 hipStream_t stream = 0,
102 bool debug_synchronous =
false)
104 return ::rocprim::radix_sort_pairs_desc(
105 d_temp_storage, temp_storage_bytes,
106 d_keys_in, d_keys_out, d_values_in, d_values_out, num_items,
108 stream, debug_synchronous
112 template<
typename KeyT,
typename ValueT,
typename NumItemsT>
113 HIPCUB_RUNTIME_FUNCTION
static
114 hipError_t SortPairsDescending(
void * d_temp_storage,
115 size_t& temp_storage_bytes,
116 DoubleBuffer<KeyT>& d_keys,
117 DoubleBuffer<ValueT>& d_values,
120 int end_bit =
sizeof(KeyT) * 8,
121 hipStream_t stream = 0,
122 bool debug_synchronous =
false)
124 ::rocprim::double_buffer<KeyT> d_keys_db = detail::to_double_buffer(d_keys);
125 ::rocprim::double_buffer<ValueT> d_values_db = detail::to_double_buffer(d_values);
126 hipError_t error = ::rocprim::radix_sort_pairs_desc(
127 d_temp_storage, temp_storage_bytes,
128 d_keys_db, d_values_db, num_items,
130 stream, debug_synchronous
132 detail::update_double_buffer(d_keys, d_keys_db);
133 detail::update_double_buffer(d_values, d_values_db);
137 template<
typename KeyT,
typename NumItemsT>
138 HIPCUB_RUNTIME_FUNCTION
static
139 hipError_t SortKeys(
void * d_temp_storage,
140 size_t& temp_storage_bytes,
141 const KeyT * d_keys_in,
145 int end_bit =
sizeof(KeyT) * 8,
146 hipStream_t stream = 0,
147 bool debug_synchronous =
false)
149 return ::rocprim::radix_sort_keys(
150 d_temp_storage, temp_storage_bytes,
151 d_keys_in, d_keys_out, num_items,
153 stream, debug_synchronous
157 template<
typename KeyT,
typename NumItemsT>
158 HIPCUB_RUNTIME_FUNCTION
static
159 hipError_t SortKeys(
void * d_temp_storage,
160 size_t& temp_storage_bytes,
161 DoubleBuffer<KeyT>& d_keys,
164 int end_bit =
sizeof(KeyT) * 8,
165 hipStream_t stream = 0,
166 bool debug_synchronous =
false)
168 ::rocprim::double_buffer<KeyT> d_keys_db = detail::to_double_buffer(d_keys);
169 hipError_t error = ::rocprim::radix_sort_keys(
170 d_temp_storage, temp_storage_bytes,
171 d_keys_db, num_items,
173 stream, debug_synchronous
175 detail::update_double_buffer(d_keys, d_keys_db);
179 template<
typename KeyT,
typename NumItemsT>
180 HIPCUB_RUNTIME_FUNCTION
static
181 hipError_t SortKeysDescending(
void * d_temp_storage,
182 size_t& temp_storage_bytes,
183 const KeyT * d_keys_in,
187 int end_bit =
sizeof(KeyT) * 8,
188 hipStream_t stream = 0,
189 bool debug_synchronous =
false)
191 return ::rocprim::radix_sort_keys_desc(
192 d_temp_storage, temp_storage_bytes,
193 d_keys_in, d_keys_out, num_items,
195 stream, debug_synchronous
199 template<
typename KeyT,
typename NumItemsT>
200 HIPCUB_RUNTIME_FUNCTION
static
201 hipError_t SortKeysDescending(
void * d_temp_storage,
202 size_t& temp_storage_bytes,
203 DoubleBuffer<KeyT>& d_keys,
206 int end_bit =
sizeof(KeyT) * 8,
207 hipStream_t stream = 0,
208 bool debug_synchronous =
false)
210 ::rocprim::double_buffer<KeyT> d_keys_db = detail::to_double_buffer(d_keys);
211 hipError_t error = ::rocprim::radix_sort_keys_desc(
212 d_temp_storage, temp_storage_bytes,
213 d_keys_db, num_items,
215 stream, debug_synchronous
217 detail::update_double_buffer(d_keys, d_keys_db);