Bolt  1.1
C++ template library with support for OpenCL
Functions
CL-reduce_by_key

Functions

template<typename InputIterator1 , typename InputIterator2 , typename OutputIterator1 , typename OutputIterator2 >
pair< OutputIterator1,
OutputIterator2 > 
bolt::cl::reduce_by_key (control &ctl, InputIterator1 keys_first, InputIterator1 keys_last, InputIterator2 values_first, OutputIterator1 keys_output, OutputIterator2 values_output, const std::string &user_code="")
 reduce_by_key performs, on a sequence, a reduction of each sub-sequence as defined by equivalent keys; the BinaryFunction in this version is plus(), and the BinaryPredicate is equal_to().
 
template<typename InputIterator1 , typename InputIterator2 , typename OutputIterator1 , typename OutputIterator2 >
pair< OutputIterator1,
OutputIterator2 > 
bolt::cl::reduce_by_key (InputIterator1 keys_first, InputIterator1 keys_last, InputIterator2 values_first, OutputIterator1 keys_output, OutputIterator2 values_output, const std::string &user_code="")
 
template<typename InputIterator1 , typename InputIterator2 , typename OutputIterator1 , typename OutputIterator2 , typename BinaryPredicate >
pair< OutputIterator1,
OutputIterator2 > 
bolt::cl::reduce_by_key (control &ctl, InputIterator1 keys_first, InputIterator1 keys_last, InputIterator2 values_first, OutputIterator1 keys_output, OutputIterator2 values_output, BinaryPredicate binary_pred, const std::string &user_code="")
 reduce_by_key performs, on a sequence, a reduction of each sub-sequence as defined by equivalent keys; the BinaryFunction in this version is plus().
 
template<typename InputIterator1 , typename InputIterator2 , typename OutputIterator1 , typename OutputIterator2 , typename BinaryPredicate >
pair< OutputIterator1,
OutputIterator2 > 
bolt::cl::reduce_by_key (InputIterator1 keys_first, InputIterator1 keys_last, InputIterator2 values_first, OutputIterator1 keys_output, OutputIterator2 values_output, BinaryPredicate binary_pred, const std::string &user_code="")
 
template<typename InputIterator1 , typename InputIterator2 , typename OutputIterator1 , typename OutputIterator2 , typename BinaryPredicate , typename BinaryFunction >
pair< OutputIterator1,
OutputIterator2 > 
bolt::cl::reduce_by_key (control &ctl, InputIterator1 keys_first, InputIterator1 keys_last, InputIterator2 values_first, OutputIterator1 keys_output, OutputIterator2 values_output, BinaryPredicate binary_pred, BinaryFunction binary_op, const std::string &user_code="")
 reduce_by_key performs, on a sequence, a reduction of each sub-sequence as defined by equivalent keys;
 
template<typename InputIterator1 , typename InputIterator2 , typename OutputIterator1 , typename OutputIterator2 , typename BinaryPredicate , typename BinaryFunction >
pair< OutputIterator1,
OutputIterator2 > 
bolt::cl::reduce_by_key (InputIterator1 keys_first, InputIterator1 keys_last, InputIterator2 values_first, OutputIterator1 keys_output, OutputIterator2 values_output, BinaryPredicate binary_pred, BinaryFunction binary_op, const std::string &user_code="")
 

Detailed Description

Function Documentation

template<typename InputIterator1 , typename InputIterator2 , typename OutputIterator1 , typename OutputIterator2 >
bolt::cl::pair< OutputIterator1, OutputIterator2 > bolt::cl::reduce_by_key ( control &  ctl,
InputIterator1  keys_first,
InputIterator1  keys_last,
InputIterator2  values_first,
OutputIterator1  keys_output,
OutputIterator2  values_output,
const std::string &  user_code = "" 
)

reduce_by_key performs, on a sequence, a reduction of each sub-sequence as defined by equivalent keys; the BinaryFunction in this version is plus(), and the BinaryPredicate is equal_to().

Parameters
ctlOptional Control structure to control command-queue, debug, tuning, etc. See bolt::cl::control.
keys_firstThe first element of the key sequence.
keys_lastThe last element of the key sequence.
values_firstThe first element of the value sequence.
keys_outputThe first element of the key output sequence.
values_outputThe first element of the value output sequence.
user_codeA user-specified Optional string that is preppended to the generated OpenCL kernel.
Template Parameters
InputIterator1is a model of Input Iterator.
InputIterator2is a model of Input Iterator.
OutputIteratoris a model of Output Iterator.
Returns
result+(last1-first1).

