Reduce#

group thread_reduce

Functions

template<int LENGTH, typename T, typename ReductionOp, bool NoPrefix = false>
__device__ inline T thread_reduce(T *input, ReductionOp reduction_op, T prefix = T(0))#

Carry out a reduction on an array of elements in one thread.

Template Parameters:
  • LENGTH – Length of the array to be reduced

  • T – the input/output type

  • ReductionOp – Binary Operation that used to carry out the reduction

  • NoPrefix – Boolean, determining whether to have a initialization value for the reduction accumulator

Parameters:
  • input – [in] Pointer to the first element of the array to be reduced

  • reduction_op – [in] Instance of the reduction operator functor

  • prefix – [in] Value to be used as prefix, if NoPrefix is false

Returns:

Value obtained from reduction of input array

template<int LENGTH, typename T, typename ReductionOp>
__device__ inline T thread_reduce(T (&input)[LENGTH], ReductionOp reduction_op, T prefix)#

Carry out a reduction on an array of elements in one thread.

Template Parameters:
  • LENGTH – Length of the array to be reduced

  • T – the input/output type

  • ReductionOp – Binary Operation that used to carry out the reduction

Parameters:
  • input – [in] Pointer to the first element of the array to be reduced

  • reduction_op – [in] Instance of the reduction operator functor

  • prefix – [in] Value to be used as prefix

Returns:

Value obtained from reduction of input array

template<int LENGTH, typename T, typename ReductionOp>
__device__ inline T thread_reduce(T (&input)[LENGTH], ReductionOp reduction_op)#

Carry out a reduction on an array of elements in one thread.

Template Parameters:
  • LENGTH – Length of the array to be reduced

  • T – the input/output type

  • ReductionOp – Binary Operation that used to carry out the reduction

Parameters:
  • input – [in] Pointer to the first element of the array to be reduced

  • reduction_op – [in] Instance of the reduction operator functor

Returns:

Value obtained from reduction of input array