/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-hipcub/checkouts/docs-5.7.0/hipcub/include/hipcub/backend/cub/device/device_segmented_sort.hpp Source File

/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-hipcub/checkouts/docs-5.7.0/hipcub/include/hipcub/backend/cub/device/device_segmented_sort.hpp Source File#

hipCUB: /home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-hipcub/checkouts/docs-5.7.0/hipcub/include/hipcub/backend/cub/device/device_segmented_sort.hpp Source File
device_segmented_sort.hpp
1 /******************************************************************************
2  * Copyright (c) 2010-2011, Duane Merrill. All rights reserved.
3  * Copyright (c) 2011-2018, NVIDIA CORPORATION. All rights reserved.
4  * Modifications Copyright (c) 2017-2023, Advanced Micro Devices, Inc. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the NVIDIA CORPORATION nor the
14  * names of its contributors may be used to endorse or promote products
15  * derived from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR ANY
21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  ******************************************************************************/
29 
30 #ifndef HIPCUB_CUB_DEVICE_DEVICE_SEGMENTED_SORT_HPP_
31 #define HIPCUB_CUB_DEVICE_DEVICE_SEGMENTED_SORT_HPP_
32 
33 #include "../../../config.hpp"
34 
35 #include <cub/device/device_segmented_sort.cuh>
36 
37 BEGIN_HIPCUB_NAMESPACE
38 
40 {
41  template <typename KeyT,
42  typename BeginOffsetIteratorT,
43  typename EndOffsetIteratorT>
44  HIPCUB_RUNTIME_FUNCTION static
45  hipError_t SortKeys(void * d_temp_storage,
46  size_t& temp_storage_bytes,
47  const KeyT * d_keys_in,
48  KeyT * d_keys_out,
49  int num_items,
50  int num_segments,
51  BeginOffsetIteratorT d_begin_offsets,
52  EndOffsetIteratorT d_end_offsets,
53  hipStream_t stream = 0,
54  bool debug_synchronous = false)
55  {
56  (void)debug_synchronous;
57  return hipCUDAErrorTohipError(::cub::DeviceSegmentedSort::SortKeys(d_temp_storage,
58  temp_storage_bytes,
59  d_keys_in,
60  d_keys_out,
61  num_items,
62  num_segments,
63  d_begin_offsets,
64  d_end_offsets,
65  stream));
66  }
67 
68  template <typename KeyT,
69  typename BeginOffsetIteratorT,
70  typename EndOffsetIteratorT>
71  HIPCUB_RUNTIME_FUNCTION static
72  hipError_t SortKeysDescending(void * d_temp_storage,
73  size_t& temp_storage_bytes,
74  const KeyT * d_keys_in,
75  KeyT * d_keys_out,
76  int num_items,
77  int num_segments,
78  BeginOffsetIteratorT d_begin_offsets,
79  EndOffsetIteratorT d_end_offsets,
80  hipStream_t stream = 0,
81  bool debug_synchronous = false)
82  {
83  (void)debug_synchronous;
84  return hipCUDAErrorTohipError(
85  ::cub::DeviceSegmentedSort::SortKeysDescending(d_temp_storage,
86  temp_storage_bytes,
87  d_keys_in,
88  d_keys_out,
89  num_items,
90  num_segments,
91  d_begin_offsets,
92  d_end_offsets,
93  stream));
94  }
95 
96  template <typename KeyT,
97  typename BeginOffsetIteratorT,
98  typename EndOffsetIteratorT>
99  HIPCUB_RUNTIME_FUNCTION static
100  hipError_t SortKeys(void * d_temp_storage,
101  size_t& temp_storage_bytes,
102  DoubleBuffer<KeyT> &d_keys,
103  int num_items,
104  int num_segments,
105  BeginOffsetIteratorT d_begin_offsets,
106  EndOffsetIteratorT d_end_offsets,
107  hipStream_t stream = 0,
108  bool debug_synchronous = false)
109  {
110  (void)debug_synchronous;
111  return hipCUDAErrorTohipError(::cub::DeviceSegmentedSort::SortKeys(d_temp_storage,
112  temp_storage_bytes,
113  d_keys,
114  num_items,
115  num_segments,
116  d_begin_offsets,
117  d_end_offsets,
118  stream));
119  }
120 
121  template <typename KeyT,
122  typename BeginOffsetIteratorT,
123  typename EndOffsetIteratorT>
124  HIPCUB_RUNTIME_FUNCTION static
125  hipError_t SortKeysDescending(void * d_temp_storage,
126  size_t& temp_storage_bytes,
127  DoubleBuffer<KeyT> &d_keys,
128  int num_items,
129  int num_segments,
130  BeginOffsetIteratorT d_begin_offsets,
131  EndOffsetIteratorT d_end_offsets,
132  hipStream_t stream = 0,
133  bool debug_synchronous = false)
134  {
135  (void)debug_synchronous;
136  return hipCUDAErrorTohipError(
137  ::cub::DeviceSegmentedSort::SortKeysDescending(d_temp_storage,
138  temp_storage_bytes,
139  d_keys,
140  num_items,
141  num_segments,
142  d_begin_offsets,
143  d_end_offsets,
144  stream));
145  }
146 
147  template <typename KeyT,
148  typename BeginOffsetIteratorT,
149  typename EndOffsetIteratorT>
150  HIPCUB_RUNTIME_FUNCTION static
151  hipError_t StableSortKeys(void * d_temp_storage,
152  size_t& temp_storage_bytes,
153  const KeyT * d_keys_in,
154  KeyT * d_keys_out,
155  int num_items,
156  int num_segments,
157  BeginOffsetIteratorT d_begin_offsets,
158  EndOffsetIteratorT d_end_offsets,
159  hipStream_t stream = 0,
160  bool debug_synchronous = false)
161  {
162  (void)debug_synchronous;
163  return hipCUDAErrorTohipError(::cub::DeviceSegmentedSort::StableSortKeys(d_temp_storage,
164  temp_storage_bytes,
165  d_keys_in,
166  d_keys_out,
167  num_items,
168  num_segments,
169  d_begin_offsets,
170  d_end_offsets,
171  stream));
172  }
173 
174  template <typename KeyT,
175  typename BeginOffsetIteratorT,
176  typename EndOffsetIteratorT>
177  HIPCUB_RUNTIME_FUNCTION static
178  hipError_t StableSortKeysDescending(void * d_temp_storage,
179  size_t& temp_storage_bytes,
180  const KeyT * d_keys_in,
181  KeyT * d_keys_out,
182  int num_items,
183  int num_segments,
184  BeginOffsetIteratorT d_begin_offsets,
185  EndOffsetIteratorT d_end_offsets,
186  hipStream_t stream = 0,
187  bool debug_synchronous = false)
188  {
189  (void)debug_synchronous;
190  return hipCUDAErrorTohipError(
191  ::cub::DeviceSegmentedSort::StableSortKeysDescending(d_temp_storage,
192  temp_storage_bytes,
193  d_keys_in,
194  d_keys_out,
195  num_items,
196  num_segments,
197  d_begin_offsets,
198  d_end_offsets,
199  stream));
200  }
201 
202  template <typename KeyT,
203  typename BeginOffsetIteratorT,
204  typename EndOffsetIteratorT>
205  HIPCUB_RUNTIME_FUNCTION static
206  hipError_t StableSortKeys(void * d_temp_storage,
207  size_t& temp_storage_bytes,
208  DoubleBuffer<KeyT> &d_keys,
209  int num_items,
210  int num_segments,
211  BeginOffsetIteratorT d_begin_offsets,
212  EndOffsetIteratorT d_end_offsets,
213  hipStream_t stream = 0,
214  bool debug_synchronous = false)
215  {
216  (void)debug_synchronous;
217  return hipCUDAErrorTohipError(::cub::DeviceSegmentedSort::StableSortKeys(d_temp_storage,
218  temp_storage_bytes,
219  d_keys,
220  num_items,
221  num_segments,
222  d_begin_offsets,
223  d_end_offsets,
224  stream));
225  }
226 
227  template <typename KeyT,
228  typename BeginOffsetIteratorT,
229  typename EndOffsetIteratorT>
230  HIPCUB_RUNTIME_FUNCTION static
231  hipError_t StableSortKeysDescending(void * d_temp_storage,
232  size_t& temp_storage_bytes,
233  DoubleBuffer<KeyT> &d_keys,
234  int num_items,
235  int num_segments,
236  BeginOffsetIteratorT d_begin_offsets,
237  EndOffsetIteratorT d_end_offsets,
238  hipStream_t stream = 0,
239  bool debug_synchronous = false)
240  {
241  (void)debug_synchronous;
242  return hipCUDAErrorTohipError(
243  ::cub::DeviceSegmentedSort::StableSortKeysDescending(d_temp_storage,
244  temp_storage_bytes,
245  d_keys,
246  num_items,
247  num_segments,
248  d_begin_offsets,
249  d_end_offsets,
250  stream));
251  }
252 
253  template <typename KeyT,
254  typename ValueT,
255  typename BeginOffsetIteratorT,
256  typename EndOffsetIteratorT>
257  HIPCUB_RUNTIME_FUNCTION static
258  hipError_t SortPairs(void * d_temp_storage,
259  size_t& temp_storage_bytes,
260  const KeyT * d_keys_in,
261  KeyT * d_keys_out,
262  const ValueT * d_values_in,
263  ValueT * d_values_out,
264  int num_items,
265  int num_segments,
266  BeginOffsetIteratorT d_begin_offsets,
267  EndOffsetIteratorT d_end_offsets,
268  hipStream_t stream = 0,
269  bool debug_synchronous = false)
270  {
271  (void)debug_synchronous;
272  return hipCUDAErrorTohipError(::cub::DeviceSegmentedSort::SortPairs(d_temp_storage,
273  temp_storage_bytes,
274  d_keys_in,
275  d_keys_out,
276  d_values_in,
277  d_values_out,
278  num_items,
279  num_segments,
280  d_begin_offsets,
281  d_end_offsets,
282  stream));
283  }
284 
285  template <typename KeyT,
286  typename ValueT,
287  typename BeginOffsetIteratorT,
288  typename EndOffsetIteratorT>
289  HIPCUB_RUNTIME_FUNCTION static
290  hipError_t SortPairsDescending(void * d_temp_storage,
291  size_t& temp_storage_bytes,
292  const KeyT * d_keys_in,
293  KeyT * d_keys_out,
294  const ValueT * d_values_in,
295  ValueT * d_values_out,
296  int num_items,
297  int num_segments,
298  BeginOffsetIteratorT d_begin_offsets,
299  EndOffsetIteratorT d_end_offsets,
300  hipStream_t stream = 0,
301  bool debug_synchronous = false)
302  {
303  (void)debug_synchronous;
304  return hipCUDAErrorTohipError(
305  ::cub::DeviceSegmentedSort::SortPairsDescending(d_temp_storage,
306  temp_storage_bytes,
307  d_keys_in,
308  d_keys_out,
309  d_values_in,
310  d_values_out,
311  num_items,
312  num_segments,
313  d_begin_offsets,
314  d_end_offsets,
315  stream));
316  }
317 
318  template <typename KeyT,
319  typename ValueT,
320  typename BeginOffsetIteratorT,
321  typename EndOffsetIteratorT>
322  HIPCUB_RUNTIME_FUNCTION static
323  hipError_t SortPairs(void * d_temp_storage,
324  size_t& temp_storage_bytes,
325  DoubleBuffer<KeyT> &d_keys,
326  DoubleBuffer<ValueT> &d_values,
327  int num_items,
328  int num_segments,
329  BeginOffsetIteratorT d_begin_offsets,
330  EndOffsetIteratorT d_end_offsets,
331  hipStream_t stream = 0,
332  bool debug_synchronous = false)
333  {
334  (void)debug_synchronous;
335  return hipCUDAErrorTohipError(::cub::DeviceSegmentedSort::SortPairs(d_temp_storage,
336  temp_storage_bytes,
337  d_keys,
338  d_values,
339  num_items,
340  num_segments,
341  d_begin_offsets,
342  d_end_offsets,
343  stream));
344  }
345 
346  template <typename KeyT,
347  typename ValueT,
348  typename BeginOffsetIteratorT,
349  typename EndOffsetIteratorT>
350  HIPCUB_RUNTIME_FUNCTION static
351  hipError_t SortPairsDescending(void * d_temp_storage,
352  size_t& temp_storage_bytes,
353  DoubleBuffer<KeyT> &d_keys,
354  DoubleBuffer<ValueT> &d_values,
355  int num_items,
356  int num_segments,
357  BeginOffsetIteratorT d_begin_offsets,
358  EndOffsetIteratorT d_end_offsets,
359  hipStream_t stream = 0,
360  bool debug_synchronous = false)
361  {
362  (void)debug_synchronous;
363  return hipCUDAErrorTohipError(
364  ::cub::DeviceSegmentedSort::SortPairsDescending(d_temp_storage,
365  temp_storage_bytes,
366  d_keys,
367  d_values,
368  num_items,
369  num_segments,
370  d_begin_offsets,
371  d_end_offsets,
372  stream));
373  }
374 
375  template <typename KeyT,
376  typename ValueT,
377  typename BeginOffsetIteratorT,
378  typename EndOffsetIteratorT>
379  HIPCUB_RUNTIME_FUNCTION static
380  hipError_t StableSortPairs(void * d_temp_storage,
381  size_t& temp_storage_bytes,
382  const KeyT * d_keys_in,
383  KeyT * d_keys_out,
384  const ValueT * d_values_in,
385  ValueT * d_values_out,
386  int num_items,
387  int num_segments,
388  BeginOffsetIteratorT d_begin_offsets,
389  EndOffsetIteratorT d_end_offsets,
390  hipStream_t stream = 0,
391  bool debug_synchronous = false)
392  {
393  (void)debug_synchronous;
394  return hipCUDAErrorTohipError(
395  ::cub::DeviceSegmentedSort::StableSortPairs(d_temp_storage,
396  temp_storage_bytes,
397  d_keys_in,
398  d_keys_out,
399  d_values_in,
400  d_values_out,
401  num_items,
402  num_segments,
403  d_begin_offsets,
404  d_end_offsets,
405  stream));
406  }
407 
408  template <typename KeyT,
409  typename ValueT,
410  typename BeginOffsetIteratorT,
411  typename EndOffsetIteratorT>
412  HIPCUB_RUNTIME_FUNCTION static
413  hipError_t StableSortPairsDescending(void * d_temp_storage,
414  size_t& temp_storage_bytes,
415  const KeyT * d_keys_in,
416  KeyT * d_keys_out,
417  const ValueT * d_values_in,
418  ValueT * d_values_out,
419  int num_items,
420  int num_segments,
421  BeginOffsetIteratorT d_begin_offsets,
422  EndOffsetIteratorT d_end_offsets,
423  hipStream_t stream = 0,
424  bool debug_synchronous = false)
425  {
426  (void)debug_synchronous;
427  return hipCUDAErrorTohipError(
428  ::cub::DeviceSegmentedSort::StableSortPairsDescending(d_temp_storage,
429  temp_storage_bytes,
430  d_keys_in,
431  d_keys_out,
432  d_values_in,
433  d_values_out,
434  num_items,
435  num_segments,
436  d_begin_offsets,
437  d_end_offsets,
438  stream));
439  }
440 
441  template <typename KeyT,
442  typename ValueT,
443  typename BeginOffsetIteratorT,
444  typename EndOffsetIteratorT>
445  HIPCUB_RUNTIME_FUNCTION static
446  hipError_t StableSortPairs(void * d_temp_storage,
447  size_t& temp_storage_bytes,
448  DoubleBuffer<KeyT> &d_keys,
449  DoubleBuffer<ValueT> &d_values,
450  int num_items,
451  int num_segments,
452  BeginOffsetIteratorT d_begin_offsets,
453  EndOffsetIteratorT d_end_offsets,
454  hipStream_t stream = 0,
455  bool debug_synchronous = false)
456  {
457  (void)debug_synchronous;
458  return hipCUDAErrorTohipError(
459  ::cub::DeviceSegmentedSort::StableSortPairs(d_temp_storage,
460  temp_storage_bytes,
461  d_keys,
462  d_values,
463  num_items,
464  num_segments,
465  d_begin_offsets,
466  d_end_offsets,
467  stream));
468  }
469 
470  template <typename KeyT,
471  typename ValueT,
472  typename BeginOffsetIteratorT,
473  typename EndOffsetIteratorT>
474  HIPCUB_RUNTIME_FUNCTION static
475  hipError_t StableSortPairsDescending(void * d_temp_storage,
476  size_t& temp_storage_bytes,
477  DoubleBuffer<KeyT> &d_keys,
478  DoubleBuffer<ValueT> &d_values,
479  int num_items,
480  int num_segments,
481  BeginOffsetIteratorT d_begin_offsets,
482  EndOffsetIteratorT d_end_offsets,
483  hipStream_t stream = 0,
484  bool debug_synchronous = false)
485  {
486  (void)debug_synchronous;
487  return hipCUDAErrorTohipError(
488  ::cub::DeviceSegmentedSort::StableSortPairsDescending(d_temp_storage,
489  temp_storage_bytes,
490  d_keys,
491  d_values,
492  num_items,
493  num_segments,
494  d_begin_offsets,
495  d_end_offsets,
496  stream));
497  }
498 };
499 
500 END_HIPCUB_NAMESPACE
501 
502 #endif // HIPCUB_CUB_DEVICE_DEVICE_SEGMENTED_SORT_HPP_
Definition: device_segmented_sort.hpp:40
Definition: util_type.hpp:108