template<typename InputIterator , typename UnaryFunction , typename T , typename BinaryFunction >
T bolt::cl::transform_reduce |
( |
control & |
ctl, |
|
|
InputIterator |
first, |
|
|
InputIterator |
last, |
|
|
UnaryFunction |
transform_op, |
|
|
T |
init, |
|
|
BinaryFunction |
reduce_op, |
|
|
const std::string & |
user_code = "" |
|
) |
| |
transform_reduce
fuses transform and reduce operations together, increasing performance by reducing memory passes.
Logically, a transform operation is performed over the input sequence using the unary function and stored into a temporary sequence; then, a reduction operation is applied using the binary function to return a single value.
- Parameters
-
ctl | Optional Control structure to control command-queue, debug, tuning, etc.See bolt::cl::control. |
first | The beginning of the input sequence. |
last | The end of the input sequence. |
transform_op | A unary tranformation operation. |
init | The initial value for the accumulator. |
reduce_op | The binary operation used to combine two values. By default, the binary operation is plus<>(). |
user_code | Optional OpenCL™ code to be passed to the OpenCL compiler. The cl_code is inserted first in the generated code, before the cl_code trait. |
- Returns
- The result of the combined transform and reduction.
- Template Parameters
-
T | The type of the result. |
InputIterator | is a model of an InputIterator. and InputIterator's value_type is convertible to BinaryFunction's first_argument_type . |
UnaryFunction | is a model of Unary Function. and UnaryFunction's result_type is convertible to InputIterator's value_type . |
BinaryFunction | is a model of Binary Function. and BinaryFunction's result_type is convertible to InputIterator's value_type . |
int input[10] = {-5, 0, 2, 3, 2, 4, -2, 1, 2, 3};
int output;
- See Also
- http://www.sgi.com/tech/stl/InputIterator.html
-
http://www.sgi.com/tech/stl/OutputIterator.html
-
http://www.sgi.com/tech/stl/UnaryFunction.html
-
http://www.sgi.com/tech/stl/BinaryFunction.html