rocPRIM
device_merge_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_MERGE_SORT_CONFIG_HPP_
22 #define ROCPRIM_DEVICE_DEVICE_MERGE_SORT_CONFIG_HPP_
23 
24 #include "config_types.hpp"
25 #include "detail/config/device_merge_sort_block_merge.hpp"
26 #include "detail/config/device_merge_sort_block_sort.hpp"
27 #include "detail/device_config_helper.hpp"
28 
31 
32 BEGIN_ROCPRIM_NAMESPACE
33 
34 namespace detail
35 {
36 
39 {
40  merge_sort_block_sort_config_params block_sort_config;
41  merge_sort_block_merge_config_params block_merge_config;
42 };
43 
44 } // namespace detail
45 
59 template<unsigned int MergeOddevenBlockSize = 512,
60  unsigned int SortBlockSize = MergeOddevenBlockSize,
61  unsigned int SortItemsPerThread = 1,
62  unsigned int MergeMergepathPartitionBlockSize = 128,
63  unsigned int MergeMergepathBlockSize = 128,
64  unsigned int MergeMergepathItemsPerThread = 4,
65  unsigned int MinInputSizeMergepath = (1 << 17) + 70000>
67 {
68 #ifndef DOXYGEN_SHOULD_SKIP_THIS
69  using block_sort_config
72  SortItemsPerThread,
74  using block_merge_config = detail::merge_sort_block_merge_config<MergeOddevenBlockSize,
75  1,
76  MinInputSizeMergepath,
77  MergeMergepathBlockSize,
78  MergeMergepathBlockSize,
79  MergeMergepathItemsPerThread>;
80  constexpr merge_sort_config()
81  : detail::merge_sort_config_params{block_sort_config(), block_merge_config()} {};
82 #endif
83 };
84 
85 namespace detail
86 {
87 
88 // Sub algorithm block_merge:
89 
90 template<typename MergeSortBlockMergeConfig, typename, typename>
92 {
93  template<target_arch Arch>
95  {
96  static constexpr merge_sort_block_merge_config_params params = MergeSortBlockMergeConfig();
97  };
98 };
99 
100 template<typename Key, typename Value>
102 {
103  template<target_arch Arch>
104  struct architecture_config
105  {
108  };
109 };
110 
111 #ifndef DOXYGEN_SHOULD_SKIP_THIS
112 template<typename MergeSortBlockMergeConfig, typename Key, typename Value>
113 template<target_arch Arch>
116  architecture_config<Arch>::params;
117 
118 template<typename Key, typename Value>
119 template<target_arch Arch>
122  Arch>::params;
123 #endif // DOXYGEN_SHOULD_SKIP_THIS
124 
125 // Sub-algorithm block_sort:
126 template<typename MergeSortBlockSortConfig, typename, typename>
128 {
129  template<target_arch Arch>
131  {
132  static constexpr merge_sort_block_sort_config_params params = MergeSortBlockSortConfig();
133  };
134 };
135 
136 template<typename Key, typename Value>
138 {
139  template<target_arch Arch>
140  struct architecture_config
141  {
144  };
145 };
146 
147 #ifndef DOXYGEN_SHOULD_SKIP_THIS
148 template<typename MergeSortBlockSortConfig, typename Key, typename Value>
149 template<target_arch Arch>
152  Arch>::params;
153 
154 template<typename Key, typename Value>
155 template<target_arch Arch>
158  Arch>::params;
159 #endif // DOXYGEN_SHOULD_SKIP_THIS
160 
161 } // namespace detail
162 
163 END_ROCPRIM_NAMESPACE
164 
166 // end of group primitivesmodule_deviceconfigs
167 
168 #endif // ROCPRIM_DEVICE_DEVICE_MERGE_SORT_CONFIG_HPP_
Kernel parameters for device merge sort.
Definition: device_merge_sort_config.hpp:38
Definition: device_merge_sort_config.hpp:130
A merged sort based algorithm which sorts stably.
Special type used to show that the given device-level operation will be executed with optimal configu...
Definition: config_types.hpp:45
Definition: device_merge_sort_block_sort.hpp:45
Definition: device_config_helper.hpp:56
Definition: device_config_helper.hpp:137
Definition: device_merge_sort_config.hpp:91
Deprecated: Configuration of device-level scan primitives.
Definition: block_histogram.hpp:62
Default values are provided by merge_sort_block_merge_config_base.
Definition: device_config_helper.hpp:122
Default values are provided by merge_sort_block_sort_config_base.
Definition: device_config_helper.hpp:47
Definition: device_merge_sort_config.hpp:127
Definition: test_device_binary_search.cpp:37
Configuration of device-level merge primitives.
Definition: device_merge_sort_config.hpp:66
Definition: device_merge_sort_block_merge.hpp:45