/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-hipcub/checkouts/docs-5.5.1/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.5.1/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.5.1/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-2020, 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  return hipCUDAErrorTohipError(
57  ::cub::DeviceSegmentedSort::SortKeys(
58  d_temp_storage, temp_storage_bytes,
59  d_keys_in, d_keys_out,
60  num_items, num_segments,
61  d_begin_offsets, d_end_offsets,
62  stream, debug_synchronous
63  )
64  );
65  }
66 
67  template <typename KeyT,
68  typename BeginOffsetIteratorT,
69  typename EndOffsetIteratorT>
70  HIPCUB_RUNTIME_FUNCTION static
71  hipError_t SortKeysDescending(void * d_temp_storage,
72  size_t& temp_storage_bytes,
73  const KeyT * d_keys_in,
74  KeyT * d_keys_out,
75  int num_items,
76  int num_segments,
77  BeginOffsetIteratorT d_begin_offsets,
78  EndOffsetIteratorT d_end_offsets,
79  hipStream_t stream = 0,
80  bool debug_synchronous = false)
81  {
82  return hipCUDAErrorTohipError(
83  ::cub::DeviceSegmentedSort::SortKeysDescending(
84  d_temp_storage, temp_storage_bytes,
85  d_keys_in, d_keys_out,
86  num_items, num_segments,
87  d_begin_offsets, d_end_offsets,
88  stream, debug_synchronous
89  )
90  );
91  }
92 
93  template <typename KeyT,
94  typename BeginOffsetIteratorT,
95  typename EndOffsetIteratorT>
96  HIPCUB_RUNTIME_FUNCTION static
97  hipError_t SortKeys(void * d_temp_storage,
98  size_t& temp_storage_bytes,
99  DoubleBuffer<KeyT> &d_keys,
100  int num_items,
101  int num_segments,
102  BeginOffsetIteratorT d_begin_offsets,
103  EndOffsetIteratorT d_end_offsets,
104  hipStream_t stream = 0,
105  bool debug_synchronous = false)
106  {
107  return hipCUDAErrorTohipError(
108  ::cub::DeviceSegmentedSort::SortKeys(
109  d_temp_storage, temp_storage_bytes,
110  d_keys,
111  num_items, num_segments,
112  d_begin_offsets, d_end_offsets,
113  stream, debug_synchronous
114  )
115  );
116  }
117 
118  template <typename KeyT,
119  typename BeginOffsetIteratorT,
120  typename EndOffsetIteratorT>
121  HIPCUB_RUNTIME_FUNCTION static
122  hipError_t SortKeysDescending(void * d_temp_storage,
123  size_t& temp_storage_bytes,
124  DoubleBuffer<KeyT> &d_keys,
125  int num_items,
126  int num_segments,
127  BeginOffsetIteratorT d_begin_offsets,
128  EndOffsetIteratorT d_end_offsets,
129  hipStream_t stream = 0,
130  bool debug_synchronous = false)
131  {
132  return hipCUDAErrorTohipError(
133  ::cub::DeviceSegmentedSort::SortKeysDescending(
134  d_temp_storage, temp_storage_bytes,
135  d_keys,
136  num_items, num_segments,
137  d_begin_offsets, d_end_offsets,
138  stream, debug_synchronous
139  )
140  );
141  }
142 
143  template <typename KeyT,
144  typename BeginOffsetIteratorT,
145  typename EndOffsetIteratorT>
146  HIPCUB_RUNTIME_FUNCTION static
147  hipError_t StableSortKeys(void * d_temp_storage,
148  size_t& temp_storage_bytes,
149  const KeyT * d_keys_in,
150  KeyT * d_keys_out,
151  int num_items,
152  int num_segments,
153  BeginOffsetIteratorT d_begin_offsets,
154  EndOffsetIteratorT d_end_offsets,
155  hipStream_t stream = 0,
156  bool debug_synchronous = false)
157  {
158  return hipCUDAErrorTohipError(
159  ::cub::DeviceSegmentedSort::StableSortKeys(
160  d_temp_storage, temp_storage_bytes,
161  d_keys_in, d_keys_out,
162  num_items, num_segments,
163  d_begin_offsets, d_end_offsets,
164  stream, debug_synchronous
165  )
166  );
167  }
168 
169  template <typename KeyT,
170  typename BeginOffsetIteratorT,
171  typename EndOffsetIteratorT>
172  HIPCUB_RUNTIME_FUNCTION static
173  hipError_t StableSortKeysDescending(void * d_temp_storage,
174  size_t& temp_storage_bytes,
175  const KeyT * d_keys_in,
176  KeyT * d_keys_out,
177  int num_items,
178  int num_segments,
179  BeginOffsetIteratorT d_begin_offsets,
180  EndOffsetIteratorT d_end_offsets,
181  hipStream_t stream = 0,
182  bool debug_synchronous = false)
183  {
184  return hipCUDAErrorTohipError(
185  ::cub::DeviceSegmentedSort::StableSortKeysDescending(
186  d_temp_storage, temp_storage_bytes,
187  d_keys_in, d_keys_out,
188  num_items, num_segments,
189  d_begin_offsets, d_end_offsets,
190  stream, debug_synchronous
191  )
192  );
193  }
194 
195  template <typename KeyT,
196  typename BeginOffsetIteratorT,
197  typename EndOffsetIteratorT>
198  HIPCUB_RUNTIME_FUNCTION static
199  hipError_t StableSortKeys(void * d_temp_storage,
200  size_t& temp_storage_bytes,
201  DoubleBuffer<KeyT> &d_keys,
202  int num_items,
203  int num_segments,
204  BeginOffsetIteratorT d_begin_offsets,
205  EndOffsetIteratorT d_end_offsets,
206  hipStream_t stream = 0,
207  bool debug_synchronous = false)
208  {
209  return hipCUDAErrorTohipError(
210  ::cub::DeviceSegmentedSort::StableSortKeys(
211  d_temp_storage, temp_storage_bytes,
212  d_keys,
213  num_items, num_segments,
214  d_begin_offsets, d_end_offsets,
215  stream, debug_synchronous
216  )
217  );
218  }
219 
220  template <typename KeyT,
221  typename BeginOffsetIteratorT,
222  typename EndOffsetIteratorT>
223  HIPCUB_RUNTIME_FUNCTION static
224  hipError_t StableSortKeysDescending(void * d_temp_storage,
225  size_t& temp_storage_bytes,
226  DoubleBuffer<KeyT> &d_keys,
227  int num_items,
228  int num_segments,
229  BeginOffsetIteratorT d_begin_offsets,
230  EndOffsetIteratorT d_end_offsets,
231  hipStream_t stream = 0,
232  bool debug_synchronous = false)
233  {
234  return hipCUDAErrorTohipError(
235  ::cub::DeviceSegmentedSort::StableSortKeysDescending(
236  d_temp_storage, temp_storage_bytes,
237  d_keys,
238  num_items, num_segments,
239  d_begin_offsets, d_end_offsets,
240  stream, debug_synchronous
241  )
242  );
243  }
244 
245  template <typename KeyT,
246  typename ValueT,
247  typename BeginOffsetIteratorT,
248  typename EndOffsetIteratorT>
249  HIPCUB_RUNTIME_FUNCTION static
250  hipError_t SortPairs(void * d_temp_storage,
251  size_t& temp_storage_bytes,
252  const KeyT * d_keys_in,
253  KeyT * d_keys_out,
254  const ValueT * d_values_in,
255  ValueT * d_values_out,
256  int num_items,
257  int num_segments,
258  BeginOffsetIteratorT d_begin_offsets,
259  EndOffsetIteratorT d_end_offsets,
260  hipStream_t stream = 0,
261  bool debug_synchronous = false)
262  {
263  return hipCUDAErrorTohipError(
264  ::cub::DeviceSegmentedSort::SortPairs(
265  d_temp_storage, temp_storage_bytes,
266  d_keys_in, d_keys_out,
267  d_values_in, d_values_out,
268  num_items, num_segments,
269  d_begin_offsets, d_end_offsets,
270  stream, debug_synchronous
271  )
272  );
273  }
274 
275  template <typename KeyT,
276  typename ValueT,
277  typename BeginOffsetIteratorT,
278  typename EndOffsetIteratorT>
279  HIPCUB_RUNTIME_FUNCTION static
280  hipError_t SortPairsDescending(void * d_temp_storage,
281  size_t& temp_storage_bytes,
282  const KeyT * d_keys_in,
283  KeyT * d_keys_out,
284  const ValueT * d_values_in,
285  ValueT * d_values_out,
286  int num_items,
287  int num_segments,
288  BeginOffsetIteratorT d_begin_offsets,
289  EndOffsetIteratorT d_end_offsets,
290  hipStream_t stream = 0,
291  bool debug_synchronous = false)
292  {
293  return hipCUDAErrorTohipError(
294  ::cub::DeviceSegmentedSort::SortPairsDescending(
295  d_temp_storage, temp_storage_bytes,
296  d_keys_in, d_keys_out,
297  d_values_in, d_values_out,
298  num_items, num_segments,
299  d_begin_offsets, d_end_offsets,
300  stream, debug_synchronous
301  )
302  );
303  }
304 
305  template <typename KeyT,
306  typename ValueT,
307  typename BeginOffsetIteratorT,
308  typename EndOffsetIteratorT>
309  HIPCUB_RUNTIME_FUNCTION static
310  hipError_t SortPairs(void * d_temp_storage,
311  size_t& temp_storage_bytes,
312  DoubleBuffer<KeyT> &d_keys,
313  DoubleBuffer<ValueT> &d_values,
314  int num_items,
315  int num_segments,
316  BeginOffsetIteratorT d_begin_offsets,
317  EndOffsetIteratorT d_end_offsets,
318  hipStream_t stream = 0,
319  bool debug_synchronous = false)
320  {
321  return hipCUDAErrorTohipError(
322  ::cub::DeviceSegmentedSort::SortPairs(
323  d_temp_storage, temp_storage_bytes,
324  d_keys, d_values,
325  num_items, num_segments,
326  d_begin_offsets, d_end_offsets,
327  stream, debug_synchronous
328  )
329  );
330  }
331 
332  template <typename KeyT,
333  typename ValueT,
334  typename BeginOffsetIteratorT,
335  typename EndOffsetIteratorT>
336  HIPCUB_RUNTIME_FUNCTION static
337  hipError_t SortPairsDescending(void * d_temp_storage,
338  size_t& temp_storage_bytes,
339  DoubleBuffer<KeyT> &d_keys,
340  DoubleBuffer<ValueT> &d_values,
341  int num_items,
342  int num_segments,
343  BeginOffsetIteratorT d_begin_offsets,
344  EndOffsetIteratorT d_end_offsets,
345  hipStream_t stream = 0,
346  bool debug_synchronous = false)
347  {
348  return hipCUDAErrorTohipError(
349  ::cub::DeviceSegmentedSort::SortPairsDescending(
350  d_temp_storage, temp_storage_bytes,
351  d_keys, d_values,
352  num_items, num_segments,
353  d_begin_offsets, d_end_offsets,
354  stream, debug_synchronous
355  )
356  );
357  }
358 
359  template <typename KeyT,
360  typename ValueT,
361  typename BeginOffsetIteratorT,
362  typename EndOffsetIteratorT>
363  HIPCUB_RUNTIME_FUNCTION static
364  hipError_t StableSortPairs(void * d_temp_storage,
365  size_t& temp_storage_bytes,
366  const KeyT * d_keys_in,
367  KeyT * d_keys_out,
368  const ValueT * d_values_in,
369  ValueT * d_values_out,
370  int num_items,
371  int num_segments,
372  BeginOffsetIteratorT d_begin_offsets,
373  EndOffsetIteratorT d_end_offsets,
374  hipStream_t stream = 0,
375  bool debug_synchronous = false)
376  {
377  return hipCUDAErrorTohipError(
378  ::cub::DeviceSegmentedSort::StableSortPairs(
379  d_temp_storage, temp_storage_bytes,
380  d_keys_in, d_keys_out,
381  d_values_in, d_values_out,
382  num_items, num_segments,
383  d_begin_offsets, d_end_offsets,
384  stream, debug_synchronous
385  )
386  );
387  }
388 
389  template <typename KeyT,
390  typename ValueT,
391  typename BeginOffsetIteratorT,
392  typename EndOffsetIteratorT>
393  HIPCUB_RUNTIME_FUNCTION static
394  hipError_t StableSortPairsDescending(void * d_temp_storage,
395  size_t& temp_storage_bytes,
396  const KeyT * d_keys_in,
397  KeyT * d_keys_out,
398  const ValueT * d_values_in,
399  ValueT * d_values_out,
400  int num_items,
401  int num_segments,
402  BeginOffsetIteratorT d_begin_offsets,
403  EndOffsetIteratorT d_end_offsets,
404  hipStream_t stream = 0,
405  bool debug_synchronous = false)
406  {
407  return hipCUDAErrorTohipError(
408  ::cub::DeviceSegmentedSort::StableSortPairsDescending(
409  d_temp_storage, temp_storage_bytes,
410  d_keys_in, d_keys_out,
411  d_values_in, d_values_out,
412  num_items, num_segments,
413  d_begin_offsets, d_end_offsets,
414  stream, debug_synchronous
415  )
416  );
417  }
418 
419  template <typename KeyT,
420  typename ValueT,
421  typename BeginOffsetIteratorT,
422  typename EndOffsetIteratorT>
423  HIPCUB_RUNTIME_FUNCTION static
424  hipError_t StableSortPairs(void * d_temp_storage,
425  size_t& temp_storage_bytes,
426  DoubleBuffer<KeyT> &d_keys,
427  DoubleBuffer<ValueT> &d_values,
428  int num_items,
429  int num_segments,
430  BeginOffsetIteratorT d_begin_offsets,
431  EndOffsetIteratorT d_end_offsets,
432  hipStream_t stream = 0,
433  bool debug_synchronous = false)
434  {
435  return hipCUDAErrorTohipError(
436  ::cub::DeviceSegmentedSort::StableSortPairs(
437  d_temp_storage, temp_storage_bytes,
438  d_keys, d_values,
439  num_items, num_segments,
440  d_begin_offsets, d_end_offsets,
441  stream, debug_synchronous
442  )
443  );
444  }
445 
446  template <typename KeyT,
447  typename ValueT,
448  typename BeginOffsetIteratorT,
449  typename EndOffsetIteratorT>
450  HIPCUB_RUNTIME_FUNCTION static
451  hipError_t StableSortPairsDescending(void * d_temp_storage,
452  size_t& temp_storage_bytes,
453  DoubleBuffer<KeyT> &d_keys,
454  DoubleBuffer<ValueT> &d_values,
455  int num_items,
456  int num_segments,
457  BeginOffsetIteratorT d_begin_offsets,
458  EndOffsetIteratorT d_end_offsets,
459  hipStream_t stream = 0,
460  bool debug_synchronous = false)
461  {
462  return hipCUDAErrorTohipError(
463  ::cub::DeviceSegmentedSort::StableSortPairsDescending(
464  d_temp_storage, temp_storage_bytes,
465  d_keys, d_values,
466  num_items, num_segments,
467  d_begin_offsets, d_end_offsets,
468  stream, debug_synchronous
469  )
470  );
471  }
472 };
473 
474 END_HIPCUB_NAMESPACE
475 
476 #endif // HIPCUB_CUB_DEVICE_DEVICE_SEGMENTED_SORT_HPP_
Definition: device_segmented_sort.hpp:40
Definition: util_type.hpp:108