rocPRIM
device_radix_sort_config.hpp
1 // Copyright (c) 2022-2023 Advanced Micro Devices, Inc. All rights reserved.
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 // THE SOFTWARE.
20 
21 #ifndef ROCPRIM_DEVICE_DEVICE_RADIX_SORT_CONFIG_HPP_
22 #define ROCPRIM_DEVICE_DEVICE_RADIX_SORT_CONFIG_HPP_
23 
24 #include "config_types.hpp"
25 #include "detail/config/device_radix_sort_block_sort.hpp"
26 #include "detail/device_config_helper.hpp"
27 
30 
31 BEGIN_ROCPRIM_NAMESPACE
32 
47 template<class SingleSortConfig = default_config,
48  class MergeSortConfig = default_config,
49  class OnesweepConfig = default_config,
50  size_t MergeSortLimit = 1024 * 1024>
52 {
53 #ifndef DOXYGEN_SHOULD_SKIP_THIS
54  using single_sort_config = SingleSortConfig;
57  using merge_sort_config = MergeSortConfig;
59  using onesweep_config = OnesweepConfig;
61  static constexpr size_t merge_sort_limit = MergeSortLimit;
62 #endif
63 };
64 
84 template<unsigned int LongRadixBits,
85  unsigned int ShortRadixBits,
86  class ScanConfig,
87  class SortConfig,
88  class SortSingleConfig = kernel_config<256, 10>,
89  class SortMergeConfig = kernel_config<1024, 1>,
90  unsigned int MergeSizeLimitBlocks = 1024U,
91  bool ForceSingleKernelConfig = false,
92  class OnesweepHistogramConfig = kernel_config<256, 8>,
93  class OnesweepSortConfig = kernel_config<256, 15>,
94  unsigned int OnesweepRadixBits = 4>
95 struct [[deprecated("use radix_sort_config_v2")]] radix_sort_config
96 {
97 #ifndef DOXYGEN_SHOULD_SKIP_THIS
98  using single_sort_config = SortSingleConfig;
103  using onesweep_config = radix_sort_onesweep_config<OnesweepHistogramConfig,
104  OnesweepSortConfig,
105  OnesweepRadixBits>;
107  static constexpr size_t merge_sort_limit = 1024 * MergeSizeLimitBlocks;
108 #endif
109 };
110 
111 namespace detail
112 {
113 
114 // sub-algorithm onesweep:
115 template<typename RadixSortOnesweepConfig, typename, typename>
117 {
118  template<target_arch Arch>
120  {
121  static constexpr radix_sort_onesweep_config_params params = RadixSortOnesweepConfig();
122  };
123 };
124 
125 template<typename Key, typename Value>
127 {
128  template<target_arch Arch>
129  struct architecture_config
130  {
133  };
134 };
135 
136 #ifndef DOXYGEN_SHOULD_SKIP_THIS
137 template<typename RadixSortOnesweepConfig, typename Key, typename Value>
138 template<target_arch Arch>
141  Arch>::params;
142 
143 template<typename Key, typename Value>
144 template<target_arch Arch>
147  Arch>::params;
148 #endif // DOXYGEN_SHOULD_SKIP_THIS
149 
150 // Sub-algorithm block_sort:
151 template<typename RadixSortBlockSortConfig, typename, typename>
153 {
154  template<target_arch Arch>
156  {
157  static constexpr kernel_config_params params = RadixSortBlockSortConfig();
158  };
159 };
160 
161 template<typename Key, typename Value>
163 {
164  template<target_arch Arch>
165  struct architecture_config
166  {
167  static constexpr kernel_config_params params
169  };
170 };
171 
172 #ifndef DOXYGEN_SHOULD_SKIP_THIS
173 template<typename RadixSortBlockSortConfig, typename Key, typename Value>
174 template<target_arch Arch>
175 constexpr kernel_config_params
177  Arch>::params;
178 
179 template<typename Key, typename Value>
180 template<target_arch Arch>
182  architecture_config<Arch>::params;
183 #endif // DOXYGEN_SHOULD_SKIP_THIS
184 
185 } // namespace detail
186 
187 END_ROCPRIM_NAMESPACE
188 
190 // end of group primitivesmodule_deviceconfigs
191 
192 #endif // ROCPRIM_DEVICE_DEVICE_RADIX_SORT_CONFIG_HPP_
Definition: device_radix_sort_config.hpp:119
SingleSortConfig single_sort_config
Configuration of radix sort single kernel.
Definition: device_radix_sort_config.hpp:55
Definition: config_types.hpp:65
Special type used to show that the given device-level operation will be executed with optimal configu...
Definition: config_types.hpp:45
Definition: device_radix_sort_onesweep.hpp:45
static constexpr size_t merge_sort_limit
Maximum number of items to use merge sort algorithm.
Definition: device_radix_sort_config.hpp:61
Deprecated: Configuration of device-level scan primitives.
Definition: block_histogram.hpp:62
Definition: device_radix_sort_config.hpp:116
Configuration of subalgorithm Onesweep.
Definition: device_config_helper.hpp:188
Definition: device_radix_sort_config.hpp:155
Definition: device_radix_sort_block_sort.hpp:45
Definition: device_radix_sort_config.hpp:152
Configuration of device-level radix sort operation.
Definition: device_radix_sort_config.hpp:51
Definition: test_device_binary_search.cpp:37
Configuration of device-level merge primitives.
Definition: device_merge_sort_config.hpp:66
OnesweepConfig onesweep_config
Configuration of radix sort onesweep.
Definition: device_radix_sort_config.hpp:59
Default values are provided by radix_sort_onesweep_config_base.
Definition: device_config_helper.hpp:163
struct deprecated("use radix_sort_config_v2")]] radix_sort_config
Legacy configuration of device-level radix sort operation.
Definition: device_radix_sort_config.hpp:95