/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-hipcub/checkouts/docs-5.5.1/hipcub/include/hipcub/backend/cub/device/device_merge_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_merge_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_merge_sort.hpp Source File
device_merge_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-2021, 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_MERGE_SORT_HPP_
31 #define HIPCUB_CUB_DEVICE_DEVICE_MERGE_SORT_HPP_
32 
33 #include "../../../config.hpp"
34 
35 #include <cub/device/device_merge_sort.cuh>
36 
37 BEGIN_HIPCUB_NAMESPACE
38 
40 {
41  template<typename KeyIteratorT, typename ValueIteratorT, typename OffsetT, typename CompareOpT>
42  HIPCUB_RUNTIME_FUNCTION static hipError_t SortPairs(void * d_temp_storage,
43  std::size_t & temp_storage_bytes,
44  KeyIteratorT d_keys,
45  ValueIteratorT d_items,
46  OffsetT num_items,
47  CompareOpT compare_op,
48  hipStream_t stream = 0,
49  bool debug_synchronous = false)
50  {
51  return hipCUDAErrorTohipError(::cub::DeviceMergeSort::SortPairs(d_temp_storage,
52  temp_storage_bytes,
53  d_keys,
54  d_items,
55  num_items,
56  compare_op,
57  stream,
58  debug_synchronous));
59  }
60 
61  template<typename KeyInputIteratorT,
62  typename ValueInputIteratorT,
63  typename KeyIteratorT,
64  typename ValueIteratorT,
65  typename OffsetT,
66  typename CompareOpT>
67  HIPCUB_RUNTIME_FUNCTION static hipError_t SortPairsCopy(void * d_temp_storage,
68  std::size_t & temp_storage_bytes,
69  KeyInputIteratorT d_input_keys,
70  ValueInputIteratorT d_input_items,
71  KeyIteratorT d_output_keys,
72  ValueIteratorT d_output_items,
73  OffsetT num_items,
74  CompareOpT compare_op,
75  hipStream_t stream = 0,
76  bool debug_synchronous = false)
77  {
78  return hipCUDAErrorTohipError(::cub::DeviceMergeSort::SortPairsCopy(d_temp_storage,
79  temp_storage_bytes,
80  d_input_keys,
81  d_input_items,
82  d_output_keys,
83  d_output_items,
84  num_items,
85  compare_op,
86  stream,
87  debug_synchronous));
88  }
89 
90  template<typename KeyIteratorT, typename OffsetT, typename CompareOpT>
91  HIPCUB_RUNTIME_FUNCTION static hipError_t SortKeys(void * d_temp_storage,
92  std::size_t & temp_storage_bytes,
93  KeyIteratorT d_keys,
94  OffsetT num_items,
95  CompareOpT compare_op,
96  hipStream_t stream = 0,
97  bool debug_synchronous = false)
98  {
99  return hipCUDAErrorTohipError(::cub::DeviceMergeSort::SortKeys(d_temp_storage,
100  temp_storage_bytes,
101  d_keys,
102  num_items,
103  compare_op,
104  stream,
105  debug_synchronous));
106  }
107 
108  template<typename KeyInputIteratorT,
109  typename KeyIteratorT,
110  typename OffsetT,
111  typename CompareOpT>
112  HIPCUB_RUNTIME_FUNCTION static hipError_t SortKeysCopy(void * d_temp_storage,
113  std::size_t & temp_storage_bytes,
114  KeyInputIteratorT d_input_keys,
115  KeyIteratorT d_output_keys,
116  OffsetT num_items,
117  CompareOpT compare_op,
118  hipStream_t stream = 0,
119  bool debug_synchronous = false)
120 
121  {
122  return hipCUDAErrorTohipError(::cub::DeviceMergeSort::SortKeysCopy(d_temp_storage,
123  temp_storage_bytes,
124  d_input_keys,
125  d_output_keys,
126  num_items,
127  compare_op,
128  stream,
129  debug_synchronous));
130  }
131 
132  template <typename KeyIteratorT,
133  typename ValueIteratorT,
134  typename OffsetT,
135  typename CompareOpT>
136  HIPCUB_RUNTIME_FUNCTION static hipError_t
137  StableSortPairs(void *d_temp_storage,
138  std::size_t &temp_storage_bytes,
139  KeyIteratorT d_keys,
140  ValueIteratorT d_items,
141  OffsetT num_items,
142  CompareOpT compare_op,
143  hipStream_t stream = 0,
144  bool debug_synchronous = false)
145  {
146  return hipCUDAErrorTohipError(
147  ::cub::DeviceMergeSort::StableSortPairs(d_temp_storage,
148  temp_storage_bytes,
149  d_keys,
150  d_items,
151  num_items,
152  compare_op,
153  stream,
154  debug_synchronous)
155  );
156  }
157 
158  template<typename KeyIteratorT, typename OffsetT, typename CompareOpT>
159  HIPCUB_RUNTIME_FUNCTION static hipError_t StableSortKeys(void * d_temp_storage,
160  std::size_t & temp_storage_bytes,
161  KeyIteratorT d_keys,
162  OffsetT num_items,
163  CompareOpT compare_op,
164  hipStream_t stream = 0,
165  bool debug_synchronous = false)
166  {
167  return hipCUDAErrorTohipError(::cub::DeviceMergeSort::StableSortKeys(d_temp_storage,
168  temp_storage_bytes,
169  d_keys,
170  num_items,
171  compare_op,
172  stream,
173  debug_synchronous));
174  }
175 };
176 
177 END_HIPCUB_NAMESPACE
178 
179 #endif // HIPCUB_CUB_DEVICE_DEVICE_MERGE_SORT_HPP_
Definition: device_merge_sort.hpp:40