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

Functions

template<typename ForwardIterator , typename T >
void bolt::cl::fill (const bolt::cl::control &ctl, ForwardIterator first, ForwardIterator last, const T &value, const std::string &cl_code="")
 Fill assigns the value of value to each element in the range [first,last].
 
template<typename ForwardIterator , typename T >
void bolt::cl::fill (ForwardIterator first, ForwardIterator last, const T &value, const std::string &cl_code="")
 
template<typename OutputIterator , typename Size , typename T >
OutputIterator bolt::cl::fill_n (const bolt::cl::control &ctl, OutputIterator first, Size n, const T &value, const std::string &cl_code="")
 fill_n assigns the value value to every element in the range [first,first+n]. The return value is first + n.
 
template<typename OutputIterator , typename Size , typename T >
OutputIterator bolt::cl::fill_n (OutputIterator first, Size n, const T &value, const std::string &cl_code="")
 
template<typename ForwardIterator , typename Generator >
void bolt::cl::generate (bolt::cl::control &ctl, ForwardIterator first, ForwardIterator last, Generator gen, const std::string &cl_code="")
 generate assigns to each element of a sequence [first,last] the value returned by gen.
 
template<typename ForwardIterator , typename Generator >
void bolt::cl::generate (ForwardIterator first, ForwardIterator last, Generator gen, const std::string &cl_code="")
 
template<typename OutputIterator , typename Size , typename Generator >
OutputIterator bolt::cl::generate_n (bolt::cl::control &ctl, OutputIterator first, Size n, Generator gen, const std::string &cl_code="")
 generate_n assigns to each element of a sequence [first,first+n] the value returned by gen.
 
template<typename OutputIterator , typename Size , typename Generator >
OutputIterator bolt::cl::generate_n (OutputIterator first, Size n, Generator gen, const std::string &cl_code="")
 

Detailed Description

Function Documentation

template<typename ForwardIterator , typename T >
void bolt::cl::fill ( const bolt::cl::control ctl,
ForwardIterator  first,
ForwardIterator  last,
const T &  value,
const std::string &  cl_code = "" 
)

Fill assigns the value of value to each element in the range [first,last].

Parameters
ctlOptional control structure to control command-queue, debug, tuning, etc. See bolt::cl::control.
firstThe first element in the range of interest.
lastThe last element in the range of interest.
valueSets this value to elements in the range [first,last].
cl_codeOptional OpenCL(TM) code to be prepended to any OpenCL kernels used by this function.
Template Parameters
ForwardIteratoris a model of Forward Iterator, and InputIterator is mutable.
Tis a model of Assignable.

The following code snippet demonstrates how to fill a device_vector with a float value.

#include <bolt/cl/fill.h>
#include <stdlib.h>
...
bolt::cl::device_vector<float> v(10);
float x=25.0f;
bolt::cl::fill(v.begin(), v.end(), x);
// the elements of v are now assigned to the float value.
See Also
http://www.sgi.com/tech/stl/fill.html
template<typename OutputIterator , typename Size , typename T >
OutputIterator bolt::cl::fill_n ( const bolt::cl::control ctl,
OutputIterator  first,
Size  n,
const T &  value,
const std::string &  cl_code = "" 
)

fill_n assigns the value value to every element in the range [first,first+n]. The return value is first + n.

Parameters
ctlOptional control structure to control command-queue, debug, tuning, etc. See bolt::cl::control.
firstThe first element in the range of interest.
nThe size of the range of interest.
valueSets this value to elements in the range [first,first+n].
cl_codeOptional OpenCL(TM) code to be prepended to any OpenCL kernels used by this function.
Template Parameters
OutputIteratoris a model of Output Iterator
Sizeis an integral type (either signed or unsigned).
Tis a model of Assignable
Returns
first+n.

The following code snippet demonstrates how to fill a device_vector with a float value.

#include <bolt/cl/fill.h>
#include <stdlib.h>
...
bolt::cl::device_vector<float> v(10);
float x=25.0f;
bolt::cl::fill_n(v.begin(), 10, x);
// the elements of v are now assigned to the float value.
See Also
http://www.sgi.com/tech/stl/fill_n.html
template<typename ForwardIterator , typename Generator >
void bolt::cl::generate ( bolt::cl::control ctl,
ForwardIterator  first,
ForwardIterator  last,
Generator  gen,
const std::string &  cl_code = "" 
)

generate assigns to each element of a sequence [first,last] the value returned by gen.

Parameters
ctlOptional control structure to control command-queue, debug, tuning, etc. See bolt::cl::control.
firstThe first element of the sequence.
lastThe last element of the sequence.
genA generator, functor taking no parameters.
cl_codeOptional OpenCL(TM) code to be prepended to any OpenCL kernels used by this function.
Template Parameters
ForwardIteratoris a model of Forward Iterator, and ForwardIterator is mutable.
Generatoris a model of Generator, and Generator's result_type is convertible to ForwardIterator's value_type.

The following code snippet demonstrates how to fill a vector with a constant number.

#include <stdlib.h>
...
BOLT_FUNCTOR(ConstFunctor,
struct ConstFunctor
{
int val;
ConstFunctor(int a) : val(a) {};
int operator() ()
{
return val;
};
};
);
...
ConstFunctor cf(1);
std::vector<int> vec(1024);
bolt::cl::generate( vec.begin(), vec.end(), cf);
// vec is now filled with 1
See Also
http://www.sgi.com/tech/stl/generate.html
template<typename OutputIterator , typename Size , typename Generator >
OutputIterator bolt::cl::generate_n ( bolt::cl::control ctl,
OutputIterator  first,
Size  n,
Generator  gen,
const std::string &  cl_code = "" 
)

generate_n assigns to each element of a sequence [first,first+n] the value returned by gen.

Parameters
ctlOptional control structure to control command-queue, debug, tuning, etc. See bolt::cl::control.
firstThe first element of the sequence.
nThe number of sequence elements to generate.
genA generator, functor taking no parameters.
cl_codeOptional OpenCL(TM) code to be prepended to any OpenCL kernels used by this function.
Template Parameters
OutputIteratoris a model of Output Iterator.
Sizeis an integral type.
Generatoris a model of Generator, and Generator's result_type is convertible to OutputIterator's value_type.

The following code snippet demonstrates how to fill a vector with a constant number.

#include <bolt/cl/bolt.h>
#include <stdlib.h>
...
BOLT_FUNCTOR(ConstFunctor,
struct ConstFunctor
{
int val;
ConstFunctor(int a) : val(a) {};
int operator() ()
{
return val;
};
};
);
...
ConstFunctor cf(1);
std::vector<int> vec(1024);
int n = 1024;
bolt::cl::generate_n(vec.begin(), n, cf);
// vec is now filled with 1
See Also
http://www.sgi.com/tech/stl/generate_n.html