/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-hipcub/checkouts/docs-5.6.0/hipcub/include/hipcub/backend/cub/device/device_reduce.hpp Source File

/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-hipcub/checkouts/docs-5.6.0/hipcub/include/hipcub/backend/cub/device/device_reduce.hpp Source File#

hipCUB: /home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-hipcub/checkouts/docs-5.6.0/hipcub/include/hipcub/backend/cub/device/device_reduce.hpp Source File
device_reduce.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-2020, 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_REDUCE_HPP_
31 #define HIPCUB_CUB_DEVICE_DEVICE_REDUCE_HPP_
32 
33 #include "../../../config.hpp"
34 
35 #include <cub/device/device_reduce.cuh>
36 
37 BEGIN_HIPCUB_NAMESPACE
38 
40 {
41 public:
42  template <
43  typename InputIteratorT,
44  typename OutputIteratorT,
45  typename ReduceOpT,
46  typename T
47  >
48  HIPCUB_RUNTIME_FUNCTION static
49  hipError_t Reduce(void *d_temp_storage,
50  size_t &temp_storage_bytes,
51  InputIteratorT d_in,
52  OutputIteratorT d_out,
53  int num_items,
54  ReduceOpT reduction_op,
55  T init,
56  hipStream_t stream = 0,
57  bool debug_synchronous = false)
58  {
59  return hipCUDAErrorTohipError(
60  ::cub::DeviceReduce::Reduce(
61  d_temp_storage, temp_storage_bytes,
62  d_in, d_out, num_items,
63  reduction_op, init,
64  stream, debug_synchronous
65  )
66  );
67  }
68 
69  template <
70  typename InputIteratorT,
71  typename OutputIteratorT
72  >
73  HIPCUB_RUNTIME_FUNCTION static
74  hipError_t Sum(void *d_temp_storage,
75  size_t &temp_storage_bytes,
76  InputIteratorT d_in,
77  OutputIteratorT d_out,
78  int num_items,
79  hipStream_t stream = 0,
80  bool debug_synchronous = false)
81  {
82  return hipCUDAErrorTohipError(
83  ::cub::DeviceReduce::Sum(
84  d_temp_storage, temp_storage_bytes,
85  d_in, d_out, num_items,
86  stream, debug_synchronous
87  )
88  );
89  }
90 
91  template <
92  typename InputIteratorT,
93  typename OutputIteratorT
94  >
95  HIPCUB_RUNTIME_FUNCTION static
96  hipError_t Min(void *d_temp_storage,
97  size_t &temp_storage_bytes,
98  InputIteratorT d_in,
99  OutputIteratorT d_out,
100  int num_items,
101  hipStream_t stream = 0,
102  bool debug_synchronous = false)
103  {
104  return hipCUDAErrorTohipError(
105  ::cub::DeviceReduce::Min(
106  d_temp_storage, temp_storage_bytes,
107  d_in, d_out, num_items,
108  stream, debug_synchronous
109  )
110  );
111  }
112 
113  template <
114  typename InputIteratorT,
115  typename OutputIteratorT
116  >
117  HIPCUB_RUNTIME_FUNCTION static
118  hipError_t ArgMin(void *d_temp_storage,
119  size_t &temp_storage_bytes,
120  InputIteratorT d_in,
121  OutputIteratorT d_out,
122  int num_items,
123  hipStream_t stream = 0,
124  bool debug_synchronous = false)
125  {
126  return hipCUDAErrorTohipError(
127  ::cub::DeviceReduce::ArgMin(
128  d_temp_storage, temp_storage_bytes,
129  d_in, d_out, num_items,
130  stream, debug_synchronous
131  )
132  );
133  }
134 
135  template <
136  typename InputIteratorT,
137  typename OutputIteratorT
138  >
139  HIPCUB_RUNTIME_FUNCTION static
140  hipError_t Max(void *d_temp_storage,
141  size_t &temp_storage_bytes,
142  InputIteratorT d_in,
143  OutputIteratorT d_out,
144  int num_items,
145  hipStream_t stream = 0,
146  bool debug_synchronous = false)
147  {
148  return hipCUDAErrorTohipError(
149  ::cub::DeviceReduce::Max(
150  d_temp_storage, temp_storage_bytes,
151  d_in, d_out, num_items,
152  stream, debug_synchronous
153  )
154  );
155  }
156 
157  template <
158  typename InputIteratorT,
159  typename OutputIteratorT
160  >
161  HIPCUB_RUNTIME_FUNCTION static
162  hipError_t ArgMax(void *d_temp_storage,
163  size_t &temp_storage_bytes,
164  InputIteratorT d_in,
165  OutputIteratorT d_out,
166  int num_items,
167  hipStream_t stream = 0,
168  bool debug_synchronous = false)
169  {
170  return hipCUDAErrorTohipError(
171  ::cub::DeviceReduce::ArgMax(
172  d_temp_storage, temp_storage_bytes,
173  d_in, d_out, num_items,
174  stream, debug_synchronous
175  )
176  );
177  }
178 
179  template<
180  typename KeysInputIteratorT,
181  typename UniqueOutputIteratorT,
182  typename ValuesInputIteratorT,
183  typename AggregatesOutputIteratorT,
184  typename NumRunsOutputIteratorT,
185  typename ReductionOpT
186  >
187  HIPCUB_RUNTIME_FUNCTION static
188  hipError_t ReduceByKey(void * d_temp_storage,
189  size_t& temp_storage_bytes,
190  KeysInputIteratorT d_keys_in,
191  UniqueOutputIteratorT d_unique_out,
192  ValuesInputIteratorT d_values_in,
193  AggregatesOutputIteratorT d_aggregates_out,
194  NumRunsOutputIteratorT d_num_runs_out,
195  ReductionOpT reduction_op,
196  int num_items,
197  hipStream_t stream = 0,
198  bool debug_synchronous = false)
199  {
200  return hipCUDAErrorTohipError(
201  ::cub::DeviceReduce::ReduceByKey(
202  d_temp_storage, temp_storage_bytes,
203  d_keys_in, d_unique_out,
204  d_values_in, d_aggregates_out,
205  d_num_runs_out, reduction_op, num_items,
206  stream, debug_synchronous
207  )
208  );
209  }
210 };
211 
212 END_HIPCUB_NAMESPACE
213 
214 #endif // HIPCUB_CUB_DEVICE_DEVICE_REDUCE_HPP_
Definition: device_reduce.hpp:40
Definition: thread_operators.hpp:126
Definition: thread_operators.hpp:141
Definition: thread_operators.hpp:106
Definition: thread_operators.hpp:116
Definition: thread_operators.hpp:76