SkePU  1.2
 All Classes Namespaces Files Functions Variables Enumerations Friends Macros Groups Pages
Public Member Functions | List of all members
skepu::Generate< GenerateFunc > Class Template Reference

A class representing the Generate skeleton. More...

#include <generate.h>

Public Member Functions

 Generate (GenerateFunc *generateFunc)
 
 ~Generate ()
 
template<typename T >
void setConstant (T constant1)
 
void finishAll ()
 
template<typename T >
void operator() (size_t numElements, Vector< T > &output)
 
template<typename T >
void operator() (size_t numRows, size_t numCols, Matrix< T > &output)
 
template<typename OutputIterator >
void operator() (size_t numElements, OutputIterator outputBegin)
 
template<typename T >
void CPU (size_t numElements, Vector< T > &output)
 
template<typename T >
void CPU (size_t numRows, size_t numCols, Matrix< T > &output)
 
template<typename OutputIterator >
void CPU (size_t numElements, OutputIterator outputBegin)
 
template<typename T >
void OMP (size_t numElements, Vector< T > &output)
 
template<typename T >
void OMP (size_t numRows, size_t numCols, Matrix< T > &output)
 
template<typename OutputIterator >
void OMP (size_t numElements, OutputIterator outputBegin)
 
template<typename T >
void CU (size_t numElements, Vector< T > &output, int useNumGPU=1)
 
template<typename T >
void CU (size_t numRows, size_t numCols, Matrix< T > &output, int useNumGPU=1)
 
template<typename OutputIterator >
void CU (size_t numElements, OutputIterator outputBegin, int useNumGPU=1)
 
template<typename T >
void CL (size_t numElements, Vector< T > &output, int useNumGPU=1)
 
template<typename T >
void CL (size_t numRows, size_t numCols, Matrix< T > &output, int useNumGPU=1)
 
template<typename OutputIterator >
void CL (size_t numElements, OutputIterator outputBegin, int useNumGPU=1)
 

Detailed Description

template<typename GenerateFunc>
class skepu::Generate< GenerateFunc >

A class representing the Generate skeleton.

This class defines the Generate skeleton, It can be used to generate a specified number of elements using a user defined function for both vector and matrix containers. It is similar to the Unary Map skeleton, applying a function to each element of a vector. But the Generate skeleton generates all the elements instead of copying the existing elements and applying a function on them.

Once the Generate object is instantiated, it is meant to be used as a function and therefore overloading operator(). There are different overloaded versions of this operator, one which takes iterators as inputs and one that takes whole vectors/matrix.

If a certain back end 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.

Constructor & Destructor Documentation

template<typename GenerateFunc >
skepu::Generate< GenerateFunc >::Generate ( GenerateFunc *  generateFunc)

When creating an instance of the Generate skeleton, a pointer to a generate 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
generateFuncA pointer to a valid user function. Will be deleted in the destructor.

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

Here is the call graph for this function:

template<typename GenerateFunc >
skepu::Generate< GenerateFunc >::~Generate ( )

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

Member Function Documentation

template<typename GenerateFunc >
template<typename T >
void skepu::Generate< GenerateFunc >::CL ( size_t  numElements,
Vector< T > &  output,
int  useNumGPU = 1 
)

Generates a number of elements using the user function which the skeleton was created with. The elements are saved in an output vector which is resized to numElements. A wrapper for CL(size_t numElements, OutputIterator outputBegin, int useNumGPU). For the OpenCL backend.

Parameters
numElementsThe number of elements to be generated.
outputThe output vector which will be overwritten with the generated values.
useNumGPUInteger specifying how many devices to use. 0 = Implementation decides.

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

Here is the call graph for this function:

template<typename GenerateFunc >
template<typename T >
void skepu::Generate< GenerateFunc >::CL ( size_t  numRows,
size_t  numCols,
Matrix< T > &  output,
int  useNumGPU = 1 
)

Generates a number of elements using the user function which the skeleton was created with. The elements are saved in an output matrix which is resized to numElements. For the OpenCL backend.

Parameters
numRowsThe number of rows to be generated.
numColsThe number of columns to be generated.
outputThe output matrix which will be overwritten with the generated values.
useNumGPUInteger specifying how many devices to use. 0 = Implementation decides.

References skepu::Matrix< T >::at(), MAX_GPU_DEVICES, and skepu::printCLError().

Here is the call graph for this function:

template<typename GenerateFunc >
template<typename OutputIterator >
void skepu::Generate< GenerateFunc >::CL ( size_t  numElements,
OutputIterator  outputBegin,
int  useNumGPU = 1 
)

Generates a number of elements using the user function which the skeleton was created with. The elements are saved in an output range. For the OpenCL backend. Calls generateNumDevices_CL(size_t numElements, OutputIterator outputBegin, int useNumGPU).

Parameters
numElementsThe number of elements to be generated.
outputBeginAn iterator pointing to the first element in the range which will be overwritten with generated values.
useNumGPUInteger specifying how many devices to use. 0 = Implementation decides.
template<typename GenerateFunc >
template<typename T >
void skepu::Generate< GenerateFunc >::CPU ( size_t  numElements,
Vector< T > &  output 
)

Generates a number of elements using the user function which the skeleton was created with. The elements are saved in an output vector which is resized to numElements. A wrapper for CPU(size_t numElements, OutputIterator outputBegin). For the CPU backend.

Parameters
numElementsThe number of elements to be generated.
outputThe output vector which will be overwritten with the generated values.

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

Here is the call graph for this function:

template<typename GenerateFunc >
template<typename T >
void skepu::Generate< GenerateFunc >::CPU ( size_t  numRows,
size_t  numCols,
Matrix< T > &  output 
)

