transform_reduce_index

transform_reduce_index#

stdgpu: stdgpu::transform_reduce_index
stdgpu Latest
Efficient STL-like Data Structures on the GPU

◆ transform_reduce_index()

template<typename IndexType , typename ExecutionPolicy , typename T , typename BinaryFunction , typename UnaryFunction , STDGPU_DETAIL_OVERLOAD_IF(is_execution_policy_v< remove_cvref_t< ExecutionPolicy > >) >
T stdgpu::transform_reduce_index ( ExecutionPolicy &&  policy,
IndexType  size,
init,
BinaryFunction  reduce,
UnaryFunction  f 
)

Calls the given unary function with an index from the range [0, size) and performs a reduction afterwards.

Template Parameters
IndexTypeThe type of the index values
ExecutionPolicyThe type of the execution policy
TThe type of the reduced value
BinaryFunctionThe type of the binary function for the reduction
UnaryFunctionThe type of the unary function applied before reduction
Parameters
[in]policyThe execution policy, e.g. host or device
[in]sizeThe number of indices, i.e. the upper bound of [0, size)
[in]initThe initial value which also participates in the reduction
[in]reduceThe binary function to reduce the values f(i)
[in]fThe unary function to call with an index i
Returns
The result of the reduction of f(i) over the index range [0, size) along with the initial value