Public Member Functions

skepu::MapArray< MapArrayFunc > Class Template Reference
[Skeletons]

A class representing the MapArray skeleton. More...

#include <maparray.h>

Collaboration diagram for skepu::MapArray< MapArrayFunc >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 MapArray (MapArrayFunc *mapArrayFunc)
 ~MapArray ()
template<typename T >
void operator() (Vector< T > &input1, Vector< T > &input2, Vector< T > &output)
template<typename Input1Iterator , typename Input2Iterator , typename OutputIterator >
void operator() (Input1Iterator input1Begin, Input1Iterator input1End, Input2Iterator input2Begin, Input2Iterator input2End, OutputIterator outputBegin)
template<typename T >
void CPU (Vector< T > &input1, Vector< T > &input2, Vector< T > &output)
template<typename Input1Iterator , typename Input2Iterator , typename OutputIterator >
void CPU (Input1Iterator input1Begin, Input1Iterator input1End, Input2Iterator input2Begin, Input2Iterator input2End, OutputIterator outputBegin)
template<typename T >
void OMP (Vector< T > &input1, Vector< T > &input2, Vector< T > &output)
template<typename Input1Iterator , typename Input2Iterator , typename OutputIterator >
void OMP (Input1Iterator input1Begin, Input1Iterator input1End, Input2Iterator input2Begin, Input2Iterator input2End, OutputIterator outputBegin)
template<typename T >
void CU (Vector< T > &input1, Vector< T > &input2, Vector< T > &output, int useNumGPU=1)
template<typename Input1Iterator , typename Input2Iterator , typename OutputIterator >
void CU (Input1Iterator input1Begin, Input1Iterator input1End, Input2Iterator input2Begin, Input2Iterator input2End, OutputIterator outputBegin, int useNumGPU=1)
template<typename T >
void CL (Vector< T > &input1, Vector< T > &input2, Vector< T > &output, int useNumGPU=1)
template<typename Input1Iterator , typename Input2Iterator , typename OutputIterator >
void CL (Input1Iterator input1Begin, Input1Iterator input1End, Input2Iterator input2Begin, Input2Iterator input2End, OutputIterator outputBegin, int useNumGPU=1)

Detailed Description

template<typename MapArrayFunc>
class skepu::MapArray< MapArrayFunc >

A class representing the MapArray skeleton.

Author:
Johan Enmyren
Version:
0.6

This class defines the MapArray skeleton which is yet another variant of Map. It produces a result vector from two input vectors where each element of the result, is a function of the corresponding element of one of the input vectors, and any number of elements from the other input vector. This means that at each call to the user defined function, which is done for each element in input two, all elements from input one can be accessed. Once instantiated, it is meant to be used as a function and therefore overloading operator(). There are a few overloaded variants of this operator. One using vectors as inputs and the other using iterators to define a range of elements.

If a certain backend is to be used, functions with the same interface as operator() but by the names CPU, CU, CL, OMP exists for CPU, CUDA, OpenCL and OpenMP respectively.

The MapArray skeleton also includes a pointer to an Environment which includes the devices available to execute on.


Constructor & Destructor Documentation

template<typename MapArrayFunc >
skepu::MapArray< MapArrayFunc >::MapArray ( MapArrayFunc *  mapArrayFunc  ) 

When creating an instance of the MapOverlap skeleton, a pointer to an array user function must be provided. Also the environment is set and if SKEPU_OPENCL is defined, the appropriate OpenCL program and kernel are created. Also creates a default execution plan which the skeleton will use if no other is specified.

Parameters:
mapArrayFunc A pointer to a valid array user function. Will be deleted in the destructor.
template<typename MapArrayFunc >
skepu::MapArray< MapArrayFunc >::~MapArray (  ) 

When the MapArray skeleton is destroyed, it deletes the user function it was created with.


Member Function Documentation

template<typename MapArrayFunc >
template<typename T >
void skepu::MapArray< MapArrayFunc >::CL ( Vector< T > &  input1,
Vector< T > &  input2,
Vector< T > &  output,
int  useNumGPU = 1 
)

Performs the MapArray on the two vectors with OpenCL as backend. Seperate output vector. First Vector can be accessed entirely for each element in second Vector. The function is a wrapper for CL(Input1Iterator input1Begin, Input1Iterator input1End, Input2Iterator input2Begin, Input2Iterator input2End, OutputIterator outputBegin, int useNumGPU).

Parameters:
input1 A vector which the mapping will be performed on.
input2 A vector which the mapping will be performed on.
output The result vector, will be overwritten with the result and resized if needed.
useNumGPU Integer specifying how many devices to use. 0 = Implementation decides.

