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