cub::DeviceFind#
-
struct DeviceFind#
Public Static Functions
-
template<typename InputIteratorT, typename OutputIteratorT, typename ScanOpT, typename NumItemsT>
static inline cudaError_t FindIf( - void *d_temp_storage,
- size_t &temp_storage_bytes,
- InputIteratorT d_in,
- OutputIteratorT d_out,
- ScanOpT scan_op,
- NumItemsT num_items,
- cudaStream_t stream = 0
Finds the first element in the input sequence that satisfies the given predicate.
The search terminates at the first element where the predicate evaluates to true.
The index of the found element is written to
d_out.If no element satisfies the predicate,
num_itemsis written tod_out.The range
[d_out, d_out + 1)shall not overlap[d_in, d_in + num_items)in any way.When
d_temp_storageisnullptr, no work is done and the required allocation size is returned intemp_storage_bytes. See Determining Temporary Storage Requirements for usage guidance.
Snippet#
The code snippet below illustrates the finding of the first element that satisfies the predicate.
- Template Parameters:
InputIteratorT – [inferred] Random-access input iterator type for reading input items (may be a simple pointer type)
OutputIteratorT – [inferred] Random-access output iterator type for writing the result index (may be a simple pointer type)
ScanOpT – [inferred] Unary predicate functor type having member
bool operator()(const T &a)NumItemsT – [inferred] An integral type representing the number of input elements
- Parameters:
d_temp_storage – [in] Device-accessible allocation of temporary storage. When
nullptr, the required allocation size is written totemp_storage_bytesand no work is done.temp_storage_bytes – [inout] Reference to size in bytes of
d_temp_storageallocationd_in – [in] Random-access iterator to the input sequence of data items
d_out – [out] Random-access iterator to the output location for the index of the found element
scan_op – [in] Unary predicate functor for determining whether an element satisfies the search condition
num_items – [in] Total number of input items (i.e., the length of
d_in)stream – [in]
[optional] CUDA stream to launch kernels within. Default is stream0.
-
template<typename InputIteratorT, typename OutputIteratorT, typename ScanOpT, typename NumItemsT>