References skepu::Vector< T >::begin(), skepu::Vector< T >::clear(), skepu::Vector< T >::end(), skepu::Vector< T >::resize(), and skepu::Vector< T >::size().

Here is the call graph for this function:

template<typename MapArrayFunc >
template<typename Input1Iterator , typename Input2Iterator , typename OutputIterator >
void skepu::MapArray< MapArrayFunc >::CL ( Input1Iterator  input1Begin,
Input1Iterator  input1End,
Input2Iterator  input2Begin,
Input2Iterator  input2End,
OutputIterator  outputBegin,
int  useNumGPU = 1 
)

Performs the MapArray on the two element ranges with OpenCL as backend. Seperate output range. First range can be accessed entirely for each element in second range. Calls mapArrayNumDevices_CL(Input1Iterator input1Begin, Input1Iterator input1End, Input2Iterator input2Begin, Input2Iterator input2End, OutputIterator outputBegin, int numDevices).

Parameters:
input1Begin A Vector::iterator to the first element in the first range.
input1End A Vector::iterator to the last element of the first range.
input2Begin A Vector::iterator to the first element in the second range.
input2End A Vector::iterator to the last element of the second range.
outputBegin A Vector::iterator to the first element of the output range.
useNumGPU Integer specifying how many devices to use. 0 = Implementation decides.
template<typename MapArrayFunc >
template<typename T >
void skepu::MapArray< MapArrayFunc >::CPU ( Vector< T > &  input1,
Vector< T > &  input2,
Vector< T > &  output 
)

Performs MapArray with the two vectors on the CPU. Seperate output is used. First Vector can be accessed entirely for each element in second Vector. The function is a wrapper for CPU(Input1Iterator input1Begin, Input1Iterator input1End, Input2Iterator input2Begin, Input2Iterator input2End, OutputIterator outputBegin).

Parameters:
input1 A vector which the mapping will be performed on.
input2 A vector which the mapping will be performed on.
output The result vector, will be overwritten with the result and resized if needed.

References skepu::Vector< T >::begin(), skepu::Vector< T >::clear(), skepu::Vector< T >::end(), skepu::Vector< T >::resize(), and skepu::Vector< T >::size().

Here is the call graph for this function:

template<typename MapArrayFunc >
template<typename Input1Iterator , typename Input2Iterator , typename OutputIterator >
void skepu::MapArray< MapArrayFunc >::CPU ( Input1Iterator  input1Begin,
Input1Iterator  input1End,
Input2Iterator  input2Begin,
Input2Iterator  input2End,
OutputIterator  outputBegin 
)

Performs the MapArray with the two element ranges on the CPU. Seperate output range is used. First range can be accessed entirely for each element in second range. The computation is done by iterating over all the elements in the ranges and applying the user function on each of them.

Parameters:
input1Begin A Vector::iterator to the first element in the first range.
input1End A Vector::iterator to the last element of the first range.
input2Begin A Vector::iterator to the first element in the second range.
input2End A Vector::iterator to the last element of the second range.
outputBegin A Vector::iterator to the first element of the output range.
template<typename MapArrayFunc >
template<typename Input1Iterator , typename Input2Iterator , typename OutputIterator >
void skepu::MapArray< MapArrayFunc >::CU ( Input1Iterator  input1Begin,
Input1Iterator  input1End,
Input2Iterator  input2Begin,
Input2Iterator  input2End,
OutputIterator  outputBegin,
int  useNumGPU = 1 
)

Performs the MapArray on the two element ranges with CUDA as backend. Seperate output range. Decides whether to use one device and mapArraySingleThread_CU or multiple devices and create new threads which calls mapArrayThreadFunc_CU. In the case of several devices the input ranges is divided evenly among the threads created. First range can be accessed entirely for each element in second range.

Parameters:
input1Begin A Vector::iterator to the first element in the first range.
input1End A Vector::iterator to the last element of the first range.
input2Begin A Vector::iterator to the first element in the second range.
input2End A Vector::iterator to the last element of the second range.
outputBegin A Vector::iterator to the first element of the output range.
useNumGPU Integer specifying how many devices to use. 0 = Implementation decides.

References skepu::Threads::fork(), and skepu::Threads::join().

Here is the call graph for this function:

template<typename MapArrayFunc >
template<typename T >
void skepu::MapArray< MapArrayFunc >::CU ( Vector< T > &  input1,
Vector< T > &  input2,
Vector< T > &  output,
int  useNumGPU = 1 
)

Performs the MapArray on the two vectors with CUDA as backend. Seperate output vector. First Vector can be accessed entirely for each element in second Vector. The function is a wrapper for CU(Input1Iterator input1Begin, Input1Iterator input1End, Input2Iterator input2Begin, Input2Iterator input2End, OutputIterator outputBegin, int useNumGPU).

