CUB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups
device_select.cuh
Go to the documentation of this file.
1 
2 /******************************************************************************
3  * Copyright (c) 2011, Duane Merrill. All rights reserved.
4  * Copyright (c) 2011-2014, NVIDIA CORPORATION. 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 
35 #pragma once
36 
37 #include <stdio.h>
38 #include <iterator>
39 
40 #include "dispatch/device_select_dispatch.cuh"
41 #include "../util_namespace.cuh"
42 
44 CUB_NS_PREFIX
45 
47 namespace cub {
48 
49 
83 {
128  template <
129  typename InputIterator,
130  typename FlagIterator,
131  typename OutputIterator,
132  typename NumSelectedIterator>
133  CUB_RUNTIME_FUNCTION __forceinline__
134  static cudaError_t Flagged(
135  void *d_temp_storage,
136  size_t &temp_storage_bytes,
137  InputIterator d_in,
138  FlagIterator d_flags,
139  OutputIterator d_out,
140  NumSelectedIterator d_num_selected,
141  int num_items,
142  cudaStream_t stream = 0,
143  bool debug_synchronous = false)
144  {
145  typedef int Offset; // Signed integer type for global offsets
146  typedef NullType SelectOp; // Selection op (not used)
147  typedef NullType EqualityOp; // Equality operator (not used)
148 
149  return DeviceSelectDispatch<InputIterator, FlagIterator, OutputIterator, NumSelectedIterator, SelectOp, EqualityOp, Offset, false>::Dispatch(
150  d_temp_storage,
151  temp_storage_bytes,
152  d_in,
153  d_flags,
154  d_out,
155  d_num_selected,
156  SelectOp(),
157  EqualityOp(),
158  num_items,
159  stream,
160  debug_synchronous);
161  }
162 
163 
235  template <
236  typename InputIterator,
237  typename OutputIterator,
238  typename NumSelectedIterator,
239  typename SelectOp>
240  CUB_RUNTIME_FUNCTION __forceinline__
241  static cudaError_t If(
242  void *d_temp_storage,
243  size_t &temp_storage_bytes,
244  InputIterator d_in,
245  OutputIterator d_out,
246  NumSelectedIterator d_num_selected,
247  int num_items,
248  SelectOp select_op,
249  cudaStream_t stream = 0,
250  bool debug_synchronous = false)
251  {
252  typedef int Offset; // Signed integer type for global offsets
253  typedef NullType* FlagIterator; // Flag iterator type (not used)
254  typedef NullType EqualityOp; // Equality operator (not used)
255 
256  return DeviceSelectDispatch<InputIterator, FlagIterator, OutputIterator, NumSelectedIterator, SelectOp, EqualityOp, Offset, false>::Dispatch(
257  d_temp_storage,
258  temp_storage_bytes,
259  d_in,
260  NULL,
261  d_out,
262  d_num_selected,
263  select_op,
264  EqualityOp(),
265  num_items,
266  stream,
267  debug_synchronous);
268  }
269 
270 
327  template <
328  typename InputIterator,
329  typename OutputIterator,
330  typename NumSelectedIterator>
331  CUB_RUNTIME_FUNCTION __forceinline__
332  static cudaError_t Unique(
333  void *d_temp_storage,
334  size_t &temp_storage_bytes,
335  InputIterator d_in,
336  OutputIterator d_out,
337  NumSelectedIterator d_num_selected,
338  int num_items,
339  cudaStream_t stream = 0,
340  bool debug_synchronous = false)
341  {
342  typedef int Offset; // Signed integer type for global offsets
343  typedef NullType* FlagIterator; // Flag iterator type (not used)
344  typedef NullType SelectOp; // Selection op (not used)
345  typedef Equality EqualityOp; // Default == operator
346 
347  return DeviceSelectDispatch<InputIterator, FlagIterator, OutputIterator, NumSelectedIterator, SelectOp, EqualityOp, Offset, false>::Dispatch(
348  d_temp_storage,
349  temp_storage_bytes,
350  d_in,
351  NULL,
352  d_out,
353  d_num_selected,
354  SelectOp(),
355  EqualityOp(),
356  num_items,
357  stream,
358  debug_synchronous);
359  }
360 
361 };
362 
369 } // CUB namespace
370 CUB_NS_POSTFIX // Optional outer namespace(s)
371 
372