/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-hipcub/checkouts/docs-5.7.0/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.7.0/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.7.0/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-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_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  (void)debug_synchronous;
52  return hipCUDAErrorTohipError(::cub::DeviceMergeSort::SortPairs(d_temp_storage,
53  temp_storage_bytes,
54  d_keys,
55  d_items,
56  num_items,
57  compare_op,
58  stream));
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  (void)debug_synchronous;
79  return hipCUDAErrorTohipError(::cub::DeviceMergeSort::SortPairsCopy(d_temp_storage,
80  temp_storage_bytes,
81  d_input_keys,
82  d_input_items,
83  d_output_keys,
84  d_output_items,
85  num_items,
86  compare_op,
87  stream));
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  (void)debug_synchronous;
100  return hipCUDAErrorTohipError(::cub::DeviceMergeSort::SortKeys(d_temp_storage,
101  temp_storage_bytes,
102  d_keys,
103  num_items,
104  compare_op,
105  stream));
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  (void)debug_synchronous;
123  return hipCUDAErrorTohipError(::cub::DeviceMergeSort::SortKeysCopy(d_temp_storage,
124  temp_storage_bytes,
125  d_input_keys,
126  d_output_keys,
127  num_items,
128  compare_op,
129  stream));
130  }
131 
132  template<typename KeyIteratorT, typename ValueIteratorT, typename OffsetT, typename CompareOpT>
133  HIPCUB_RUNTIME_FUNCTION static hipError_t StableSortPairs(void* d_temp_storage,
134  std::size_t& temp_storage_bytes,
135  KeyIteratorT d_keys,
136  ValueIteratorT d_items,
137  OffsetT num_items,
138  CompareOpT compare_op,
139  hipStream_t stream = 0,
140  bool debug_synchronous = false)
141  {
142  (void)debug_synchronous;
143  return hipCUDAErrorTohipError(::cub::DeviceMergeSort::StableSortPairs(d_temp_storage,
144  temp_storage_bytes,
145  d_keys,
146  d_items,
147  num_items,
148  compare_op,
149  stream));
150  }
151 
152  template<typename KeyIteratorT, typename OffsetT, typename CompareOpT>
153  HIPCUB_RUNTIME_FUNCTION static hipError_t StableSortKeys(void * d_temp_storage,
154  std::size_t & temp_storage_bytes,
155  KeyIteratorT d_keys,
156  OffsetT num_items,
157  CompareOpT compare_op,
158  hipStream_t stream = 0,
159  bool debug_synchronous = false)
160  {
161  (void)debug_synchronous;
162  return hipCUDAErrorTohipError(::cub::DeviceMergeSort::StableSortKeys(d_temp_storage,
163  temp_storage_bytes,
164  d_keys,
165  num_items,
166  compare_op,
167  stream));
168  }
169 };
170 
171 END_HIPCUB_NAMESPACE
172 
173 #endif // HIPCUB_CUB_DEVICE_DEVICE_MERGE_SORT_HPP_
Definition: device_merge_sort.hpp:40