Bolt  1.3
C++ template library with support for OpenCL
Namespaces | Classes | Functions
bolt Namespace Reference

Defining namespace for the Bolt project. More...

Namespaces

namespace  amp
 Namespace containing AMP related data types and functions.
 
namespace  cl
 Namespace containing OpenCL related data types and functions.
 

Classes

class  ArrayPool
 
class  synchronized_view
 

Functions

template<typename IterType , typename Function >
void parallel_iteration (concurrency::extent< 1 > ext, IterType Init, Function f)
 
template<typename IterType , typename Function >
void parallel_iteration_1 (concurrency::extent< 1 > ext, IterType Init, Function f)
 

Detailed Description

Defining namespace for the Bolt project.

transform iterator adapts an iterator by modifying the operator* to apply a function object to the result of dereferencing the iterator and returning the result..

The following example demonstrates how to use a transform_iterator.

//In AMP, Transform Iterator works only with device_vectors.
//The example here uses device_vector iterators.
struct UDD
{
int i;
float f;
UDD operator = (const int rhs)
{
UDD _result;
_result.i = i + rhs;
_result.f = f + (float)rhs;
return _result;
}
UDD operator + (const UDD &rhs) const
{
UDD _result;
_result.i = this->i + rhs.i;
_result.f = this->f + rhs.f;
return _result;
}
UDD()
: i(0), f(0) { }
UDD(int _in)
: i(_in), f((float)(_in+2) ){ }
};
struct UDDadd_3
{
UDD operator() (const UDD &x) const
{
UDD temp;
temp.i = x.i + 3;
temp.f = x.f + 3.0f;
return temp;
}
typedef UDD result_type;
//Note that the result_type needs to be defined and should be type-defined to the
//return type of operator () overload.
};
int main() {
// Create device_vectors
UDDadd_3 add3;
dv_trf_itr_add3 dv_trf_begin (dvInVec1.begin(), add3), dv_trf_end (dvInVec1.end(), add3);
// Fill values
dvInVec1[ 0 ] = 10 ; dvInVec1[ 1 ] = 15 ; dvInVec1[ 2 ] = 20 ;
dvInVec1[ 3 ] = 25 ; dvInVec1[ 4 ] = 30 ;
dvInVec2[ 0 ] = 10 ; dvInVec2[ 1 ] = 15 ; dvInVec2[ 2 ] = 20 ;
dvInVec2[ 3 ] = 25 ; dvInVec2[ 4 ] = 30 ;
...
bolt::amp::transform(dv_trf_begin,
dv_trf_end,
dvInVec2.begin( ),
dvDestVec.begin( ),
}

Function Documentation

template<typename IterType , typename Function >
void bolt::parallel_iteration ( concurrency::extent< 1 >  ext,
IterType  Init,
Function  f 
)

parallel_iteration1 : Slow implementation - just use a parallel_for for all devices.

Init is the initial state for the Iteration type for every index.

The user provides a functor that accepts two arguments: index<> - location in the extent to be processed. IterType : User-supplied type that tracks the state of each iteration. The functor is responsible for : Updating the state so that it points to the next 'iteration'. The next "iteration" could be the next cascade stage in a face-detection algorithm, or the next iteration of a loop. It is very important to update to the next state to avoid an infinite loop. Returns true if the Bolt runtime is to schedule the next iteration, or false if the runtime is to exit.