SkePU(integratedwithStarPU)
0.8.1
|
A class representing the MapOverlap skeleton. More...
#include <mapoverlap.h>
Public Member Functions | |
MapOverlap (MapOverlapFunc *mapOverlapFunc) | |
MapOverlap (MapOverlapFunc *mapOverlapFunc, Vector< T > *in, Vector< T > *out, EdgePolicy poly, T pad=T()) | |
~MapOverlap () | |
void | run_async () |
void | operator() (Vector< T > &input, EdgePolicy poly=CONSTANT, T pad=T()) |
void | operator() (Vector< T > &input, Vector< T > &output, EdgePolicy poly=CONSTANT, T pad=T()) |
void | replaceText (std::string &text, std::string find, std::string replace) |
void | createOpenCLProgram () |
Static Public Member Functions | |
static void | cpu_func (void *buffers[], void *arg) |
static void | omp_func (void *buffers[], void *arg) |
static void | cuda_func (void *buffers[], void *arg) |
static void | opencl_func (void *buffers[], void *arg) |
A class representing the MapOverlap skeleton.
This class defines the MapOverlap skeleton for a Vector
container type. MapOverlp is similar to a Map, but each element of the result vector is a function of several adjacent elements of one input vector that reside at a certain constant maximum distance from each other. Once instantiated, it is meant to be used as a function and therefore overloading operator()
. There are a few overloaded variants of this operator depending on if a seperate output vector is provided.
It uses StarPU as a backend and choice between different backends can be controlled by using defines. SKEPU_OPENMP can be used to use OpenMP whose support is currently limited in StarPU, hence not recommended, SKEPU_CUDA will register CUDA backend along other defined (atleast CPU if nothing else is defined) SKEPU_OPENCL will register OpenCL backend along other defined (atleast CPU if nothing else is defined) CUDA_ONLY will eliminate all other backends (even CPU) and will force StarPU to use CUDA only. if no above macro is defined, it will use sequential CPU backend.
The MapOverlap skeleton also includes a pointer to an Environment which includes the devices available to execute on.
This class defines the MapOverlap skeleton for a Matrix
container type. MapOverlp is similar to a Map, but each element of the result matrix is a function of several (row and/or column) adjacent elements of one input matrix that reside at a certain constant maximum distance from each other. Once instantiated, it is meant to be used as a function and therefore overloading operator()
. There are a few overloaded variants of this operator depending on if a seperate output vector is provided.
It uses StarPU as a backend and choice between different backends can be controlled by using defines. SKEPU_OPENMP can be used to use OpenMP whose support is currently limited in StarPU, hence not recommended, SKEPU_CUDA will register CUDA backend along other defined (atleast CPU if nothing else is defined) SKEPU_OPENCL will register OpenCL backend along other defined (atleast CPU if nothing else is defined) CUDA_ONLY will eliminate all other backends (even CPU) and will force StarPU to use CUDA only. if no above macro is defined, it will use sequential CPU backend.
skepu::MapOverlap< MapOverlapFunc, T, c_type >::MapOverlap | ( | MapOverlapFunc * | mapOverlapFunc | ) |
When creating an instance of the MapOverlap skeleton with a Vector
container type, a pointer to an overlap user function must be provided. Also the environment is set and if SKEPU_OPENCL
is defined, the appropriate OpenCL program is created.
mapOverlapFunc | A pointer to a valid overlap user function. Will be deleted in the destructor. |
References skepu::Environment< T >::getInstance().
skepu::MapOverlap< MapOverlapFunc, T, c_type >::MapOverlap | ( | MapOverlapFunc * | mapOverlapFunc, |
Vector< T > * | in, | ||
Vector< T > * | out, | ||
EdgePolicy | poly, | ||
T | pad = T() |
||
) |
When creating an instance of the MapOverlap skeleton with a Vector
container type, a pointer to an overlap user function must be provided. Also the environment is set and if SKEPU_OPENCL
is defined, the appropriate OpenCL program is created. This constructor is used to assist in calling map skeleton in a task-parallel skeleton(e.g. farm) by implementing Task class "run_async()" method. The parameters for map call should be specified before e.g. using this constructor.
mapOverlapFunc | A pointer to a valid overlap user function. Will be deleted in the destructor. |
in | A pointer to a input Vector object. |
out | A pointer to a output Vector object. |
poly | An EdgePolicy specifying what to do when overlapping elements on the edge. |
pad | A padding value that will be used for edge elements to perform overlap if constant EdgePolicy is used. |
References skepu::Environment< T >::getInstance().
skepu::MapOverlap< MapOverlapFunc, T, c_type >::~MapOverlap | ( | ) |
When the MapOverlap skeleton with a Vector
container type is destroyed, it deletes the user function it was created with. Furthermore, it destroy OpenCL handler and performance model objects (if created) and StarPU codelet.
|
static |
A static function used with StarPU codelet for MapOverlap with Vector
container and is called by the StarPU if CPU backend is selected for a skeleton invocation.
buffers | Contain all StarPU managed data which in this case consists of one read and one write buffer. |
arg | A read only argument which is used to pass handler to the object as this is a static function. |
void skepu::MapOverlap< MapOverlapFunc, T, c_type >::createOpenCLProgram | ( | ) |
A function called by the constructor. It creates the OpenCL program for the skeleton and saves the kernel name. The program is built from a string containing the user function (specified when constructing the skeleton) and a generic MapOverlap kernel. The type and function names in the generic kernel are relpaced by user function specific code before it is compiled by the OpenCL JIT compiler.
Also handles the use of doubles automatically by including "#pragma OPENCL EXTENSION cl_khr_fp64: enable" if doubles are used.
References skepu::MapOverlapKernel_CL().
|
static |
A static function used with StarPU codelet for MapOverlap with Vector
container and is called by the StarPU if CUDA backend is selected for a skeleton invocation.
buffers | Contain all StarPU managed data which in this case consists of one read and one write buffer. |
arg | A read only argument which is used to pass handler to the object as this is a static function. |
|
static |
A static function used with StarPU codelet for MapOverlap with Vector
container and is called by the StarPU if OpenMP backend is selected for a skeleton invocation.
buffers | Contain all StarPU managed data which in this case consists of one read and one write buffer. |
arg | A read only argument which is used to pass handler to the object as this is a static function. |
|
static |
A static function used with StarPU codelet for MapOverlap with Vector
container and is called by the StarPU if OpenCL backend is selected for a skeleton invocation.
buffers | Contain all StarPU managed data which in this case consists of one read and one write buffer. |
arg | A read only argument which is used to pass handler to the object as this is a static function. |
void skepu::MapOverlap< MapOverlapFunc, T, c_type >::operator() | ( | Vector< T > & | input, |
EdgePolicy | poly = CONSTANT , |
||
T | pad = T() |
||
) |
Performs the MapOverlap on a whole Vector. With itself as output.
Depending on which backend was used, appropriate backend will be registered. In case of multiple backends (e.g. CPU and CUDA) StarPU will decide at runtime which one to use.
input | A vector which the mapping will be performed on. It will be overwritten with the result. |
poly | Edge policy for the calculation, either CONSTANT or CYCLIC. |
pad | If CONSTANT edge policy, this is the value to pad with. |
References skepu::Vector< T >::begin(), skepu::Vector< T >::end(), and skepu::Vector< T >::size().
void skepu::MapOverlap< MapOverlapFunc, T, c_type >::operator() | ( | Vector< T > & | input, |
Vector< T > & | output, | ||
EdgePolicy | poly = CONSTANT , |
||
T | pad = T() |
||
) |
Performs the MapOverlap on a whole Vector. With a seperate Vector as output.
Depending on which backend was used, appropriate backend will be registered. In case of multiple backends (e.g. CPU and CUDA) StarPU will decide at runtime which one to use.
input | A vector which the mapping will be performed on. |
output | The result vector, will be overwritten with the result and resized if needed. |
poly | Edge policy for the calculation, either CONSTANT or CYCLIC. |
pad | If CONSTANT edge policy, this is the value to pad with. |
References skepu::Vector< T >::clear(), skepu::Vector< T >::resize(), and skepu::Vector< T >::size().
void skepu::MapOverlap< MapOverlapFunc, T, c_type >::replaceText | ( | std::string & | text, |
std::string | find, | ||
std::string | replace | ||
) |
A helper function used by createOpenCLProgram() for MapOverlap with Vector
. It finds all instances of a string in another string and replaces it with a third string.
text | A std::string which is searched. |
find | The std::string which is searched for and replaced. |
replace | The relpacement std::string . |
|
virtual |
This is an abstract method defined in the Task
class which every data-parallel skeleton implements to allow itself to be used within task-parallel skeletons (e.g. farm). It relies on the fact that parameters for the function call are already provided e.g. via constructor or setter methods available in the public interface of the class.
Implements skepu::Task.