Bolt  1.3
C++ template library with support for OpenCL
Functions
CL-gather

Functions

template<typename InputIterator1 , typename InputIterator2 , typename OutputIterator >
void bolt::cl::gather (::bolt::cl::control &ctl, InputIterator1 map_first, InputIterator1 map_last, InputIterator2 input_first, OutputIterator result, const std::string &user_code="")
 This version of gather copies elements from a source array to a destination range according to a specified map. For each i in InputIterator1 in the range [map_first, map_last), gather copies the corresponding input_first[ map [ i ] ] to result[ i - map_first ].
 
template<typename InputIterator1 , typename InputIterator2 , typename OutputIterator >
void bolt::cl::gather (InputIterator1 map_first, InputIterator1 map_last, InputIterator2 input_first, OutputIterator result, const std::string &user_code="")
 
template<typename InputIterator1 , typename InputIterator2 , typename InputIterator3 , typename OutputIterator >
void bolt::cl::gather_if (bolt::cl::control &ctl, InputIterator1 map_first, InputIterator1 map_last, InputIterator2 stencil, InputIterator3 input_first, OutputIterator result, const std::string &user_code="")
 This version of gather_if copies elements from a source array to a destination range according to a specified map. For each i in InputIterator1 in the range [map_first, map_last), gather_if copies the corresponding input_first[ map [ i ] ] to result[ i - map_first ] if stencil[ i - map_first ] is true.
 
template<typename InputIterator1 , typename InputIterator2 , typename InputIterator3 , typename OutputIterator >
void bolt::cl::gather_if (InputIterator1 map_first, InputIterator1 map_last, InputIterator2 stencil, InputIterator3 input_first, OutputIterator result, const std::string &user_code="")
 
template<typename InputIterator1 , typename InputIterator2 , typename InputIterator3 , typename OutputIterator , typename Predicate >
void bolt::cl::gather_if (bolt::cl::control &ctl, InputIterator1 map_first, InputIterator1 map_last, InputIterator2 stencil, InputIterator3 input, OutputIterator result, Predicate pred, const std::string &user_code="")
 This version of gather_if copies elements from a source array to a destination range according to a specified map. For each i in InputIterator1 in the range [map_first, map_last), gather_if copies the corresponding input_first[ map [ i ] ] to result[ i - map_first ] if pred (stencil[ i - map_first ]) is true.
 
template<typename InputIterator1 , typename InputIterator2 , typename InputIterator3 , typename OutputIterator , typename Predicate >
void bolt::cl::gather_if (InputIterator1 map_first, InputIterator1 map_last, InputIterator2 stencil, InputIterator3 input, OutputIterator result, Predicate pred, const std::string &user_code="")
 

Detailed Description

Function Documentation

template<typename InputIterator1 , typename InputIterator2 , typename OutputIterator >
void bolt::cl::gather ( ::bolt::cl::control ctl,
InputIterator1  map_first,
InputIterator1  map_last,
InputIterator2  input_first,
OutputIterator  result,
const std::string &  user_code = "" 
)

This version of gather copies elements from a source array to a destination range according to a specified map. For each i in InputIterator1 in the range [map_first, map_last), gather copies the corresponding input_first[ map [ i ] ] to result[ i - map_first ].

gather APIs copy elements from a source array to a destination range (conditionally) according to a specified map. For common code between the host and device, one can take a look at the ClCode and TypeName implementations. See Bolt Tools for Split-Source for a detailed description.

Parameters
ctlOptional Control structure to control command-queue, debug, tuning, etc.See bolt::cl::control.
map_firstThe beginning of map sequence.
map_lastThe end of map sequence.
inputThe beginning of the source sequence.
resultThe beginning of the output sequence.
user_codeOptional OpenCL™ code to be passed to the OpenCL compiler. The cl_code is inserted first in the generated code, before the cl_code trait.
Template Parameters
InputIterator1is a model of InputIterator
InputIterator2is a model of InputIterator
OutputIteratoris a model of OutputIterator

The following code snippet demonstrates how to use gather

