CUB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups
device_partition.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 
74 {
121  template <
122  typename InputIterator,
123  typename FlagIterator,
124  typename OutputIterator,
125  typename NumSelectedIterator>
126  CUB_RUNTIME_FUNCTION __forceinline__
127  static cudaError_t Flagged(
128  void *d_temp_storage,
129  size_t &temp_storage_bytes,
130  InputIterator d_in,
131  FlagIterator d_flags,
132  OutputIterator d_out,
133  NumSelectedIterator d_num_selected,
134  int num_items,
135  cudaStream_t stream = 0,
136  bool debug_synchronous = false)
137  {
138  typedef int Offset; // Signed integer type for global offsets
139  typedef NullType SelectOp; // Selection op (not used)
140  typedef NullType EqualityOp; // Equality operator (not used)
141 
142  return DeviceSelectDispatch<InputIterator, FlagIterator, OutputIterator, NumSelectedIterator, SelectOp, EqualityOp, Offset, true>::Dispatch(
143  d_temp_storage,
144  temp_storage_bytes,
145  d_in,
146  d_flags,
147  d_out,
148  d_num_selected,
149  SelectOp(),
150  EqualityOp(),
151  num_items,
152  stream,
153  debug_synchronous);
154  }
155 
156 
230  template <
231  typename InputIterator,
232  typename OutputIterator,
233  typename NumSelectedIterator,
234  typename SelectOp>
235  CUB_RUNTIME_FUNCTION __forceinline__
236  static cudaError_t If(
237  void *d_temp_storage,
238  size_t &temp_storage_bytes,
239  InputIterator d_in,
240  OutputIterator d_out,
241  NumSelectedIterator d_num_selected,
242  int num_items,
243  SelectOp select_op,
244  cudaStream_t stream = 0,
245  bool debug_synchronous = false)
246  {
247  typedef int Offset; // Signed integer type for global offsets
248  typedef NullType* FlagIterator; // Flag iterator type (not used)
249  typedef NullType EqualityOp; // Equality operator (not used)
250 
251  return DeviceSelectDispatch<InputIterator, FlagIterator, OutputIterator, NumSelectedIterator, SelectOp, EqualityOp, Offset, true>::Dispatch(
252  d_temp_storage,
253  temp_storage_bytes,
254  d_in,
255  NULL,
256  d_out,
257  d_num_selected,
258  select_op,
259  EqualityOp(),
260  num_items,
261  stream,
262  debug_synchronous);
263  }
264 
265 };
266 
272 } // CUB namespace
273 CUB_NS_POSTFIX // Optional outer namespace(s)
274 
275