rocPRIM
device_reduce.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_DETAIL_CONFIG_DEVICE_REDUCE_HPP_
22 #define ROCPRIM_DEVICE_DETAIL_CONFIG_DEVICE_REDUCE_HPP_
23 
24 #include "../../../type_traits.hpp"
25 #include "../device_config_helper.hpp"
26 #include <type_traits>
27 
28 /* DO NOT EDIT THIS FILE
29  * This file is automatically generated by `/scripts/autotune/create_optimization.py`.
30  * so most likely you want to edit rocprim/device/device_(algo)_config.hpp
31  */
32 
35 
36 BEGIN_ROCPRIM_NAMESPACE
37 
38 namespace detail
39 {
40 
41 template<unsigned int arch, class key_type, class enable = void>
43 {};
44 
45 // Based on key_type = double
46 template<class key_type>
48  static_cast<unsigned int>(target_arch::gfx1030),
49  key_type,
50  std::enable_if_t<(bool(rocprim::is_floating_point<key_type>::value) && (sizeof(key_type) <= 8)
51  && (sizeof(key_type) > 4))>>
52  : reduce_config<256, 8, ::rocprim::block_reduce_algorithm::using_warp_reduce>
53 {};
54 
55 // Based on key_type = float
56 template<class key_type>
58  static_cast<unsigned int>(target_arch::gfx1030),
59  key_type,
60  std::enable_if_t<(bool(rocprim::is_floating_point<key_type>::value) && (sizeof(key_type) <= 4)
61  && (sizeof(key_type) > 2))>>
62  : reduce_config<256, 2, ::rocprim::block_reduce_algorithm::using_warp_reduce>
63 {};
64 
65 // Based on key_type = rocprim::half
66 template<class key_type>
67 struct default_reduce_config<static_cast<unsigned int>(target_arch::gfx1030),
68  key_type,
69  std::enable_if_t<(bool(rocprim::is_floating_point<key_type>::value)
70  && (sizeof(key_type) <= 2))>>
71  : reduce_config<256, 4, ::rocprim::block_reduce_algorithm::using_warp_reduce>
72 {};
73 
74 // Based on key_type = int64_t
75 template<class key_type>
77  static_cast<unsigned int>(target_arch::gfx1030),
78  key_type,
79  std::enable_if_t<(!bool(rocprim::is_floating_point<key_type>::value) && (sizeof(key_type) <= 8)
80  && (sizeof(key_type) > 4))>>
81  : reduce_config<256, 1, ::rocprim::block_reduce_algorithm::using_warp_reduce>
82 {};
83 
84 // Based on key_type = int
85 template<class key_type>
87  static_cast<unsigned int>(target_arch::gfx1030),
88  key_type,
89  std::enable_if_t<(!bool(rocprim::is_floating_point<key_type>::value) && (sizeof(key_type) <= 4)
90  && (sizeof(key_type) > 2))>>
91  : reduce_config<256, 2, ::rocprim::block_reduce_algorithm::using_warp_reduce>
92 {};
93 
94 // Based on key_type = short
95 template<class key_type>
97  static_cast<unsigned int>(target_arch::gfx1030),
98  key_type,
99  std::enable_if_t<(!bool(rocprim::is_floating_point<key_type>::value) && (sizeof(key_type) <= 2)
100  && (sizeof(key_type) > 1))>>
101  : reduce_config<256, 4, ::rocprim::block_reduce_algorithm::using_warp_reduce>
102 {};
103 
104 // Based on key_type = int8_t
105 template<class key_type>
106 struct default_reduce_config<static_cast<unsigned int>(target_arch::gfx1030),
107  key_type,
108  std::enable_if_t<(!bool(rocprim::is_floating_point<key_type>::value)
109  && (sizeof(key_type) <= 1))>>
110  : reduce_config<128, 16, ::rocprim::block_reduce_algorithm::using_warp_reduce>
111 {};
112 
113 // Based on key_type = double
114 template<class key_type>
116  static_cast<unsigned int>(target_arch::gfx1102),
117  key_type,
118  std::enable_if_t<(bool(rocprim::is_floating_point<key_type>::value) && (sizeof(key_type) <= 8)
119  && (sizeof(key_type) > 4))>>
120  : reduce_config<256, 8, ::rocprim::block_reduce_algorithm::using_warp_reduce>
121 {};
122 
123 // Based on key_type = float
124 template<class key_type>
126  static_cast<unsigned int>(target_arch::gfx1102),
127  key_type,
128  std::enable_if_t<(bool(rocprim::is_floating_point<key_type>::value) && (sizeof(key_type) <= 4)
129  && (sizeof(key_type) > 2))>>
130  : reduce_config<128, 16, ::rocprim::block_reduce_algorithm::using_warp_reduce>
131 {};
132 
133 // Based on key_type = rocprim::half
134 template<class key_type>
135 struct default_reduce_config<static_cast<unsigned int>(target_arch::gfx1102),
136  key_type,
137  std::enable_if_t<(bool(rocprim::is_floating_point<key_type>::value)
138  && (sizeof(key_type) <= 2))>>
139  : reduce_config<256, 16, ::rocprim::block_reduce_algorithm::using_warp_reduce>
140 {};
141 
142 // Based on key_type = int64_t
143 template<class key_type>
145  static_cast<unsigned int>(target_arch::gfx1102),
146  key_type,
147  std::enable_if_t<(!bool(rocprim::is_floating_point<key_type>::value) && (sizeof(key_type) <= 8)
148  && (sizeof(key_type) > 4))>>
149  : reduce_config<128, 16, ::rocprim::block_reduce_algorithm::using_warp_reduce>
150 {};
151 
152 // Based on key_type = int
153 template<class key_type>
155  static_cast<unsigned int>(target_arch::gfx1102),
156  key_type,
157  std::enable_if_t<(!bool(rocprim::is_floating_point<key_type>::value) && (sizeof(key_type) <= 4)
158  && (sizeof(key_type) > 2))>>
159  : reduce_config<256, 8, ::rocprim::block_reduce_algorithm::using_warp_reduce>
160 {};
161 
162 // Based on key_type = short
163 template<class key_type>
165  static_cast<unsigned int>(target_arch::gfx1102),
166  key_type,
167  std::enable_if_t<(!bool(rocprim::is_floating_point<key_type>::value) && (sizeof(key_type) <= 2)
168  && (sizeof(key_type) > 1))>>
169  : reduce_config<256, 8, ::rocprim::block_reduce_algorithm::using_warp_reduce>
170 {};
171 
172 // Based on key_type = int8_t
173 template<class key_type>
174 struct default_reduce_config<static_cast<unsigned int>(target_arch::gfx1102),
175  key_type,
176  std::enable_if_t<(!bool(rocprim::is_floating_point<key_type>::value)
177  && (sizeof(key_type) <= 1))>>
178  : reduce_config<256, 16, ::rocprim::block_reduce_algorithm::using_warp_reduce>
179 {};
180 
181 // Based on key_type = double
182 template<class key_type>
184  static_cast<unsigned int>(target_arch::gfx900),
185  key_type,
186  std::enable_if_t<(bool(rocprim::is_floating_point<key_type>::value) && (sizeof(key_type) <= 8)
187  && (sizeof(key_type) > 4))>>
188  : reduce_config<128, 4, ::rocprim::block_reduce_algorithm::using_warp_reduce>
189 {};
190 
191 // Based on key_type = float
192 template<class key_type>
194  static_cast<unsigned int>(target_arch::gfx900),
195  key_type,
196  std::enable_if_t<(bool(rocprim::is_floating_point<key_type>::value) && (sizeof(key_type) <= 4)
197  && (sizeof(key_type) > 2))>>
198  : reduce_config<128, 8, ::rocprim::block_reduce_algorithm::using_warp_reduce>
199 {};
200 
201 // Based on key_type = rocprim::half
202 template<class key_type>
203 struct default_reduce_config<static_cast<unsigned int>(target_arch::gfx900),
204  key_type,
205  std::enable_if_t<(bool(rocprim::is_floating_point<key_type>::value)
206  && (sizeof(key_type) <= 2))>>
207  : reduce_config<128, 16, ::rocprim::block_reduce_algorithm::using_warp_reduce>
208 {};
209 
210 // Based on key_type = int64_t
211 template<class key_type>
213  static_cast<unsigned int>(target_arch::gfx900),
214  key_type,
215  std::enable_if_t<(!bool(rocprim::is_floating_point<key_type>::value) && (sizeof(key_type) <= 8)
216  && (sizeof(key_type) > 4))>>
217  : reduce_config<128, 4, ::rocprim::block_reduce_algorithm::using_warp_reduce>
218 {};
219 
220 // Based on key_type = int
221 template<class key_type>
223  static_cast<unsigned int>(target_arch::gfx900),
224  key_type,
225  std::enable_if_t<(!bool(rocprim::is_floating_point<key_type>::value) && (sizeof(key_type) <= 4)
226  && (sizeof(key_type) > 2))>>
227  : reduce_config<128, 8, ::rocprim::block_reduce_algorithm::using_warp_reduce>
228 {};
229 
230 // Based on key_type = short
231 template<class key_type>
233  static_cast<unsigned int>(target_arch::gfx900),
234  key_type,
235  std::enable_if_t<(!bool(rocprim::is_floating_point<key_type>::value) && (sizeof(key_type) <= 2)
236  && (sizeof(key_type) > 1))>>
237  : reduce_config<128, 16, ::rocprim::block_reduce_algorithm::using_warp_reduce>
238 {};
239 
240 // Based on key_type = int8_t
241 template<class key_type>
242 struct default_reduce_config<static_cast<unsigned int>(target_arch::gfx900),
243  key_type,
244  std::enable_if_t<(!bool(rocprim::is_floating_point<key_type>::value)
245  && (sizeof(key_type) <= 1))>>
246  : reduce_config<64, 16, ::rocprim::block_reduce_algorithm::using_warp_reduce>
247 {};
248 
249 // Based on key_type = double
250 template<class key_type>
252  static_cast<unsigned int>(target_arch::gfx906),
253  key_type,
254  std::enable_if_t<(bool(rocprim::is_floating_point<key_type>::value) && (sizeof(key_type) <= 8)
255  && (sizeof(key_type) > 4))>>
256  : reduce_config<128, 4, ::rocprim::block_reduce_algorithm::using_warp_reduce>
257 {};
258 
259 // Based on key_type = float
260 template<class key_type>
262  static_cast<unsigned int>(target_arch::gfx906),
263  key_type,
264  std::enable_if_t<(bool(rocprim::is_floating_point<key_type>::value) && (sizeof(key_type) <= 4)
265  && (sizeof(key_type) > 2))>>
266  : reduce_config<256, 4, ::rocprim::block_reduce_algorithm::using_warp_reduce>
267 {};
268 
269 // Based on key_type = rocprim::half
270 template<class key_type>
271 struct default_reduce_config<static_cast<unsigned int>(target_arch::gfx906),
272  key_type,
273  std::enable_if_t<(bool(rocprim::is_floating_point<key_type>::value)
274  && (sizeof(key_type) <= 2))>>
275  : reduce_config<64, 16, ::rocprim::block_reduce_algorithm::using_warp_reduce>
276 {};
277 
278 // Based on key_type = int64_t
279 template<class key_type>
281  static_cast<unsigned int>(target_arch::gfx906),
282  key_type,
283  std::enable_if_t<(!bool(rocprim::is_floating_point<key_type>::value) && (sizeof(key_type) <= 8)
284  && (sizeof(key_type) > 4))>>
285  : reduce_config<256, 16, ::rocprim::block_reduce_algorithm::using_warp_reduce>
286 {};
287 
288 // Based on key_type = int
289 template<class key_type>
291  static_cast<unsigned int>(target_arch::gfx906),
292  key_type,
293  std::enable_if_t<(!bool(rocprim::is_floating_point<key_type>::value) && (sizeof(key_type) <= 4)
294  && (sizeof(key_type) > 2))>>
295  : reduce_config<256, 4, ::rocprim::block_reduce_algorithm::using_warp_reduce>
296 {};
297 
298 // Based on key_type = short
299 template<class key_type>
301  static_cast<unsigned int>(target_arch::gfx906),
302  key_type,
303  std::enable_if_t<(!bool(rocprim::is_floating_point<key_type>::value) && (sizeof(key_type) <= 2)
304  && (sizeof(key_type) > 1))>>
305  : reduce_config<256, 8, ::rocprim::block_reduce_algorithm::using_warp_reduce>
306 {};
307 
308 // Based on key_type = int8_t
309 template<class key_type>
310 struct default_reduce_config<static_cast<unsigned int>(target_arch::gfx906),
311  key_type,
312  std::enable_if_t<(!bool(rocprim::is_floating_point<key_type>::value)
313  && (sizeof(key_type) <= 1))>>
314  : reduce_config<128, 16, ::rocprim::block_reduce_algorithm::using_warp_reduce>
315 {};
316 
317 // Based on key_type = double
318 template<class key_type>
320  static_cast<unsigned int>(target_arch::gfx908),
321  key_type,
322  std::enable_if_t<(bool(rocprim::is_floating_point<key_type>::value) && (sizeof(key_type) <= 8)
323  && (sizeof(key_type) > 4))>>
324  : reduce_config<256, 16, ::rocprim::block_reduce_algorithm::using_warp_reduce>
325 {};
326 
327 // Based on key_type = float
328 template<class key_type>
330  static_cast<unsigned int>(target_arch::gfx908),
331  key_type,
332  std::enable_if_t<(bool(rocprim::is_floating_point<key_type>::value) && (sizeof(key_type) <= 4)
333  && (sizeof(key_type) > 2))>>
334  : reduce_config<256, 4, ::rocprim::block_reduce_algorithm::using_warp_reduce>
335 {};
336 
337 // Based on key_type = rocprim::half
338 template<class key_type>
339 struct default_reduce_config<static_cast<unsigned int>(target_arch::gfx908),
340  key_type,
341  std::enable_if_t<(bool(rocprim::is_floating_point<key_type>::value)
342  && (sizeof(key_type) <= 2))>>
343  : reduce_config<256, 16, ::rocprim::block_reduce_algorithm::using_warp_reduce>
344 {};
345 
346 // Based on key_type = int64_t
347 template<class key_type>
349  static_cast<unsigned int>(target_arch::gfx908),
350  key_type,
351  std::enable_if_t<(!bool(rocprim::is_floating_point<key_type>::value) && (sizeof(key_type) <= 8)
352  && (sizeof(key_type) > 4))>>
353  : reduce_config<256, 16, ::rocprim::block_reduce_algorithm::using_warp_reduce>
354 {};
355 
356 // Based on key_type = int
357 template<class key_type>
359  static_cast<unsigned int>(target_arch::gfx908),
360  key_type,
361  std::enable_if_t<(!bool(rocprim::is_floating_point<key_type>::value) && (sizeof(key_type) <= 4)
362  && (sizeof(key_type) > 2))>>
363  : reduce_config<256, 4, ::rocprim::block_reduce_algorithm::using_warp_reduce>
364 {};
365 
366 // Based on key_type = short
367 template<class key_type>
369  static_cast<unsigned int>(target_arch::gfx908),
370  key_type,
371  std::enable_if_t<(!bool(rocprim::is_floating_point<key_type>::value) && (sizeof(key_type) <= 2)
372  && (sizeof(key_type) > 1))>>
373  : reduce_config<128, 8, ::rocprim::block_reduce_algorithm::using_warp_reduce>
374 {};
375 
376 // Based on key_type = int8_t
377 template<class key_type>
378 struct default_reduce_config<static_cast<unsigned int>(target_arch::gfx908),
379  key_type,
380  std::enable_if_t<(!bool(rocprim::is_floating_point<key_type>::value)
381  && (sizeof(key_type) <= 1))>>
382  : reduce_config<256, 16, ::rocprim::block_reduce_algorithm::using_warp_reduce>
383 {};
384 
385 // Based on key_type = double
386 template<class key_type>
388  static_cast<unsigned int>(target_arch::unknown),
389  key_type,
390  std::enable_if_t<(bool(rocprim::is_floating_point<key_type>::value) && (sizeof(key_type) <= 8)
391  && (sizeof(key_type) > 4))>>
392  : reduce_config<256, 16, ::rocprim::block_reduce_algorithm::using_warp_reduce>
393 {};
394 
395 // Based on key_type = float
396 template<class key_type>
398  static_cast<unsigned int>(target_arch::unknown),
399  key_type,
400  std::enable_if_t<(bool(rocprim::is_floating_point<key_type>::value) && (sizeof(key_type) <= 4)
401  && (sizeof(key_type) > 2))>>
402  : reduce_config<256, 4, ::rocprim::block_reduce_algorithm::using_warp_reduce>
403 {};
404 
405 // Based on key_type = rocprim::half
406 template<class key_type>
407 struct default_reduce_config<static_cast<unsigned int>(target_arch::unknown),
408  key_type,
409  std::enable_if_t<(bool(rocprim::is_floating_point<key_type>::value)
410  && (sizeof(key_type) <= 2))>>
411  : reduce_config<256, 16, ::rocprim::block_reduce_algorithm::using_warp_reduce>
412 {};
413 
414 // Based on key_type = int64_t
415 template<class key_type>
417  static_cast<unsigned int>(target_arch::unknown),
418  key_type,
419  std::enable_if_t<(!bool(rocprim::is_floating_point<key_type>::value) && (sizeof(key_type) <= 8)
420  && (sizeof(key_type) > 4))>>
421  : reduce_config<256, 16, ::rocprim::block_reduce_algorithm::using_warp_reduce>
422 {};
423 
424 // Based on key_type = int
425 template<class key_type>
427  static_cast<unsigned int>(target_arch::unknown),
428  key_type,
429  std::enable_if_t<(!bool(rocprim::is_floating_point<key_type>::value) && (sizeof(key_type) <= 4)
430  && (sizeof(key_type) > 2))>>
431  : reduce_config<256, 4, ::rocprim::block_reduce_algorithm::using_warp_reduce>
432 {};
433 
434 // Based on key_type = short
435 template<class key_type>
437  static_cast<unsigned int>(target_arch::unknown),
438  key_type,
439  std::enable_if_t<(!bool(rocprim::is_floating_point<key_type>::value) && (sizeof(key_type) <= 2)
440  && (sizeof(key_type) > 1))>>
441  : reduce_config<128, 8, ::rocprim::block_reduce_algorithm::using_warp_reduce>
442 {};
443 
444 // Based on key_type = int8_t
445 template<class key_type>
446 struct default_reduce_config<static_cast<unsigned int>(target_arch::unknown),
447  key_type,
448  std::enable_if_t<(!bool(rocprim::is_floating_point<key_type>::value)
449  && (sizeof(key_type) <= 1))>>
450  : reduce_config<256, 16, ::rocprim::block_reduce_algorithm::using_warp_reduce>
451 {};
452 
453 // Based on key_type = double
454 template<class key_type>
456  static_cast<unsigned int>(target_arch::gfx90a),
457  key_type,
458  std::enable_if_t<(bool(rocprim::is_floating_point<key_type>::value) && (sizeof(key_type) <= 8)
459  && (sizeof(key_type) > 4))>>
460  : reduce_config<256, 16, ::rocprim::block_reduce_algorithm::using_warp_reduce>
461 {};
462 
463 // Based on key_type = float
464 template<class key_type>
466  static_cast<unsigned int>(target_arch::gfx90a),
467  key_type,
468  std::enable_if_t<(bool(rocprim::is_floating_point<key_type>::value) && (sizeof(key_type) <= 4)
469  && (sizeof(key_type) > 2))>>
470  : reduce_config<256, 4, ::rocprim::block_reduce_algorithm::using_warp_reduce>
471 {};
472 
473 // Based on key_type = rocprim::half
474 template<class key_type>
475 struct default_reduce_config<static_cast<unsigned int>(target_arch::gfx90a),
476  key_type,
477  std::enable_if_t<(bool(rocprim::is_floating_point<key_type>::value)
478  && (sizeof(key_type) <= 2))>>
479  : reduce_config<256, 16, ::rocprim::block_reduce_algorithm::using_warp_reduce>
480 {};
481 
482 // Based on key_type = int64_t
483 template<class key_type>
485  static_cast<unsigned int>(target_arch::gfx90a),
486  key_type,
487  std::enable_if_t<(!bool(rocprim::is_floating_point<key_type>::value) && (sizeof(key_type) <= 8)
488  && (sizeof(key_type) > 4))>>
489  : reduce_config<256, 16, ::rocprim::block_reduce_algorithm::using_warp_reduce>
490 {};
491 
492 // Based on key_type = int
493 template<class key_type>
495  static_cast<unsigned int>(target_arch::gfx90a),
496  key_type,
497  std::enable_if_t<(!bool(rocprim::is_floating_point<key_type>::value) && (sizeof(key_type) <= 4)
498  && (sizeof(key_type) > 2))>>
499  : reduce_config<256, 4, ::rocprim::block_reduce_algorithm::using_warp_reduce>
500 {};
501 
502 // Based on key_type = short
503 template<class key_type>
505  static_cast<unsigned int>(target_arch::gfx90a),
506  key_type,
507  std::enable_if_t<(!bool(rocprim::is_floating_point<key_type>::value) && (sizeof(key_type) <= 2)
508  && (sizeof(key_type) > 1))>>
509  : reduce_config<128, 8, ::rocprim::block_reduce_algorithm::using_warp_reduce>
510 {};
511 
512 // Based on key_type = int8_t
513 template<class key_type>
514 struct default_reduce_config<static_cast<unsigned int>(target_arch::gfx90a),
515  key_type,
516  std::enable_if_t<(!bool(rocprim::is_floating_point<key_type>::value)
517  && (sizeof(key_type) <= 1))>>
518  : reduce_config<256, 16, ::rocprim::block_reduce_algorithm::using_warp_reduce>
519 {};
520 
521 } // end namespace detail
522 
523 END_ROCPRIM_NAMESPACE
524 
526 // end of group primitivesmodule_deviceconfigs
527 
528 #endif // ROCPRIM_DEVICE_DETAIL_CONFIG_DEVICE_REDUCE_HPP_
Configuration of device-level reduce primitives.
Definition: device_config_helper.hpp:241
Definition: device_config_helper.hpp:265
Deprecated: Configuration of device-level scan primitives.
Definition: block_histogram.hpp:62
Definition: device_reduce.hpp:42