Generates a number of elements using the user function which the skeleton was created with. The elements are saved in an output matrix which is resized to numElements. For the CPU backend.

Parameters
numRowsThe number of rows to be generated.
numColsThe number of columns to be generated.
outputThe output matrix which will be overwritten with the generated values.
template<typename GenerateFunc >
template<typename OutputIterator >
void skepu::Generate< GenerateFunc >::CPU ( size_t  numElements,
OutputIterator  outputBegin 
)

Generates a number of elements using the user function which the skeleton was created with. The elements are saved in an output range. For the CPU backend.

Parameters
numElementsThe number of elements to be generated.
outputBeginAn iterator pointing to the first element in the range which will be overwritten with generated values.
template<typename GenerateFunc >
template<typename T >
void skepu::Generate< GenerateFunc >::CU ( size_t  numElements,
Vector< T > &  output,
int  useNumGPU = 1 
)

Generates a number of elements using the user function which the skeleton was created with. The elements are saved in an output vector which is resized to numElements. A wrapper for CU(size_t numElements, OutputIterator outputBegin, int useNumGPU). For the CUDA backend.

Parameters
numElementsThe number of elements to be generated.
outputThe output vector which will be overwritten with the generated values.
useNumGPUInteger specifying how many devices to use. 0 = Implementation decides.

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

Here is the call graph for this function:

template<typename GenerateFunc >
template<typename T >
void skepu::Generate< GenerateFunc >::CU ( size_t  numRows,
size_t  numCols,
Matrix< T > &  output,
int  useNumGPU = 1 
)

Generates a number of elements using the user function which the skeleton was created with. The elements are saved in an output matrix which is resized to numElements. For the CUDA backend.

Parameters
numRowsThe number of rows to be generated.
numColsThe number of columns to be generated.
outputThe output matrix which will be overwritten with the generated values.
useNumGPUInteger specifying how many devices to use. 0 = Implementation decides.

References skepu::GenerateKernel_CU_Matrix(), and MAX_GPU_DEVICES.

Here is the call graph for this function:

template<typename GenerateFunc >
template<typename OutputIterator >
void skepu::Generate< GenerateFunc >::CU ( size_t  numElements,
OutputIterator  outputBegin,
int  useNumGPU = 1 
)

Generates a number of elements using the user function which the skeleton was created with. The elements are saved in an output range. For the CUDA backend. Decides whether to use one device and generateSingleThread_CU or multiple devices and create new threads which calls generateThreadFunc_CU. In the case of several devices the input range is divided evenly among the threads created.

Parameters
numElementsThe number of elements to be generated.
outputBeginAn iterator pointing to the first element in the range which will be overwritten with generated values.
useNumGPUInteger specifying how many devices to use. 0 = Implementation decides.

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

Here is the call graph for this function:

template<typename GenerateFunc >
void skepu::Generate< GenerateFunc >::finishAll ( )
inline

Makes sure all operations on devices are finished.

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

Here is the call graph for this function:

template<typename GenerateFunc >
template<typename T >
void skepu::Generate< GenerateFunc >::OMP ( size_t  numElements,
Vector< T > &  output 
)

Generates a number of elements using the user function which the skeleton was created with. The elements are saved in an output vector which is resized to numElements. A wrapper for OMP(size_t numElements, OutputIterator outputBegin). For the OpenMP backend.

Parameters
numElementsThe number of elements to be generated.
outputThe output vector which will be overwritten with the generated values.

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

Here is the call graph for this function:

template<typename GenerateFunc >
template<typename T >
void skepu::Generate< GenerateFunc >::OMP ( size_t  numRows,
size_t  numCols,
Matrix< T > &  output 
)

Generates a number of elements using the user function which the skeleton was created with. The elements are saved in an output matrix which is resized to numElements. For the OpenMP backend.

Parameters
numRowsThe number of rows to be generated.
numColsThe number of columns to be generated.
outputThe output matrix which will be overwritten with the generated values.
template<typename GenerateFunc >
template<typename OutputIterator >
void skepu::Generate< GenerateFunc >::OMP ( size_t  numElements,
OutputIterator  outputBegin 
)

Generates a number of elements using the user function which the skeleton was created with. The elements are saved in an output range. For the OpenMP backend.

Parameters
numElementsThe number of elements to be generated.
outputBeginAn iterator pointing to the first element in the range which will be overwritten with generated values.
template<typename GenerateFunc >
template<typename T >
void skepu::Generate< GenerateFunc >::operator() ( size_t  numElements,
Vector< T > &  output 
)

Generates a number of elements using the user function which the skeleton was created with. The elements are saved in an output vector.

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
numElementsThe number of elements to be generated.
outputThe output vector which will be overwritten with the generated values.
template<typename GenerateFunc >
template<typename T >
void skepu::Generate< GenerateFunc >::operator() ( size_t  numRows,
size_t  numCols,
Matrix< T > &  output 
)

Generates a number of elements for a matrix object using the user function which the skeleton was created with. The elements are saved in an output matrix.

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
numRowsThe number of rows to be generated.
numColsThe number of columns to be generated.
outputThe output matrix which will be overwritten with the generated values.
template<typename GenerateFunc >
template<typename OutputIterator >
void skepu::Generate< GenerateFunc >::operator() ( size_t  numElements,
OutputIterator  outputBegin 
)

Generates a number of elements using the user function which the skeleton was created with. The elements are saved in an output 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
numElementsThe number of elements to be generated.
outputBeginAn iterator pointing to the first element in the range which will be overwritten with generated values.
template<typename GenerateFunc >
template<typename T >
void skepu::Generate< GenerateFunc >::setConstant ( constant1)
inline

This function sets the constant that can be used in the generate user function.


The documentation for this class was generated from the following files: