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