Bolt
1.1
C++ template library with support for OpenCL
|
Functions | |
template<typename InputIterator > | |
std::iterator_traits < InputIterator >::value_type | bolt::amp::reduce (bolt::amp::control &ctl, InputIterator first, InputIterator last) |
reduce returns the result of combining all the elements in the specified range using the specified binary_op. The classic example is a summation, where the binary_op is the plus operator. By default, the initial value is "0" and the binary operator is "plus<>()". | |
template<typename InputIterator > | |
std::iterator_traits < InputIterator >::value_type | bolt::amp::reduce (InputIterator first, InputIterator last) |
template<typename InputIterator , typename T > | |
T | bolt::amp::reduce (bolt::amp::control &ctl, InputIterator first, InputIterator last, T init) |
reduce returns the result of combining all the elements in the specified range using the specified binary_op. The classic example is a summation, where the binary_op is the plus operator. By default, the initial value is "0" and the binary operator is "plus<>()". | |
template<typename InputIterator , typename T > | |
T | bolt::amp::reduce (InputIterator first, InputIterator last, T init) |
template<typename InputIterator , typename T , typename BinaryFunction > | |
T | bolt::amp::reduce (bolt::amp::control &ctl, InputIterator first, InputIterator last, T init, BinaryFunction binary_op=bolt::amp::plus< T >()) |
reduce returns the result of combining all the elements in the specified range using the specified binary_op. The classic example is a summation, where the binary_op is the plus operator. By default, the binary operator is "plus<>()". The version takes a bolt::amp::control structure as a first argument. | |
template<typename InputIterator , typename T , typename BinaryFunction > | |
T | bolt::amp::reduce (InputIterator first, InputIterator last, T init, BinaryFunction binary_op) |
std::iterator_traits< InputIterator >::value_type bolt::amp::reduce | ( | bolt::amp::control & | ctl, |
InputIterator | first, | ||
InputIterator | last | ||
) |
reduce returns the result of combining all the elements in the specified range using the specified binary_op. The classic example is a summation, where the binary_op is the plus operator. By default, the initial value is "0" and the binary operator is "plus<>()".
reduce
requires that the binary reduction op ("binary_op") is cummutative. The order in which reduce
applies the binary_op is not deterministic.
The reduce
operation is similar the std::accumulate function
ctl | Optional Control structure to control accelerator,debug, tuning. See bolt::amp::control. |
first | The first position in the sequence to be reduced. |
last | The last position in the sequence to be reduced. the generated code, before the cl_code trait. |
InputIterator | An iterator that can be dereferenced for an object, and can be incremented to get to the next element in a sequence. |
T | The type of the result. |
The following code example shows the use of reduce
to sum 10 numbers, using the default plus operator.
T bolt::amp::reduce | ( | bolt::amp::control & | ctl, |
InputIterator | first, | ||
InputIterator | last, | ||
T | init | ||
) |
reduce
returns the result of combining all the elements in the specified range using the specified binary_op. The classic example is a summation, where the binary_op is the plus operator. By default, the initial value is "0" and the binary operator is "plus<>()".
reduce
requires that the binary reduction op ("binary_op") is cummutative. The order in which reduce
applies the binary_op is not deterministic.
The reduce
operation is similar the std::accumulate function
ctl | Optional Control structure to control accelerator,debug, tuning. See bolt::amp::control. |
first | The first position in the sequence to be reduced. |
last | The last position in the sequence to be reduced. |
init | The initial value for the accumulator. |
InputIterator | An iterator that can be dereferenced for an object, and can be incremented to get to the next element in a sequence. |
T | The type of the result. |
The following code example shows the use of reduce
to sum 10 numbers, using the default plus operator.
T bolt::amp::reduce | ( | bolt::amp::control & | ctl, |
InputIterator | first, | ||
InputIterator | last, | ||
T | init, | ||
BinaryFunction | binary_op = bolt::amp::plus<T>() |
||
) |
reduce returns the result of combining all the elements in the specified range using the specified binary_op. The classic example is a summation, where the binary_op is the plus operator. By default, the binary operator is "plus<>()". The version takes a bolt::amp::control structure as a first argument.
reduce
requires that the binary reduction op ("binary_op") is cummutative. The order in which reduce
applies the binary_op is not deterministic.
The reduce
operation is similar the std::accumulate function.
ctl | Optional Control structure to control accelerator,debug, tuning. See bolt::amp::control. |
first | The first position in the sequence to be reduced. |
last | The last position in the sequence to be reduced. |
init | The initial value for the accumulator. |
binary_op | The binary operation used to combine two values. By default, the binary operation is plus<>(). |
InputIterator | An iterator that can be dereferenced for an object, and can be incremented to get to the next element in a sequence. |
BinaryFunction | A function object defining an operation that is applied to consecutive elements in the sequence. |
The following code example shows the use of reduce
to find the max of 10 numbers, specifying a specific accelerator.