/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-hipcub/checkouts/docs-5.7.0/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.7.0/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.7.0/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-2023, 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  (void)debug_synchronous;
62  return hipCUDAErrorTohipError(::cub::DeviceSegmentedReduce::Reduce(d_temp_storage,
63  temp_storage_bytes,
64  d_in,
65  d_out,
66  num_segments,
67  d_begin_offsets,
68  d_end_offsets,
69  reduction_op,
70  initial_value,
71  stream));
72  }
73 
74  template<
75  typename InputIteratorT,
76  typename OutputIteratorT,
77  typename OffsetIteratorT
78  >
79  HIPCUB_RUNTIME_FUNCTION static
80  hipError_t Sum(void * d_temp_storage,
81  size_t& temp_storage_bytes,
82  InputIteratorT d_in,
83  OutputIteratorT d_out,
84  int num_segments,
85  OffsetIteratorT d_begin_offsets,
86  OffsetIteratorT d_end_offsets,
87  hipStream_t stream = 0,
88  bool debug_synchronous = false)
89  {
90  (void)debug_synchronous;
91  return hipCUDAErrorTohipError(::cub::DeviceSegmentedReduce::Sum(d_temp_storage,
92  temp_storage_bytes,
93  d_in,
94  d_out,
95  num_segments,
96  d_begin_offsets,
97  d_end_offsets,
98  stream));
99  }
100 
101  template<
102  typename InputIteratorT,
103  typename OutputIteratorT,
104  typename OffsetIteratorT
105  >
106  HIPCUB_RUNTIME_FUNCTION static
107  hipError_t Min(void * d_temp_storage,
108  size_t& temp_storage_bytes,
109  InputIteratorT d_in,
110  OutputIteratorT d_out,
111  int num_segments,
112  OffsetIteratorT d_begin_offsets,
113  OffsetIteratorT d_end_offsets,
114  hipStream_t stream = 0,
115  bool debug_synchronous = false)
116  {
117  (void)debug_synchronous;
118  return hipCUDAErrorTohipError(::cub::DeviceSegmentedReduce::Min(d_temp_storage,
119  temp_storage_bytes,
120  d_in,
121  d_out,
122  num_segments,
123  d_begin_offsets,
124  d_end_offsets,
125  stream));
126  }
127 
128  template<
129  typename InputIteratorT,
130  typename OutputIteratorT,
131  typename OffsetIteratorT
132  >
133  HIPCUB_RUNTIME_FUNCTION static
134  hipError_t ArgMin(void * d_temp_storage,
135  size_t& temp_storage_bytes,
136  InputIteratorT d_in,
137  OutputIteratorT d_out,
138  int num_segments,
139  OffsetIteratorT d_begin_offsets,
140  OffsetIteratorT d_end_offsets,
141  hipStream_t stream = 0,
142  bool debug_synchronous = false)
143  {
144  (void)debug_synchronous;
145  return hipCUDAErrorTohipError(::cub::DeviceSegmentedReduce::ArgMin(d_temp_storage,
146  temp_storage_bytes,
147  d_in,
148  d_out,
149  num_segments,
150  d_begin_offsets,
151  d_end_offsets,
152  stream));
153  }
154 
155  template<
156  typename InputIteratorT,
157  typename OutputIteratorT,
158  typename OffsetIteratorT
159  >
160  HIPCUB_RUNTIME_FUNCTION static
161  hipError_t Max(void * d_temp_storage,
162  size_t& temp_storage_bytes,
163  InputIteratorT d_in,
164  OutputIteratorT d_out,
165  int num_segments,
166  OffsetIteratorT d_begin_offsets,
167  OffsetIteratorT d_end_offsets,
168  hipStream_t stream = 0,
169  bool debug_synchronous = false)
170  {
171  (void)debug_synchronous;
172  return hipCUDAErrorTohipError(::cub::DeviceSegmentedReduce::Max(d_temp_storage,
173  temp_storage_bytes,
174  d_in,
175  d_out,
176  num_segments,
177  d_begin_offsets,
178  d_end_offsets,
179  stream));
180  }
181 
182  template<
183  typename InputIteratorT,
184  typename OutputIteratorT,
185  typename OffsetIteratorT
186  >
187  HIPCUB_RUNTIME_FUNCTION static
188  hipError_t ArgMax(void * d_temp_storage,
189  size_t& temp_storage_bytes,
190  InputIteratorT d_in,
191  OutputIteratorT d_out,
192  int num_segments,
193  OffsetIteratorT d_begin_offsets,
194  OffsetIteratorT d_end_offsets,
195  hipStream_t stream = 0,
196  bool debug_synchronous = false)
197  {
198  (void)debug_synchronous;
199  return hipCUDAErrorTohipError(::cub::DeviceSegmentedReduce::ArgMax(d_temp_storage,
200  temp_storage_bytes,
201  d_in,
202  d_out,
203  num_segments,
204  d_begin_offsets,
205  d_end_offsets,
206  stream));
207  }
208 };
209 
210 END_HIPCUB_NAMESPACE
211 
212 #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