SkePU(integratedwithStarPU)
0.8.1
|
A class representing the Map skeleton. More...
#include <map.h>
Public Member Functions | |
Map (MapFunc *mapFunc) | |
Map (MapFunc *mapFunc, Vector< T > *input, Vector< T > *output, int parts=1) | |
~Map () | |
void | run_async () |
template<typename U > | |
void | setConstant (U constant1) |
void | finishAll () |
void | operator() (Vector< T > &input) |
void | operator() (Vector< T > &input, Vector< T > &output) |
void | operator() (Vector< T > &input, int parts) |
void | operator() (Vector< T > &input, Vector< T > &output, int parts) |
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 *buffer[], void *arg) |
static void | cuda_func (void *buffer[], void *arg) |
static void | opencl_func (void *buffer[], void *arg) |
A class representing the Map skeleton.
This class defines the Map skeleton for unary
user function and vector
container type, a calculation pattern where a user function is applied to each element of an input range. Once the Map object is instantiated, it is meant to be used as a function and therefore overloading operator()
.
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.
This class defines the Map skeleton for binary
user function and vector
container type, a calculation pattern where a user function is applied to each element of an input range. Once the Map object is instantiated, it is meant to be used as a function and therefore overloading operator()
.
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.
This class defines the Map skeleton for ternary
user function and vector
container type, a calculation pattern where a user function is applied to each element of an input range. Once the Map object is instantiated, it is meant to be used as a function and therefore overloading operator()
.
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.
This class defines the Map skeleton for unary
user function and matrix
container type, a calculation pattern where a user function is applied to each element of an input range. Once the Map object is instantiated, it is meant to be used as a function and therefore overloading operator()
.
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.
This class defines the Map skeleton for binary
user function and Matrix
container type, a calculation pattern where a user function is applied to each element of an input range. Once the Map object is instantiated, it is meant to be used as a function and therefore overloading operator()
.
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.
This class defines the Map skeleton for ternary
user function and matrix
container type, a calculation pattern where a user function is applied to each element of an input range. Once the Map object is instantiated, it is meant to be used as a function and therefore overloading operator()
.
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.
This class defines the Map skeleton for unary
user function and SparseMatrix
container type, a calculation pattern where a user function is applied to each element of an input range. Once the Map object is instantiated, it is meant to be used as a function and therefore overloading operator()
.
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.
This class defines the Map skeleton for binary
user function and SparseMatrix
container type, a calculation pattern where a user function is applied to each element of an input range. Once the Map object is instantiated, it is meant to be used as a function and therefore overloading operator()
.
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.
This class defines the Map skeleton for ternary
user function and SparseMatrix
container type, a calculation pattern where a user function is applied to each element of an input range. Once the Map object is instantiated, it is meant to be used as a function and therefore overloading operator()
.
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::Map< MapFunc, T, c_type, cont_type >::Map | ( | MapFunc * | mapFunc | ) |
When creating an instance of the Map skeleton, for a unary
user function and Vector
container type. Also the environment is set and if SKEPU_OPENCL
is defined, the appropriate OpenCL program is created.
mapFunc | A pointer to a valid unary user function. Will be deleted in the destructor. |
References skepu::Environment< T >::getInstance().
skepu::Map< MapFunc, T, c_type, cont_type >::Map | ( | MapFunc * | mapFunc, |
Vector< T > * | in, | ||
Vector< T > * | out, | ||
int | _parts = 1 |
||
) |
When creating an instance of the Map skeleton, for a unary
user function and Vector
container type. 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.
mapFunc | A pointer to a valid unary user function. Will be deleted in the destructor. |
in | A pointer to a input Vector object. |
out | A pointer to a output Vector object. |
_parts | An integer specifying number of partitions(subtasks) to be created when map is called. |
References skepu::Environment< T >::getInstance().
skepu::Map< MapFunc, T, c_type, cont_type >::~Map | ( | ) |
|
static |
A static function used with StarPU codelet for MAP_UNARY
user function and 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 either only one read-write buffer (Same vector is read and written) or one read and one write buffer. |
arg | A read only argument which is used to pass handler to the object and other data as this is a static function. |
void skepu::Map< MapFunc, T, c_type, cont_type >::createOpenCLProgram | ( | ) |
A function for MAP_UNARY
user function and with Vector
container called by the constructor. It creates the OpenCL program for the skeleton using StarPU helper functions and saves the kernel name. The program is built from a string containing the user function (specified when constructing the skeleton) and a generic Map 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::BinaryMapKernel_CL(), skepu::read_file_into_string(), skepu::TrinaryMapKernel_CL(), and skepu::UnaryMapKernel_CL().
|
static |
A static function used with StarPU codelet for MAP_UNARY
user function and 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 either only one read-write buffer (Same vector is read and written) or one read and one write buffer. |
arg | A read only argument which is used to pass handler to the object and other data as this is a static function. |
|
inline |
Makes sure all operations on devices are finished.
|
static |
A static function used with StarPU codelet for MAP_UNARY
user function and 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 either only one read-write buffer (Same vector is read and written) or one read and one write buffer. |
arg | A read only argument which is used to pass handler to the object and other data as this is a static function. |
|
static |
A static function used with StarPU codelet for MAP_UNARY
user function and 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 either only one read-write buffer (Same vector is read and written) or one read and one write buffer. |
arg | A read only argument which is used to pass handler to the object and other data as this is a static function. |
void skepu::Map< MapFunc, T, c_type, cont_type >::operator() | ( | Vector< T > & | input | ) |
Performs the Map on one vector. With itself as output. The Map skeleton needs to be created with a unary user function.
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. |
void skepu::Map< MapFunc, T, c_type, cont_type >::operator() | ( | Vector< T > & | input, |
Vector< T > & | output | ||
) |
Performs the Map on one vector. With a second vector as output. The Map skeleton needs to be created with a unary user function.
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. |
References skepu::Vector< T >::clear(), skepu::Vector< T >::resize(), and skepu::Vector< T >::size().
void skepu::Map< MapFunc, T, c_type, cont_type >::operator() | ( | Vector< T > & | input, |
int | parts | ||
) |
Performs the Map on one vector with itself as output. It has support for creating multiple tasks using filters/partitioning. The Map skeleton needs to be created with a unary
user function.
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. |
parts | The number of parts (StarPU tasks) that will be created for this skeleton call dividing the work equally between different created tasks. |
References skepu::Vector< T >::registerPartitions().
void skepu::Map< MapFunc, T, c_type, cont_type >::operator() | ( | Vector< T > & | input, |
Vector< T > & | output, | ||
int | parts | ||
) |
Performs the Map on one vector. With a second vector as output. It has support for creating multiple tasks using filters/partitioning. The Map skeleton needs to be created with a unary user function.
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. |
parts | The number of parts (StarPU tasks) that will be created for this skeleton call dividing the work equally between different created tasks. |
References skepu::Vector< T >::clear(), skepu::Vector< T >::registerPartitions(), skepu::Vector< T >::resize(), and skepu::Vector< T >::size().
void skepu::Map< MapFunc, T, c_type, cont_type >::replaceText | ( | std::string & | text, |
std::string | find, | ||
std::string | replace | ||
) |
A helper function for MAP_UNARY
user function and with Vector
container used by createOpenCLProgram(). 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.
|
inline |
If the Mapping function supports a constant, set it with this function before a call.