#include <bolt/cl/gather.h>
int map[10] = {9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
int input[10] = {0, 11, 22, 33, 44, 55, 66, 77, 88, 99};
int output[10];
bolt::cl::gather(map, map + 10, input, output);
// output is now {99, 88, 77, 66, 55, 44, 33, 22, 11, 0};
template<typename InputIterator1 , typename InputIterator2 , typename InputIterator3 , typename OutputIterator >
void bolt::cl::gather_if ( bolt::cl::control ctl,
InputIterator1  map_first,
InputIterator1  map_last,
InputIterator2  stencil,
InputIterator3  input_first,
OutputIterator  result,
const std::string &  user_code = "" 
)

This version of gather_if copies elements from a source array to a destination range according to a specified map. For each i in InputIterator1 in the range [map_first, map_last), gather_if copies the corresponding input_first[ map [ i ] ] to result[ i - map_first ] if stencil[ i - map_first ] is true.

Parameters
ctlOptional Control structure to control command-queue, debug, tuning, etc.See bolt::cl::control.
map_firstThe beginning of map sequence.
map_lastThe end of map sequence.
stencilThe beginning of the stencil sequence.
inputThe beginning of the source sequence.
resultThe beginning of the output sequence.
user_codeOptional OpenCL™ code to be passed to the OpenCL compiler. The cl_code is inserted first in the generated code, before the cl_code trait.
Template Parameters
InputIterator1is a model of InputIterator
InputIterator2is a model of InputIterator
InputIterator3is a model of InputIterator
OutputIteratoris a model of OutputIterator

The following code snippet demonstrates how to use gather_if

#include <bolt/cl/gather.h>
int map[10] = {9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
int input[10] = {0, 11, 22, 33, 44, 55, 66, 77, 88, 99};
int stencil[10] = {0, 0, 0, 0, 0, 1, 1, 1, 1, 1};
int output[10];
bolt::cl::gather_if(map, map + 10, stencil, input, output);
// output is now {0, 0, 0, 0, 0, 44, 33, 22, 11, 0};
template<typename InputIterator1 , typename InputIterator2 , typename InputIterator3 , typename OutputIterator , typename Predicate >
void bolt::cl::gather_if ( bolt::cl::control ctl,
InputIterator1  map_first,
InputIterator1  map_last,
InputIterator2  stencil,
InputIterator3  input,
OutputIterator  result,
Predicate  pred,
const std::string &  user_code = "" 
)

This version of gather_if copies elements from a source array to a destination range according to a specified map. For each i in InputIterator1 in the range [map_first, map_last), gather_if copies the corresponding input_first[ map [ i ] ] to result[ i - map_first ] if pred (stencil[ i - map_first ]) is true.

Parameters
ctlOptional Control structure to control command-queue, debug, tuning, etc.See bolt::cl::control.
map_firstThe beginning of map sequence.
map_lastThe end of map sequence.
stencilThe beginning of the stencil sequence.
inputThe beginning of the source sequence.
resultThe beginning of the output sequence.
predA predicate for stencil.
user_codeOptional OpenCL™ code to be passed to the OpenCL compiler. The cl_code is inserted first in the generated code, before the cl_code trait.
Template Parameters
InputIterator1is a model of InputIterator
InputIterator2is a model of InputIterator
InputIterator3is a model of InputIterator
OutputIteratoris a model of OutputIterator
Predicateis a model of Predicate

The following code snippet demonstrates how to use gather_if

#include <bolt/cl/gather.h>
BOLT_FUNCTOR( greater_pred,
struct greater_pred{
bool operator () (int x)
{
return ( (x > 5)?1:0 );
}
};
);
...
int map[10] = {9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
int input[10] = {0, 11, 22, 33, 44, 55, 66, 77, 88, 99};
int stencil[10] = {2, 3, 1, 4, 5, 10, 6, 8, 7, 9};
int output[10];
greater_pred is_gt_5;
bolt::cl::gather_if(map, map + 10, stencil, input, output, is_gt_5);
// output is now {0, 0, 0, 0, 0, 44, 33, 22, 11, 0};