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

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

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