SkePU 1.0
Public Member Functions
skepu::Generate< GenerateFunc > Class Template Reference

A class representing the Generate skeleton. More...

#include <generate.h>

Collaboration diagram for skepu::Generate< GenerateFunc >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Generate (GenerateFunc *generateFunc)
 ~Generate ()
template<typename T >
void setConstant (T constant1)
void finishAll ()
template<typename T >
void operator() (unsigned int numElements, Vector< T > &output)
template<typename T >
void operator() (unsigned int numRows, unsigned int numCols, Matrix< T > &output)
template<typename OutputIterator >
void operator() (unsigned int numElements, OutputIterator outputBegin)
template<typename T >
void CPU (unsigned int numElements, Vector< T > &output)
template<typename T >
void CPU (unsigned int numRows, unsigned int numCols, Matrix< T > &output)
template<typename OutputIterator >
void CPU (unsigned int numElements, OutputIterator outputBegin)
template<typename T >
void OMP (unsigned int numElements, Vector< T > &output)
template<typename T >
void OMP (unsigned int numRows, unsigned int numCols, Matrix< T > &output)
template<typename OutputIterator >
void OMP (unsigned int numElements, OutputIterator outputBegin)
template<typename T >
void CU (unsigned int numElements, Vector< T > &output, int useNumGPU=1)
template<typename T >
void CU (unsigned int numRows, unsigned int numCols, Matrix< T > &output, int useNumGPU=1)
template<typename OutputIterator >
void CU (unsigned int numElements, OutputIterator outputBegin, int useNumGPU=1)
template<typename T >
void CL (unsigned int numElements, Vector< T > &output, int useNumGPU=1)
template<typename T >
void CL (unsigned int numRows, unsigned int numCols, Matrix< T > &output, int useNumGPU=1)
template<typename OutputIterator >
void CL (unsigned int 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 ( unsigned int  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(unsigned int 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 ( unsigned int  numRows,
unsigned int  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::DeviceMemPointer_CL< T >::changeDeviceData(), skepu::Matrix< T >::clear(), skepu::DeviceMemPointer_CL< T >::getDeviceDataPointer(), MAX_GPU_DEVICES, skepu::Matrix< T >::resize(), skepu::Matrix< T >::total_cols(), skepu::Matrix< T >::total_rows(), and skepu::Matrix< T >::updateDevice_CL().

Here is the call graph for this function:

template<typename GenerateFunc >
template<typename OutputIterator >
void skepu::Generate< GenerateFunc >::CL ( unsigned int  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(unsigned int numElements, OutputIterator outputBegin, int numDevices).

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 ( unsigned int  numRows,
unsigned int  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.

References skepu::Matrix< T >::clear(), skepu::Matrix< T >::invalidateDevice(), skepu::Matrix< T >::resize(), skepu::Matrix< T >::total_cols(), and skepu::Matrix< T >::total_rows().

Here is the call graph for this function:

template<typename GenerateFunc >
template<typename OutputIterator >
void skepu::Generate< GenerateFunc >::CPU ( unsigned int  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 >::CPU ( unsigned int  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(unsigned int 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 OutputIterator >
void skepu::Generate< GenerateFunc >::CU ( unsigned int  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 >
template<typename T >
void skepu::Generate< GenerateFunc >::CU ( unsigned int  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(unsigned int 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 ( unsigned int  numRows,
unsigned int  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::DeviceMemPointer_CU< T >::changeDeviceData(), skepu::Matrix< T >::clear(), skepu::GenerateKernel_CU_Matrix(), skepu::DeviceMemPointer_CU< T >::getDeviceDataPointer(), MAX_GPU_DEVICES, skepu::Matrix< T >::resize(), skepu::Matrix< T >::total_cols(), skepu::Matrix< T >::total_rows(), and skepu::Matrix< T >::updateDevice_CU().

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 OutputIterator >
void skepu::Generate< GenerateFunc >::OMP ( unsigned int  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 >::OMP ( unsigned int  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(unsigned int 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 ( unsigned int  numRows,
unsigned int  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.

References skepu::Matrix< T >::clear(), skepu::Matrix< T >::invalidateDevice(), skepu::Matrix< T >::resize(), skepu::Matrix< T >::total_cols(), and skepu::Matrix< T >::total_rows().

Here is the call graph for this function:

template<typename GenerateFunc >
template<typename T >
void skepu::Generate< GenerateFunc >::operator() ( unsigned int  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 OutputIterator >
void skepu::Generate< GenerateFunc >::operator() ( unsigned int  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 >::operator() ( unsigned int  numRows,
unsigned int  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 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:
 All Classes Namespaces Files Functions Enumerations Friends Defines