SkePU 0.7
Public Member Functions
skepu::MapArray< MapArrayFunc > Class Template Reference

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 T >
void operator() (Vector< T > &input1, Matrix< T > &input2, Matrix< 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 T >
void CPU (Vector< T > &input1, Matrix< T > &input2, Matrix< 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 T >
void OMP (Vector< T > &input1, Matrix< T > &input2, Matrix< 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 T >
void CU (Vector< T > &input1, Matrix< T > &input2, Matrix< 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 T >
void CL (Vector< T > &input1, Matrix< T > &input2, Matrix< 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.

This class defines the MapArray skeleton. MapArray is yet another variant of Map. It produces a result (vector/matrix) from either two input objects (vector/matrix) where each element of the result, is a function of the corresponding element of the second input (vector/matrix), and any number of elements from the first 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 containers 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 MapArray 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:
mapArrayFuncA pointer to a valid array user function. Will be deleted in the destructor.

References skepu::Environment< T >::getInstance().

Here is the call graph for this function:

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:
input1A vector which the mapping will be performed on.
input2A vector which the mapping will be performed on.
outputThe result vector, will be overwritten with the result and resized if needed.
useNumGPUInteger 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 T >
void skepu::MapArray< MapArrayFunc >::CL ( Vector< T > &  input1,
Matrix< T > &  input2,
Matrix< T > &  output,
int  useNumGPU = 1 
)

Performs the MapArray on the one vector and one matrix with OpenCL as backend. Separate output matrix. The vector can be accessed entirely for each element in the matrix. The function is a wrapper for CL(Input1Iterator input1Begin, Input1Iterator input1End, Input2Iterator input2Begin, Input2Iterator input2End, OutputIterator outputBegin, int useNumGPU).

Parameters:
input1A vector which the mapping will be performed on.
input2A matrix which the mapping will be performed on.
outputThe result matrix, will be overwritten with the result and resized if needed.
useNumGPUInteger specifying how many devices to use. 0 = Implementation decides.

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

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:
input1BeginAn iterator to the first element in the first range.
input1EndAn iterator to the last element of the first range.
input2BeginAn iterator to the first element in the second range.
input2EndAn iterator to the last element of the second range.
outputBeginAn iterator to the first element of the output range.
useNumGPUInteger specifying how many devices to use. 0 = Implementation decides.
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:
input1BeginAn iterator to the first element in the first range.
input1EndAn iterator to the last element of the first range.
input2BeginAn iterator to the first element in the second range.
input2EndAn iterator to the last element of the second range.
outputBeginAn iterator to the first element of the output range.
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:
input1A vector which the mapping will be performed on.
input2A vector which the mapping will be performed on.
outputThe 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 >::CPU ( Vector< T > &  input1,
Matrix< T > &  input2,
Matrix< T > &  output 
)

Performs MapArray with the one vector and one matrix on the CPU. Seperate output is used. The Vector can be accessed entirely for each element in Matrix. The function is a wrapper for CPU(Input1Iterator input1Begin, Input1Iterator input1End, Input2Iterator input2Begin, Input2Iterator input2End, OutputIterator outputBegin).

Parameters:
input1A vector which the mapping will be performed on.
input2A matrix which the mapping will be performed on.
outputThe result matrix, will be overwritten with the result and resized if needed.

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

Here is the call graph for this function:

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. 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:
input1BeginAn iterator to the first element in the first range.
input1EndAn iterator to the last element of the first range.
input2BeginAn iterator to the first element in the second range.
input2EndAn iterator to the last element of the second range.
outputBeginAn iterator to the first element of the output range.
useNumGPUInteger specifying how many devices to use. 0 = Implementation decides.

References skepu::MapArrayKernel_CU(), skepu::max(), MAX_GPU_DEVICES, and skepu::min().

Here is the call graph for this function:

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

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

Parameters:
input1A vector which the mapping will be performed on.
input2A matrix which the mapping will be performed on.
outputThe result matrix, will be overwritten with the result and resized if needed.
useNumGPUInteger specifying how many devices to use. 0 = Implementation decides.

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

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:
input1A vector which the mapping will be performed on.
input2A vector which the mapping will be performed on.
outputThe result vector, will be overwritten with the result and resized if needed.
useNumGPUInteger 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 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:
input1A vector which the mapping will be performed on.
input2A vector which the mapping will be performed on.
outputThe 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 >::OMP ( Vector< T > &  input1,
Matrix< T > &  input2,
Matrix< T > &  output 
)

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

Parameters:
input1A vector which the mapping will be performed on.
input2A matrix which the mapping will be performed on.
outputThe result matrix, will be overwritten with the result and resized if needed.

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

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:
input1BeginAn iterator to the first element in the first range.
input1EndAn iterator to the last element of the first range.
input2BeginAn iterator to the first element in the second range.
input2EndAn iterator to the last element of the second range.
outputBeginAn iterator to the first element of the output range.
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:
input1BeginA Vector::iterator to the first element in the first range.
input1EndA Vector::iterator to the last element of the first range.
input2BeginA Vector::iterator to the first element in the second range.
input2EndA Vector::iterator to the last element of the second range.
outputBeginA Vector::iterator to the first element of the output range.
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:
input1First vector, which can be accessed entirely for each element in second vector.
input2Second vector, each value of this vector can be mapped to several values from first Vector.
outputThe result vector, will be overwritten with the result and resized if needed.

References 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,
Matrix< T > &  input2,
Matrix< T > &  output 
)

Performs the MapArray on the one vector and matrix specified. A seperate output matrix 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:
input1First vector, which can be accessed entirely for each element in second vector.
input2Second matrix, each value of this matrix can be mapped to several values from first Vector.
outputThe result matrix, will be overwritten with the result and resized if needed.

References skepu::Vector< T >::size().

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