/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-hipcub/checkouts/docs-5.2.3/hipcub/include/hipcub/backend/rocprim/device/device_histogram.hpp Source File

/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-hipcub/checkouts/docs-5.2.3/hipcub/include/hipcub/backend/rocprim/device/device_histogram.hpp Source File#

hipCUB: /home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-hipcub/checkouts/docs-5.2.3/hipcub/include/hipcub/backend/rocprim/device/device_histogram.hpp Source File
device_histogram.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_ROCPRIM_DEVICE_DEVICE_HISTOGRAM_HPP_
31 #define HIPCUB_ROCPRIM_DEVICE_DEVICE_HISTOGRAM_HPP_
32 
33 #include "../../../config.hpp"
34 
35 #include "../util_type.hpp"
36 
37 #include <rocprim/device/device_histogram.hpp>
38 
39 BEGIN_HIPCUB_NAMESPACE
40 
41 struct DeviceHistogram
42 {
43  template<
44  typename SampleIteratorT,
45  typename CounterT,
46  typename LevelT,
47  typename OffsetT
48  >
49  HIPCUB_RUNTIME_FUNCTION static
50  hipError_t HistogramEven(void * d_temp_storage,
51  size_t& temp_storage_bytes,
52  SampleIteratorT d_samples,
53  CounterT * d_histogram,
54  int num_levels,
55  LevelT lower_level,
56  LevelT upper_level,
57  OffsetT num_samples,
58  hipStream_t stream = 0,
59  bool debug_synchronous = false)
60  {
61  return ::rocprim::histogram_even(
62  d_temp_storage, temp_storage_bytes,
63  d_samples, num_samples,
64  d_histogram,
65  num_levels, lower_level, upper_level,
66  stream, debug_synchronous
67  );
68  }
69 
70  template<
71  typename SampleIteratorT,
72  typename CounterT,
73  typename LevelT,
74  typename OffsetT
75  >
76  HIPCUB_RUNTIME_FUNCTION static
77  hipError_t HistogramEven(void * d_temp_storage,
78  size_t& temp_storage_bytes,
79  SampleIteratorT d_samples,
80  CounterT * d_histogram,
81  int num_levels,
82  LevelT lower_level,
83  LevelT upper_level,
84  OffsetT num_row_samples,
85  OffsetT num_rows,
86  size_t row_stride_bytes,
87  hipStream_t stream = 0,
88  bool debug_synchronous = false)
89  {
90  return ::rocprim::histogram_even(
91  d_temp_storage, temp_storage_bytes,
92  d_samples, num_row_samples, num_rows, row_stride_bytes,
93  d_histogram,
94  num_levels, lower_level, upper_level,
95  stream, debug_synchronous
96  );
97  }
98 
99  template<
100  int NUM_CHANNELS,
101  int NUM_ACTIVE_CHANNELS,
102  typename SampleIteratorT,
103  typename CounterT,
104  typename LevelT,
105  typename OffsetT
106  >
107  HIPCUB_RUNTIME_FUNCTION static
108  hipError_t MultiHistogramEven(void * d_temp_storage,
109  size_t& temp_storage_bytes,
110  SampleIteratorT d_samples,
111  CounterT * d_histogram[NUM_ACTIVE_CHANNELS],
112  int num_levels[NUM_ACTIVE_CHANNELS],
113  LevelT lower_level[NUM_ACTIVE_CHANNELS],
114  LevelT upper_level[NUM_ACTIVE_CHANNELS],
115  OffsetT num_pixels,
116  hipStream_t stream = 0,
117  bool debug_synchronous = false)
118  {
119  unsigned int levels[NUM_ACTIVE_CHANNELS];
120  for(unsigned int channel = 0; channel < NUM_ACTIVE_CHANNELS; channel++)
121  {
122  levels[channel] = num_levels[channel];
123  }
124  return ::rocprim::multi_histogram_even<NUM_CHANNELS, NUM_ACTIVE_CHANNELS>(
125  d_temp_storage, temp_storage_bytes,
126  d_samples, num_pixels,
127  d_histogram,
128  levels, lower_level, upper_level,
129  stream, debug_synchronous
130  );
131  }
132 
133  template<
134  int NUM_CHANNELS,
135  int NUM_ACTIVE_CHANNELS,
136  typename SampleIteratorT,
137  typename CounterT,
138  typename LevelT,
139  typename OffsetT
140  >
141  HIPCUB_RUNTIME_FUNCTION static
142  hipError_t MultiHistogramEven(void * d_temp_storage,
143  size_t& temp_storage_bytes,
144  SampleIteratorT d_samples,
145  CounterT * d_histogram[NUM_ACTIVE_CHANNELS],
146  int num_levels[NUM_ACTIVE_CHANNELS],
147  LevelT lower_level[NUM_ACTIVE_CHANNELS],
148  LevelT upper_level[NUM_ACTIVE_CHANNELS],
149  OffsetT num_row_pixels,
150  OffsetT num_rows,
151  size_t row_stride_bytes,
152  hipStream_t stream = 0,
153  bool debug_synchronous = false)
154  {
155  unsigned int levels[NUM_ACTIVE_CHANNELS];
156  for(unsigned int channel = 0; channel < NUM_ACTIVE_CHANNELS; channel++)
157  {
158  levels[channel] = num_levels[channel];
159  }
160  return ::rocprim::multi_histogram_even<NUM_CHANNELS, NUM_ACTIVE_CHANNELS>(
161  d_temp_storage, temp_storage_bytes,
162  d_samples, num_row_pixels, num_rows, row_stride_bytes,
163  d_histogram,
164  levels, lower_level, upper_level,
165  stream, debug_synchronous
166  );
167  }
168 
169  template<
170  typename SampleIteratorT,
171  typename CounterT,
172  typename LevelT,
173  typename OffsetT
174  >
175  HIPCUB_RUNTIME_FUNCTION static
176  hipError_t HistogramRange(void * d_temp_storage,
177  size_t& temp_storage_bytes,
178  SampleIteratorT d_samples,
179  CounterT * d_histogram,
180  int num_levels,
181  LevelT * d_levels,
182  OffsetT num_samples,
183  hipStream_t stream = 0,
184  bool debug_synchronous = false)
185  {
186  return ::rocprim::histogram_range(
187  d_temp_storage, temp_storage_bytes,
188  d_samples, num_samples,
189  d_histogram,
190  num_levels, d_levels,
191  stream, debug_synchronous
192  );
193  }
194 
195  template<
196  typename SampleIteratorT,
197  typename CounterT,
198  typename LevelT,
199  typename OffsetT
200  >
201  HIPCUB_RUNTIME_FUNCTION static
202  hipError_t HistogramRange(void * d_temp_storage,
203  size_t& temp_storage_bytes,
204  SampleIteratorT d_samples,
205  CounterT * d_histogram,
206  int num_levels,
207  LevelT * d_levels,
208  OffsetT num_row_samples,
209  OffsetT num_rows,
210  size_t row_stride_bytes,
211  hipStream_t stream = 0,
212  bool debug_synchronous = false)
213  {
214  return ::rocprim::histogram_range(
215  d_temp_storage, temp_storage_bytes,
216  d_samples, num_row_samples, num_rows, row_stride_bytes,
217  d_histogram,
218  num_levels, d_levels,
219  stream, debug_synchronous
220  );
221  }
222 
223  template<
224  int NUM_CHANNELS,
225  int NUM_ACTIVE_CHANNELS,
226  typename SampleIteratorT,
227  typename CounterT,
228  typename LevelT,
229  typename OffsetT
230  >
231  HIPCUB_RUNTIME_FUNCTION static
232  hipError_t MultiHistogramRange(void * d_temp_storage,
233  size_t& temp_storage_bytes,
234  SampleIteratorT d_samples,
235  CounterT * d_histogram[NUM_ACTIVE_CHANNELS],
236  int num_levels[NUM_ACTIVE_CHANNELS],
237  LevelT * d_levels[NUM_ACTIVE_CHANNELS],
238  OffsetT num_pixels,
239  hipStream_t stream = 0,
240  bool debug_synchronous = false)
241  {
242  unsigned int levels[NUM_ACTIVE_CHANNELS];
243  for(unsigned int channel = 0; channel < NUM_ACTIVE_CHANNELS; channel++)
244  {
245  levels[channel] = num_levels[channel];
246  }
247  return ::rocprim::multi_histogram_range<NUM_CHANNELS, NUM_ACTIVE_CHANNELS>(
248  d_temp_storage, temp_storage_bytes,
249  d_samples, num_pixels,
250  d_histogram,
251  levels, d_levels,
252  stream, debug_synchronous
253  );
254  }
255 
256  template<
257  int NUM_CHANNELS,
258  int NUM_ACTIVE_CHANNELS,
259  typename SampleIteratorT,
260  typename CounterT,
261  typename LevelT,
262  typename OffsetT
263  >
264  HIPCUB_RUNTIME_FUNCTION static
265  hipError_t MultiHistogramRange(void * d_temp_storage,
266  size_t& temp_storage_bytes,
267  SampleIteratorT d_samples,
268  CounterT * d_histogram[NUM_ACTIVE_CHANNELS],
269  int num_levels[NUM_ACTIVE_CHANNELS],
270  LevelT * d_levels[NUM_ACTIVE_CHANNELS],
271  OffsetT num_row_pixels,
272  OffsetT num_rows,
273  size_t row_stride_bytes,
274  hipStream_t stream = 0,
275  bool debug_synchronous = false)
276  {
277  unsigned int levels[NUM_ACTIVE_CHANNELS];
278  for(unsigned int channel = 0; channel < NUM_ACTIVE_CHANNELS; channel++)
279  {
280  levels[channel] = num_levels[channel];
281  }
282  return ::rocprim::multi_histogram_range<NUM_CHANNELS, NUM_ACTIVE_CHANNELS>(
283  d_temp_storage, temp_storage_bytes,
284  d_samples, num_row_pixels, num_rows, row_stride_bytes,
285  d_histogram,
286  levels, d_levels,
287  stream, debug_synchronous
288  );
289  }
290 };
291 
292 END_HIPCUB_NAMESPACE
293 
294 #endif // HIPCUB_ROCPRIM_DEVICE_DEVICE_HISTOGRAM_HPP_