Parameters:
input1 A vector which the mapping will be performed on.
input2 A vector which the mapping will be performed on.
output The result vector, will be overwritten with the result and resized if needed.
useNumGPU Integer specifying how many devices to use. 0 = Implementation decides.

References skepu::Vector< T >::begin(), skepu::Vector< T >::clear(), skepu::Vector< T >::end(), skepu::Vector< T >::resize(), and skepu::Vector< T >::size().

Here is the call graph for this function:

template<typename MapArrayFunc >
template<typename Input1Iterator , typename Input2Iterator , typename OutputIterator >
void skepu::MapArray< MapArrayFunc >::OMP ( Input1Iterator  input1Begin,
Input1Iterator  input1End,
Input2Iterator  input2Begin,
Input2Iterator  input2End,
OutputIterator  outputBegin 
)

Performs MapArray on the two vectors with OpenMP as backend. Seperate output range is used. First range can be accessed entirely for each element in second range. The computation is done by iterating over all the elements in the ranges and applying the user function on each of them. Elements are divided among threads automatically by OpenMP.

Parameters:
input1Begin A Vector::iterator to the first element in the first range.
input1End A Vector::iterator to the last element of the first range.
input2Begin A Vector::iterator to the first element in the second range.
input2End A Vector::iterator to the last element of the second range.
outputBegin A Vector::iterator to the first element of the output range.
template<typename MapArrayFunc >
template<typename T >
void skepu::MapArray< MapArrayFunc >::OMP ( Vector< T > &  input1,
Vector< T > &  input2,
Vector< T > &  output 
)

Performs MapArray on the two vectors with OpenMP as backend. Seperate output is used. First Vector can be accessed entirely for each element in second Vector. The function is a wrapper for CPU(Input1Iterator input1Begin, Input1Iterator input1End, Input2Iterator input2Begin, Input2Iterator input2End, OutputIterator outputBegin).

Parameters:
input1 A vector which the mapping will be performed on.
input2 A vector which the mapping will be performed on.
output The result vector, will be overwritten with the result and resized if needed.

References skepu::Vector< T >::begin(), skepu::Vector< T >::clear(), skepu::Vector< T >::end(), skepu::Vector< T >::resize(), and skepu::Vector< T >::size().

Here is the call graph for this function:

template<typename MapArrayFunc >
template<typename T >
void skepu::MapArray< MapArrayFunc >::operator() ( Vector< T > &  input1,
Vector< T > &  input2,
Vector< T > &  output 
)

Performs the MapArray on the two Vectors specified. A seperate output vector is used.

Depending on which backend was used, different versions of the skeleton is called. If SKEPU_CUDA is defined, the CUDA backend is used, similarly if SKEPU_OPENCL or SKEPU_OPENMP are defined then the OpenCL or OpenMP backend is used. As a fallback there is always a CPU version.

Parameters:
input1 First vector, which can be accessed entirely for each element in second vector.
input2 Second vector, each value of this vector can be mapped to several values from first Vector.
output The result vector, will be overwritten with the result and resized if needed.

References skepu::MapArray< MapArrayFunc >::CL(), skepu::MapArray< MapArrayFunc >::CPU(), skepu::MapArray< MapArrayFunc >::CU(), skepu::MapArray< MapArrayFunc >::OMP(), and skepu::Vector< T >::size().

Here is the call graph for this function:

template<typename MapArrayFunc >
template<typename Input1Iterator , typename Input2Iterator , typename OutputIterator >
void skepu::MapArray< MapArrayFunc >::operator() ( Input1Iterator  input1Begin,
Input1Iterator  input1End,
Input2Iterator  input2Begin,
Input2Iterator  input2End,
OutputIterator  outputBegin 
)

Performs the MapArray on the two element ranges specified. A seperate output range is used. First range can be accessed entirely for each element in second range.

Depending on which backend was used, different versions of the skeleton is called. If SKEPU_CUDA is defined, the CUDA backend is used, similarly if SKEPU_OPENCL or SKEPU_OPENMP are defined then the OpenCL or OpenMP backend is used. As a fallback there is always a CPU version.

Parameters:
input1Begin A Vector::iterator to the first element in the first range.
input1End A Vector::iterator to the last element of the first range.
input2Begin A Vector::iterator to the first element in the second range.
input2End A Vector::iterator to the last element of the second range.
outputBegin A Vector::iterator to the first element of the output range.

References skepu::MapArray< MapArrayFunc >::CL(), skepu::MapArray< MapArrayFunc >::CPU(), skepu::MapArray< MapArrayFunc >::CU(), and skepu::MapArray< MapArrayFunc >::OMP().

Here is the call graph for this function:


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Enumerations Friends Defines