21 #ifndef ROCPRIM_WARP_WARP_SORT_HPP_ 22 #define ROCPRIM_WARP_WARP_SORT_HPP_ 24 #include <type_traits> 26 #include "../config.hpp" 27 #include "../detail/various.hpp" 29 #include "../intrinsics.hpp" 30 #include "../functional.hpp" 32 #include "detail/warp_sort_shuffle.hpp" 37 BEGIN_ROCPRIM_NAMESPACE
104 static_assert(WarpSize <= ROCPRIM_MAX_WARP_SIZE,
"WarpSize can't be greater than hardware warp size.");
127 template<
class BinaryFunction = ::rocprim::less<Key>,
unsigned int FunctionWarpSize = WarpSize>
128 ROCPRIM_DEVICE ROCPRIM_INLINE
130 BinaryFunction compare_function = BinaryFunction())
131 ->
typename std::enable_if<(FunctionWarpSize <= __AMDGCN_WAVEFRONT_SIZE), void>::type
133 base_type::sort(thread_key, compare_function);
138 template<
class BinaryFunction = ::rocprim::less<Key>,
unsigned int FunctionWarpSize = WarpSize>
139 ROCPRIM_DEVICE ROCPRIM_INLINE
141 BinaryFunction compare_function = BinaryFunction())
142 ->
typename std::enable_if<(FunctionWarpSize > __AMDGCN_WAVEFRONT_SIZE),
void>::type
144 (void) compare_function;
160 unsigned int ItemsPerThread,
161 class BinaryFunction = ::rocprim::less<Key>,
162 unsigned int FunctionWarpSize = WarpSize
164 ROCPRIM_DEVICE ROCPRIM_INLINE
165 auto sort(Key (&thread_keys)[ItemsPerThread],
166 BinaryFunction compare_function = BinaryFunction())
167 ->
typename std::enable_if<(FunctionWarpSize <= __AMDGCN_WAVEFRONT_SIZE), void>::type
169 base_type::sort(thread_keys, compare_function);
175 unsigned int ItemsPerThread,
176 class BinaryFunction = ::rocprim::less<Key>,
177 unsigned int FunctionWarpSize = WarpSize
179 ROCPRIM_DEVICE ROCPRIM_INLINE
180 auto sort(Key (&thread_keys)[ItemsPerThread],
181 BinaryFunction compare_function = BinaryFunction())
182 ->
typename std::enable_if<(FunctionWarpSize > __AMDGCN_WAVEFRONT_SIZE),
void>::type
185 (void) compare_function;
218 template<
class BinaryFunction = ::rocprim::less<Key>,
unsigned int FunctionWarpSize = WarpSize>
219 ROCPRIM_DEVICE ROCPRIM_INLINE
221 storage_type& storage,
222 BinaryFunction compare_function = BinaryFunction())
223 ->
typename std::enable_if<(FunctionWarpSize <= __AMDGCN_WAVEFRONT_SIZE), void>::type
226 thread_key, storage, compare_function
232 template<
class BinaryFunction = ::rocprim::less<Key>,
unsigned int FunctionWarpSize = WarpSize>
233 ROCPRIM_DEVICE ROCPRIM_INLINE
236 BinaryFunction compare_function = BinaryFunction())
237 ->
typename std::enable_if<(FunctionWarpSize > __AMDGCN_WAVEFRONT_SIZE),
void>::type
239 (void) compare_function;
274 unsigned int ItemsPerThread,
275 class BinaryFunction = ::rocprim::less<Key>,
276 unsigned int FunctionWarpSize = WarpSize
278 ROCPRIM_DEVICE ROCPRIM_INLINE
279 auto sort(Key (&thread_keys)[ItemsPerThread],
280 storage_type& storage,
281 BinaryFunction compare_function = BinaryFunction())
282 ->
typename std::enable_if<(FunctionWarpSize <= __AMDGCN_WAVEFRONT_SIZE), void>::type
285 thread_keys, storage, compare_function
292 unsigned int ItemsPerThread,
293 class BinaryFunction = ::rocprim::less<Key>,
294 unsigned int FunctionWarpSize = WarpSize
296 ROCPRIM_DEVICE ROCPRIM_INLINE
297 auto sort(Key (&thread_keys)[ItemsPerThread],
299 BinaryFunction compare_function = BinaryFunction())
300 ->
typename std::enable_if<(FunctionWarpSize > __AMDGCN_WAVEFRONT_SIZE),
void>::type
303 (void) compare_function;
319 template<
class BinaryFunction = ::rocprim::less<Key>,
unsigned int FunctionWarpSize = WarpSize>
320 ROCPRIM_DEVICE ROCPRIM_INLINE
323 BinaryFunction compare_function = BinaryFunction())
324 ->
typename std::enable_if<(FunctionWarpSize <= __AMDGCN_WAVEFRONT_SIZE), void>::type
327 thread_key, thread_value, compare_function
333 template<
class BinaryFunction = ::rocprim::less<Key>,
unsigned int FunctionWarpSize = WarpSize>
334 ROCPRIM_DEVICE ROCPRIM_INLINE
337 BinaryFunction compare_function = BinaryFunction())
338 ->
typename std::enable_if<(FunctionWarpSize > __AMDGCN_WAVEFRONT_SIZE),
void>::type
340 (void) compare_function;
357 unsigned int ItemsPerThread,
358 class BinaryFunction = ::rocprim::less<Key>,
359 unsigned int FunctionWarpSize = WarpSize
361 ROCPRIM_DEVICE ROCPRIM_INLINE
362 auto sort(Key (&thread_keys)[ItemsPerThread],
363 Value (&thread_values)[ItemsPerThread],
364 BinaryFunction compare_function = BinaryFunction())
365 ->
typename std::enable_if<(FunctionWarpSize <= __AMDGCN_WAVEFRONT_SIZE), void>::type
368 thread_keys, thread_values, compare_function
375 unsigned int ItemsPerThread,
376 class BinaryFunction = ::rocprim::less<Key>,
377 unsigned int FunctionWarpSize = WarpSize
379 ROCPRIM_DEVICE ROCPRIM_INLINE
380 auto sort(Key (&thread_keys)[ItemsPerThread],
381 Value (&thread_values)[ItemsPerThread],
382 BinaryFunction compare_function = BinaryFunction())
383 ->
typename std::enable_if<(FunctionWarpSize > __AMDGCN_WAVEFRONT_SIZE),
void>::type
386 (void) thread_values;
387 (void) compare_function;
421 template<
class BinaryFunction = ::rocprim::less<Key>,
unsigned int FunctionWarpSize = WarpSize>
422 ROCPRIM_DEVICE ROCPRIM_INLINE
425 storage_type& storage,
426 BinaryFunction compare_function = BinaryFunction())
427 ->
typename std::enable_if<(FunctionWarpSize <= __AMDGCN_WAVEFRONT_SIZE), void>::type
430 thread_key, thread_value, storage, compare_function
436 template<
class BinaryFunction = ::rocprim::less<Key>,
unsigned int FunctionWarpSize = WarpSize>
437 ROCPRIM_DEVICE ROCPRIM_INLINE
441 BinaryFunction compare_function = BinaryFunction())
442 ->
typename std::enable_if<(FunctionWarpSize > __AMDGCN_WAVEFRONT_SIZE),
void>::type
444 (void) compare_function;
480 unsigned int ItemsPerThread,
481 class BinaryFunction = ::rocprim::less<Key>,
482 unsigned int FunctionWarpSize = WarpSize
484 ROCPRIM_DEVICE ROCPRIM_INLINE
485 auto sort(Key (&thread_keys)[ItemsPerThread],
486 Value (&thread_values)[ItemsPerThread],
487 storage_type& storage,
488 BinaryFunction compare_function = BinaryFunction())
489 ->
typename std::enable_if<(FunctionWarpSize <= __AMDGCN_WAVEFRONT_SIZE), void>::type
492 thread_keys, thread_values, storage, compare_function
499 unsigned int ItemsPerThread,
500 class BinaryFunction = ::rocprim::less<Key>,
501 unsigned int FunctionWarpSize = WarpSize
503 ROCPRIM_DEVICE ROCPRIM_INLINE
504 auto sort(Key (&thread_keys)[ItemsPerThread],
505 Value (&thread_values)[ItemsPerThread],
507 BinaryFunction compare_function = BinaryFunction())
508 ->
typename std::enable_if<(FunctionWarpSize > __AMDGCN_WAVEFRONT_SIZE),
void>::type
511 (void) thread_values;
512 (void) compare_function;
518 END_ROCPRIM_NAMESPACE
523 #endif // ROCPRIM_WARP_WARP_SORT_HPP_ Empty type used as a placeholder, usually used to flag that given template parameter should not be us...
Definition: types.hpp:135
ROCPRIM_DEVICE ROCPRIM_INLINE auto sort(Key &thread_key, Value &thread_value, storage_type &storage, BinaryFunction compare_function=BinaryFunction()) -> typename std::enable_if<(FunctionWarpSize<=__AMDGCN_WAVEFRONT_SIZE), void >::type
Warp sort by key for any data type using temporary storage.
Definition: warp_sort.hpp:423
Definition: warp_sort_shuffle.hpp:42
ROCPRIM_DEVICE ROCPRIM_INLINE auto sort(Key &thread_key, Value &thread_value, BinaryFunction compare_function=BinaryFunction()) -> typename std::enable_if<(FunctionWarpSize<=__AMDGCN_WAVEFRONT_SIZE), void >::type
Warp sort by key for any data type.
Definition: warp_sort.hpp:321
ROCPRIM_DEVICE ROCPRIM_INLINE auto sort(Key(&thread_keys)[ItemsPerThread], storage_type &, BinaryFunction compare_function=BinaryFunction()) -> typename std::enable_if<(FunctionWarpSize > __AMDGCN_WAVEFRONT_SIZE), void >::type
Warp sort for any data type using temporary storage.
Definition: warp_sort.hpp:297
ROCPRIM_DEVICE ROCPRIM_INLINE auto sort(Key(&thread_keys)[ItemsPerThread], Value(&thread_values)[ItemsPerThread], storage_type &storage, BinaryFunction compare_function=BinaryFunction()) -> typename std::enable_if<(FunctionWarpSize<=__AMDGCN_WAVEFRONT_SIZE), void >::type
Warp sort by key for any data type using temporary storage.
Definition: warp_sort.hpp:485
ROCPRIM_DEVICE ROCPRIM_INLINE constexpr unsigned int device_warp_size()
Returns a number of threads in a hardware warp for the actual target.
Definition: thread.hpp:70
ROCPRIM_DEVICE ROCPRIM_INLINE auto sort(Key &, storage_type &, BinaryFunction compare_function=BinaryFunction()) -> typename std::enable_if<(FunctionWarpSize > __AMDGCN_WAVEFRONT_SIZE), void >::type
Warp sort for any data type using temporary storage.
Definition: warp_sort.hpp:234
ROCPRIM_DEVICE ROCPRIM_INLINE auto sort(Key(&thread_keys)[ItemsPerThread], Value(&thread_values)[ItemsPerThread], BinaryFunction compare_function=BinaryFunction()) -> typename std::enable_if<(FunctionWarpSize<=__AMDGCN_WAVEFRONT_SIZE), void >::type
Warp sort by key for any data type.
Definition: warp_sort.hpp:362
base_type::storage_type storage_type
Struct used to allocate a temporary memory that is required for thread communication during operation...
Definition: warp_sort.hpp:104
The warp_sort class provides warp-wide methods for computing a parallel sort of items across thread w...
Definition: warp_sort.hpp:99
ROCPRIM_DEVICE ROCPRIM_INLINE auto sort(Key(&thread_keys)[ItemsPerThread], Value(&thread_values)[ItemsPerThread], storage_type &, BinaryFunction compare_function=BinaryFunction()) -> typename std::enable_if<(FunctionWarpSize > __AMDGCN_WAVEFRONT_SIZE), void >::type
Warp sort by key for any data type using temporary storage.
Definition: warp_sort.hpp:504
ROCPRIM_DEVICE ROCPRIM_INLINE auto sort(Key &, Value &, storage_type &, BinaryFunction compare_function=BinaryFunction()) -> typename std::enable_if<(FunctionWarpSize > __AMDGCN_WAVEFRONT_SIZE), void >::type
Warp sort by key for any data type using temporary storage.
Definition: warp_sort.hpp:438
ROCPRIM_DEVICE ROCPRIM_INLINE auto sort(Key(&thread_keys)[ItemsPerThread], storage_type &storage, BinaryFunction compare_function=BinaryFunction()) -> typename std::enable_if<(FunctionWarpSize<=__AMDGCN_WAVEFRONT_SIZE), void >::type
Warp sort for any data type using temporary storage.
Definition: warp_sort.hpp:279
ROCPRIM_DEVICE ROCPRIM_INLINE auto sort(Key(&thread_keys)[ItemsPerThread], Value(&thread_values)[ItemsPerThread], BinaryFunction compare_function=BinaryFunction()) -> typename std::enable_if<(FunctionWarpSize > __AMDGCN_WAVEFRONT_SIZE), void >::type
Warp sort by key for any data type.
Definition: warp_sort.hpp:380
ROCPRIM_DEVICE ROCPRIM_INLINE auto sort(Key &thread_key, BinaryFunction compare_function=BinaryFunction()) -> typename std::enable_if<(FunctionWarpSize<=__AMDGCN_WAVEFRONT_SIZE), void >::type
Warp sort for any data type.
Definition: warp_sort.hpp:129
ROCPRIM_DEVICE ROCPRIM_INLINE auto sort(Key &thread_key, storage_type &storage, BinaryFunction compare_function=BinaryFunction()) -> typename std::enable_if<(FunctionWarpSize<=__AMDGCN_WAVEFRONT_SIZE), void >::type
Warp sort for any data type using temporary storage.
Definition: warp_sort.hpp:220
ROCPRIM_DEVICE ROCPRIM_INLINE auto sort(Key(&thread_keys)[ItemsPerThread], BinaryFunction compare_function=BinaryFunction()) -> typename std::enable_if<(FunctionWarpSize<=__AMDGCN_WAVEFRONT_SIZE), void >::type
Warp sort for any data type.
Definition: warp_sort.hpp:165
#define ROCPRIM_PRINT_ERROR_ONCE(message)
Prints the supplied error message only once (using only one of the active threads).
Definition: functional.hpp:42
ROCPRIM_DEVICE ROCPRIM_INLINE auto sort(Key(&thread_keys)[ItemsPerThread], BinaryFunction compare_function=BinaryFunction()) -> typename std::enable_if<(FunctionWarpSize > __AMDGCN_WAVEFRONT_SIZE), void >::type
Warp sort for any data type.
Definition: warp_sort.hpp:180
ROCPRIM_DEVICE ROCPRIM_INLINE auto sort(Key &, Value &, BinaryFunction compare_function=BinaryFunction()) -> typename std::enable_if<(FunctionWarpSize > __AMDGCN_WAVEFRONT_SIZE), void >::type
Warp sort by key for any data type.
Definition: warp_sort.hpp:335
ROCPRIM_DEVICE ROCPRIM_INLINE auto sort(Key &, BinaryFunction compare_function=BinaryFunction()) -> typename std::enable_if<(FunctionWarpSize > __AMDGCN_WAVEFRONT_SIZE), void >::type
Warp sort for any data type.
Definition: warp_sort.hpp:140