Example:

...
int keys[11] = { 0, 0, 0, 2, 2, 2, -5, -5, -5, -5, 6 };
int vals[11] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 };
int keys_out[11];
int vals_out[11];
bolt::cl::reduce_by_key( ctl, keys, keys+11, vals, keys_out, vals_out );
// keys_out => { 0, 2, -5, 6 }
// vals_out => { 6, 6, 8, 2 }
template<typename InputIterator1 , typename InputIterator2 , typename OutputIterator1 , typename OutputIterator2 , typename BinaryPredicate >
bolt::cl::pair< OutputIterator1, OutputIterator2 > bolt::cl::reduce_by_key ( control &  ctl,
InputIterator1  keys_first,
InputIterator1  keys_last,
InputIterator2  values_first,
OutputIterator1  keys_output,
OutputIterator2  values_output,
BinaryPredicate  binary_pred,
const std::string &  user_code = "" 
)

reduce_by_key performs, on a sequence, a reduction of each sub-sequence as defined by equivalent keys; the BinaryFunction in this version is plus().

Parameters
ctlOptional Control structure to control command-queue, debug, tuning, etc. See bolt::cl::control.
keys_firstThe first element of the key sequence.
keys_lastThe last element of the key sequence.
values_firstThe first element of the value sequence.
keys_outputThe first element of the key output sequence.
values_outputThe first element of the value output sequence.
binary_predBinary predicate which determines if two keys are equal.
user_codeA user-specified Optional string that is preppended to the generated OpenCL kernel.
Template Parameters
InputIterator1is a model of Input Iterator.
InputIterator2is a model of Input Iterator.
OutputIteratoris a model of Output Iterator.
BinaryPredicateis a model of Binary Predicate.
Returns
pair(last of keys output, last of value output)

Example:

...
int keys[11] = { 0, 0, 0, 2, 2, 2, -5, -5, -5, -5, 6 };
int vals[11] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 };
int keys_out[11];
int vals_out[11];
bolt::cl::equal_to<int> eq;
bolt::cl::reduce_by_key( ctl, keys, keys+11, vals, keys_out, vals_out, eq );
// keys_out => { 0, 2, -5, 6 }
// vals_out => { 6, 6, 8, 2 }
template<typename InputIterator1 , typename InputIterator2 , typename OutputIterator1 , typename OutputIterator2 , typename BinaryPredicate , typename BinaryFunction >
bolt::cl::pair< OutputIterator1, OutputIterator2 > bolt::cl::reduce_by_key ( control &  ctl,
InputIterator1  keys_first,
InputIterator1  keys_last,
InputIterator2  values_first,
OutputIterator1  keys_output,
OutputIterator2  values_output,
BinaryPredicate  binary_pred,
BinaryFunction  binary_op,
const std::string &  user_code = "" 
)

reduce_by_key performs, on a sequence, a reduction of each sub-sequence as defined by equivalent keys;

Parameters
ctlOptional Control structure to control command-queue, debug, tuning, etc. See bolt::cl::control.
keys_firstThe first element of the key sequence.
keys_lastThe last element of the key sequence.
values_firstThe first element of the value sequence.
keys_outputThe first element of the key output sequence.
values_outputThe first element of the value output sequence.
binary_predBinary predicate which determines if two keys are equal.
binary_opBinary function for scanning transformed elements.
user_codeA user-specified Optional tring that is preppended to the generated OpenCL kernel.
Template Parameters
InputIterator1is a model of Input Iterator.
InputIterator2is a model of Input Iterator.
OutputIteratoris a model of Output Iterator.
BinaryPredicateis a model of Binary Predicate.
BinaryFunctionis a model of Binary Function whose return type is convertible to OutputIterator's value_type.
Returns
pair(last of keys output, last of value output)

Example:

...
int keys[11] = { 0, 0, 0, 2, 2, 2, -5, -5, -5, -5, 6 };
int vals[11] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 };
int keys_out[11];
int vals_out[11];
bolt::cl::reduce_by_key( ctl, keys, keys+11, vals, keys_out, vals_out,bolt::cl::equal_to<int>(),
bolt::cl::plus<int>() );
// keys_out => { 0, 2, -5, 6 }
// vals_out => { 6, 6, 8, 2 }