/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-hipcub/checkouts/docs-5.7.0/hipcub/include/hipcub/backend/cub/device/device_radix_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_radix_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_radix_sort.hpp Source File
device_radix_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_RADIX_SORT_HPP_
31 #define HIPCUB_CUB_DEVICE_DEVICE_RADIX_SORT_HPP_
32 
33 #include "../../../config.hpp"
34 
35 #include <cub/device/device_radix_sort.cuh>
36 
37 BEGIN_HIPCUB_NAMESPACE
38 
40 {
41  template<typename KeyT, typename ValueT, typename NumItemsT>
42  HIPCUB_RUNTIME_FUNCTION static
43  hipError_t SortPairs(void * d_temp_storage,
44  size_t& temp_storage_bytes,
45  const KeyT * d_keys_in,
46  KeyT * d_keys_out,
47  const ValueT * d_values_in,
48  ValueT * d_values_out,
49  NumItemsT num_items,
50  int begin_bit = 0,
51  int end_bit = sizeof(KeyT) * 8,
52  hipStream_t stream = 0,
53  bool debug_synchronous = false)
54  {
55  (void)debug_synchronous;
56  return hipCUDAErrorTohipError(::cub::DeviceRadixSort::SortPairs(d_temp_storage,
57  temp_storage_bytes,
58  d_keys_in,
59  d_keys_out,
60  d_values_in,
61  d_values_out,
62  num_items,
63  begin_bit,
64  end_bit,
65  stream));
66  }
67 
68  template<typename KeyT, typename ValueT, typename NumItemsT>
69  HIPCUB_RUNTIME_FUNCTION static
70  hipError_t SortPairs(void * d_temp_storage,
71  size_t& temp_storage_bytes,
72  DoubleBuffer<KeyT>& d_keys,
73  DoubleBuffer<ValueT>& d_values,
74  NumItemsT num_items,
75  int begin_bit = 0,
76  int end_bit = sizeof(KeyT) * 8,
77  hipStream_t stream = 0,
78  bool debug_synchronous = false)
79  {
80  (void)debug_synchronous;
81  return hipCUDAErrorTohipError(::cub::DeviceRadixSort::SortPairs(d_temp_storage,
82  temp_storage_bytes,
83  d_keys,
84  d_values,
85  num_items,
86  begin_bit,
87  end_bit,
88  stream));
89  }
90 
91  template<typename KeyT, typename ValueT, typename NumItemsT>
92  HIPCUB_RUNTIME_FUNCTION static
93  hipError_t SortPairsDescending(void * d_temp_storage,
94  size_t& temp_storage_bytes,
95  const KeyT * d_keys_in,
96  KeyT * d_keys_out,
97  const ValueT * d_values_in,
98  ValueT * d_values_out,
99  NumItemsT num_items,
100  int begin_bit = 0,
101  int end_bit = sizeof(KeyT) * 8,
102  hipStream_t stream = 0,
103  bool debug_synchronous = false)
104  {
105  (void)debug_synchronous;
106  return hipCUDAErrorTohipError(
107  ::cub::DeviceRadixSort::SortPairsDescending(d_temp_storage,
108  temp_storage_bytes,
109  d_keys_in,
110  d_keys_out,
111  d_values_in,
112  d_values_out,
113  num_items,
114  begin_bit,
115  end_bit,
116  stream));
117  }
118 
119  template<typename KeyT, typename ValueT, typename NumItemsT>
120  HIPCUB_RUNTIME_FUNCTION static
121  hipError_t SortPairsDescending(void * d_temp_storage,
122  size_t& temp_storage_bytes,
123  DoubleBuffer<KeyT>& d_keys,
124  DoubleBuffer<ValueT>& d_values,
125  NumItemsT num_items,
126  int begin_bit = 0,
127  int end_bit = sizeof(KeyT) * 8,
128  hipStream_t stream = 0,
129  bool debug_synchronous = false)
130  {
131  (void)debug_synchronous;
132  return hipCUDAErrorTohipError(
133  ::cub::DeviceRadixSort::SortPairsDescending(d_temp_storage,
134  temp_storage_bytes,
135  d_keys,
136  d_values,
137  num_items,
138  begin_bit,
139  end_bit,
140  stream));
141  }
142 
143  template<typename KeyT, typename NumItemsT>
144  HIPCUB_RUNTIME_FUNCTION static
145  hipError_t SortKeys(void * d_temp_storage,
146  size_t& temp_storage_bytes,
147  const KeyT * d_keys_in,
148  KeyT * d_keys_out,
149  NumItemsT num_items,
150  int begin_bit = 0,
151  int end_bit = sizeof(KeyT) * 8,
152  hipStream_t stream = 0,
153  bool debug_synchronous = false)
154  {
155  (void)debug_synchronous;
156  return hipCUDAErrorTohipError(::cub::DeviceRadixSort::SortKeys(d_temp_storage,
157  temp_storage_bytes,
158  d_keys_in,
159  d_keys_out,
160  num_items,
161  begin_bit,
162  end_bit,
163  stream));
164  }
165 
166  template<typename KeyT, typename NumItemsT>
167  HIPCUB_RUNTIME_FUNCTION static
168  hipError_t SortKeys(void * d_temp_storage,
169  size_t& temp_storage_bytes,
170  DoubleBuffer<KeyT>& d_keys,
171  NumItemsT num_items,
172  int begin_bit = 0,
173  int end_bit = sizeof(KeyT) * 8,
174  hipStream_t stream = 0,
175  bool debug_synchronous = false)
176  {
177  (void)debug_synchronous;
178  return hipCUDAErrorTohipError(::cub::DeviceRadixSort::SortKeys(d_temp_storage,
179  temp_storage_bytes,
180  d_keys,
181  num_items,
182  begin_bit,
183  end_bit,
184  stream));
185  }
186 
187  template<typename KeyT, typename NumItemsT>
188  HIPCUB_RUNTIME_FUNCTION static
189  hipError_t SortKeysDescending(void * d_temp_storage,
190  size_t& temp_storage_bytes,
191  const KeyT * d_keys_in,
192  KeyT * d_keys_out,
193  NumItemsT num_items,
194  int begin_bit = 0,
195  int end_bit = sizeof(KeyT) * 8,
196  hipStream_t stream = 0,
197  bool debug_synchronous = false)
198  {
199  (void)debug_synchronous;
200  return hipCUDAErrorTohipError(::cub::DeviceRadixSort::SortKeysDescending(d_temp_storage,
201  temp_storage_bytes,
202  d_keys_in,
203  d_keys_out,
204  num_items,
205  begin_bit,
206  end_bit,
207  stream));
208  }
209 
210  template<typename KeyT, typename NumItemsT>
211  HIPCUB_RUNTIME_FUNCTION static
212  hipError_t SortKeysDescending(void * d_temp_storage,
213  size_t& temp_storage_bytes,
214  DoubleBuffer<KeyT>& d_keys,
215  NumItemsT num_items,
216  int begin_bit = 0,
217  int end_bit = sizeof(KeyT) * 8,
218  hipStream_t stream = 0,
219  bool debug_synchronous = false)
220  {
221  (void)debug_synchronous;
222  return hipCUDAErrorTohipError(::cub::DeviceRadixSort::SortKeysDescending(d_temp_storage,
223  temp_storage_bytes,
224  d_keys,
225  num_items,
226  begin_bit,
227  end_bit,
228  stream));
229  }
230 };
231 
232 END_HIPCUB_NAMESPACE
233 
234 #endif // HIPCUB_CUB_DEVICE_DEVICE_RADIX_SORT_HPP_
Definition: device_radix_sort.hpp:40
Definition: util_type.hpp:108