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

Functions

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

Detailed Description

Function Documentation

template<typename InputIterator1 , typename InputIterator2 , typename OutputIterator >
void bolt::cl::scatter ( ::bolt::cl::control ctl,
InputIterator1  first,
InputIterator1  last,
InputIterator2  map,
OutputIterator  result,
const std::string &  user_code = "" 
)

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

scatter APIs copy elements from a source range to a destination array (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.
firstThe beginning of input sequence.
lastThe end of input sequence.
mapThe 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 scatter

int input[10] = {5, 7, 2, 3, 12, 6, 9, 8, 1, 4};
int map[10] = {8, 2, 3, 9, 0, 5, 1, 7, 6, 4};
int output[10];
bolt::cl::scatter(input, input + 10, map, output);
// output is now {12, 9, 7, 2, 4, 6, 1, 8, 5, 3};
template<typename InputIterator1 , typename InputIterator2 , typename InputIterator3 , typename OutputIterator >
void bolt::cl::scatter_if ( bolt::cl::control ctl,
InputIterator1  first1,
InputIterator1  last1,
InputIterator2  map,
InputIterator3  stencil,
OutputIterator  result,
const std::string &  user_code = "" 
)

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

Parameters
ctlOptional Control structure to control command-queue, debug, tuning, etc.See bolt::cl::control.
firstThe beginning of input sequence.
lastThe end of input sequence.
mapThe beginning of the map sequence.
stencilThe beginning of the stencil 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 scatter_if

int input[10] = {5, 7, 2, 3, 12, 6, 9, 8, 1, 4};
int map[10] = {8, 2, 3, 9, 0, 5, 1, 7, 6, 4};
int stencil[10] = {0, 0, 0, 0, 0, 1, 1, 1, 1, 1};
int output[10];
bolt::cl::scatter_if(input, input + 10, map, stencil, output);
// output is now {0, 9, 0, 0, 4, 6, 1, 8, 0, 0};
template<typename InputIterator1 , typename InputIterator2 , typename InputIterator3 , typename OutputIterator , typename Predicate >
void bolt::cl::scatter_if ( bolt::cl::control ctl,
InputIterator1  first1,
InputIterator1  last1,
InputIterator2  map,
InputIterator3  stencil,
OutputIterator  result,
Predicate  pred,
const std::string &  user_code = "" 
)

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

Parameters
ctlOptional Control structure to control command-queue, debug, tuning, etc.See bolt::cl::control.
firstThe beginning of input sequence.
lastThe end of input sequence.
mapThe beginning of the map sequence.
stencilThe beginning of the stencil 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 scatter_if

BOLT_FUNCTOR( greater_pred,
struct greater_pred{
bool operator () (int x)
{
return ( (x > 5)?1:0 );
}
};
);
...
int input[10] = {5, 7, 2, 3, 12, 6, 9, 8, 1, 4};
int map[10] = {8, 2, 3, 9, 0, 5, 1, 7, 6, 4};
int stencil[10] = {1, 3, 5, 2, 4, 6, 10, 9, 12, 22};
int output[10];
greater_pred is_gt_5;
bolt::cl::scatter_if(input, input + 10, map, stencil, output, is_gt_5);
// output is now {0, 9, 0, 0, 4, 6, 1, 8, 0, 0};