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

Functions

template<typename InputIterator1 , typename InputIterator2 , typename OutputIterator >
void bolt::amp::gather (::bolt::amp::control &ctl, InputIterator1 map_first, InputIterator1 map_last, InputIterator2 input_first, OutputIterator result)
 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::amp::gather (InputIterator1 map_first, InputIterator1 map_last, InputIterator2 input_first, OutputIterator result)
 
template<typename InputIterator1 , typename InputIterator2 , typename InputIterator3 , typename OutputIterator >
void bolt::amp::gather_if (bolt::amp::control &ctl, InputIterator1 map_first, InputIterator1 map_last, InputIterator2 stencil, InputIterator3 input_first, OutputIterator result)
 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::amp::gather_if (InputIterator1 map_first, InputIterator1 map_last, InputIterator2 stencil, InputIterator3 input_first, OutputIterator result)
 
template<typename InputIterator1 , typename InputIterator2 , typename InputIterator3 , typename OutputIterator , typename Predicate >
void bolt::amp::gather_if (bolt::amp::control &ctl, InputIterator1 map_first, InputIterator1 map_last, InputIterator2 stencil, InputIterator3 input, OutputIterator result, Predicate pred)
 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::amp::gather_if (InputIterator1 map_first, InputIterator1 map_last, InputIterator2 stencil, InputIterator3 input, OutputIterator result, Predicate pred)
 

Detailed Description

Function Documentation

template<typename InputIterator1 , typename InputIterator2 , typename OutputIterator >
void bolt::amp::gather ( ::bolt::amp::control ctl,
InputIterator1  map_first,
InputIterator1  map_last,
InputIterator2  input_first,
OutputIterator  result 
)

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::amp::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.
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

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::amp::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::amp::gather_if ( bolt::amp::control ctl,
InputIterator1  map_first,
InputIterator1  map_last,
InputIterator2  stencil,
InputIterator3  input_first,
OutputIterator  result 
)

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::amp::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.
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

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::amp::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::amp::gather_if ( bolt::amp::control ctl,
InputIterator1  map_first,
InputIterator1  map_last,
InputIterator2  stencil,
InputIterator3  input,
OutputIterator  result,
Predicate  pred 
)

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::amp::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.
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

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::amp::gather_if(map, map + 10, stencil, input, output, is_gt_5);
// output is now {0, 0, 0, 0, 0, 44, 33, 22, 11, 0};