30 #ifndef HIPCUB_ROCPRIM_DEVICE_DEVICE_SEGMENTED_RADIX_SORT_HPP_
31 #define HIPCUB_ROCPRIM_DEVICE_DEVICE_SEGMENTED_RADIX_SORT_HPP_
33 #include "../../../config.hpp"
35 #include "../util_type.hpp"
37 #include <rocprim/device/device_segmented_radix_sort.hpp>
39 BEGIN_HIPCUB_NAMESPACE
41 struct DeviceSegmentedRadixSort
43 template<
typename KeyT,
typename ValueT,
typename OffsetIteratorT>
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 OffsetIteratorT d_begin_offsets,
54 OffsetIteratorT d_end_offsets,
56 int end_bit =
sizeof(KeyT) * 8,
57 hipStream_t stream = 0,
58 bool debug_synchronous =
false)
60 return ::rocprim::segmented_radix_sort_pairs(
61 d_temp_storage, temp_storage_bytes,
62 d_keys_in, d_keys_out, d_values_in, d_values_out, num_items,
63 num_segments, d_begin_offsets, d_end_offsets,
65 stream, debug_synchronous
69 template<
typename KeyT,
typename ValueT,
typename OffsetIteratorT>
70 HIPCUB_RUNTIME_FUNCTION
static
71 hipError_t SortPairs(
void * d_temp_storage,
72 size_t& temp_storage_bytes,
73 DoubleBuffer<KeyT>& d_keys,
74 DoubleBuffer<ValueT>& d_values,
77 OffsetIteratorT d_begin_offsets,
78 OffsetIteratorT d_end_offsets,
80 int end_bit =
sizeof(KeyT) * 8,
81 hipStream_t stream = 0,
82 bool debug_synchronous =
false)
84 ::rocprim::double_buffer<KeyT> d_keys_db = detail::to_double_buffer(d_keys);
85 ::rocprim::double_buffer<ValueT> d_values_db = detail::to_double_buffer(d_values);
86 hipError_t error = ::rocprim::segmented_radix_sort_pairs(
87 d_temp_storage, temp_storage_bytes,
88 d_keys_db, d_values_db, num_items,
89 num_segments, d_begin_offsets, d_end_offsets,
91 stream, debug_synchronous
93 detail::update_double_buffer(d_keys, d_keys_db);
94 detail::update_double_buffer(d_values, d_values_db);
98 template<
typename KeyT,
typename ValueT,
typename OffsetIteratorT>
99 HIPCUB_RUNTIME_FUNCTION
static
100 hipError_t SortPairsDescending(
void * d_temp_storage,
101 size_t& temp_storage_bytes,
102 const KeyT * d_keys_in,
104 const ValueT * d_values_in,
105 ValueT * d_values_out,
108 OffsetIteratorT d_begin_offsets,
109 OffsetIteratorT d_end_offsets,
111 int end_bit =
sizeof(KeyT) * 8,
112 hipStream_t stream = 0,
113 bool debug_synchronous =
false)
115 return ::rocprim::segmented_radix_sort_pairs_desc(
116 d_temp_storage, temp_storage_bytes,
117 d_keys_in, d_keys_out, d_values_in, d_values_out, num_items,
118 num_segments, d_begin_offsets, d_end_offsets,
120 stream, debug_synchronous
124 template<
typename KeyT,
typename ValueT,
typename OffsetIteratorT>
125 HIPCUB_RUNTIME_FUNCTION
static
126 hipError_t SortPairsDescending(
void * d_temp_storage,
127 size_t& temp_storage_bytes,
128 DoubleBuffer<KeyT>& d_keys,
129 DoubleBuffer<ValueT>& d_values,
132 OffsetIteratorT d_begin_offsets,
133 OffsetIteratorT d_end_offsets,
135 int end_bit =
sizeof(KeyT) * 8,
136 hipStream_t stream = 0,
137 bool debug_synchronous =
false)
139 ::rocprim::double_buffer<KeyT> d_keys_db = detail::to_double_buffer(d_keys);
140 ::rocprim::double_buffer<ValueT> d_values_db = detail::to_double_buffer(d_values);
141 hipError_t error = ::rocprim::segmented_radix_sort_pairs_desc(
142 d_temp_storage, temp_storage_bytes,
143 d_keys_db, d_values_db, num_items,
144 num_segments, d_begin_offsets, d_end_offsets,
146 stream, debug_synchronous
148 detail::update_double_buffer(d_keys, d_keys_db);
149 detail::update_double_buffer(d_values, d_values_db);
153 template<
typename KeyT,
typename OffsetIteratorT>
154 HIPCUB_RUNTIME_FUNCTION
static
155 hipError_t SortKeys(
void * d_temp_storage,
156 size_t& temp_storage_bytes,
157 const KeyT * d_keys_in,
161 OffsetIteratorT d_begin_offsets,
162 OffsetIteratorT d_end_offsets,
164 int end_bit =
sizeof(KeyT) * 8,
165 hipStream_t stream = 0,
166 bool debug_synchronous =
false)
168 return ::rocprim::segmented_radix_sort_keys(
169 d_temp_storage, temp_storage_bytes,
170 d_keys_in, d_keys_out, num_items,
171 num_segments, d_begin_offsets, d_end_offsets,
173 stream, debug_synchronous
177 template<
typename KeyT,
typename OffsetIteratorT>
178 HIPCUB_RUNTIME_FUNCTION
static
179 hipError_t SortKeys(
void * d_temp_storage,
180 size_t& temp_storage_bytes,
181 DoubleBuffer<KeyT>& d_keys,
184 OffsetIteratorT d_begin_offsets,
185 OffsetIteratorT d_end_offsets,
187 int end_bit =
sizeof(KeyT) * 8,
188 hipStream_t stream = 0,
189 bool debug_synchronous =
false)
191 ::rocprim::double_buffer<KeyT> d_keys_db = detail::to_double_buffer(d_keys);
192 hipError_t error = ::rocprim::segmented_radix_sort_keys(
193 d_temp_storage, temp_storage_bytes,
194 d_keys_db, num_items,
195 num_segments, d_begin_offsets, d_end_offsets,
197 stream, debug_synchronous
199 detail::update_double_buffer(d_keys, d_keys_db);
203 template<
typename KeyT,
typename OffsetIteratorT>
204 HIPCUB_RUNTIME_FUNCTION
static
205 hipError_t SortKeysDescending(
void * d_temp_storage,
206 size_t& temp_storage_bytes,
207 const KeyT * d_keys_in,
211 OffsetIteratorT d_begin_offsets,
212 OffsetIteratorT d_end_offsets,
214 int end_bit =
sizeof(KeyT) * 8,
215 hipStream_t stream = 0,
216 bool debug_synchronous =
false)
218 return ::rocprim::segmented_radix_sort_keys_desc(
219 d_temp_storage, temp_storage_bytes,
220 d_keys_in, d_keys_out, num_items,
221 num_segments, d_begin_offsets, d_end_offsets,
223 stream, debug_synchronous
227 template<
typename KeyT,
typename OffsetIteratorT>
228 HIPCUB_RUNTIME_FUNCTION
static
229 hipError_t SortKeysDescending(
void * d_temp_storage,
230 size_t& temp_storage_bytes,
231 DoubleBuffer<KeyT>& d_keys,
234 OffsetIteratorT d_begin_offsets,
235 OffsetIteratorT d_end_offsets,
237 int end_bit =
sizeof(KeyT) * 8,
238 hipStream_t stream = 0,
239 bool debug_synchronous =
false)
241 ::rocprim::double_buffer<KeyT> d_keys_db = detail::to_double_buffer(d_keys);
242 hipError_t error = ::rocprim::segmented_radix_sort_keys_desc(
243 d_temp_storage, temp_storage_bytes,
244 d_keys_db, num_items,
245 num_segments, d_begin_offsets, d_end_offsets,
247 stream, debug_synchronous
249 detail::update_double_buffer(d_keys, d_keys_db);