|
SkePU 0.7
|
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() (unsigned int numElements, Vector< 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 OutputIterator > | |
| void | CPU (unsigned int numElements, OutputIterator outputBegin) |
| template<typename T > | |
| void | OMP (unsigned int numElements, Vector< 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 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 OutputIterator > | |
| void | CL (unsigned int numElements, OutputIterator outputBegin, int useNumGPU=1) |
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. 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 two overloaded versions of this operator, one which takes iterators as inputs and one that takes whole vectors. The vector variants are merely wrappers for the functions which takes iterators as parameters.
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.
| 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.
| generateFunc | A pointer to a valid user function. Will be deleted in the destructor. |
References skepu::Environment< T >::getInstance().

| skepu::Generate< GenerateFunc >::~Generate | ( | ) |
When the Generate skeleton is destroyed, it deletes the user function it was created with.
| 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.
| numElements | The number of elements to be generated. |
| output | The output vector which will be overwritten with the generated values. |
| useNumGPU | Integer 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().

| 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).
| numElements | The number of elements to be generated. |
| outputBegin | An iterator pointing to the first element in the range which will be overwritten with generated values. |
| useNumGPU | Integer specifying how many devices to use. 0 = Implementation decides. |
| 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.
| numElements | The number of elements to be generated. |
| outputBegin | An iterator pointing to the first element in the range which will be overwritten with generated values. |
| 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.
| numElements | The number of elements to be generated. |
| output | The 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().

| 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.
| numElements | The number of elements to be generated. |
| output | The output vector which will be overwritten with the generated values. |
| useNumGPU | Integer 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().

| 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.
| numElements | The number of elements to be generated. |
| outputBegin | An iterator pointing to the first element in the range which will be overwritten with generated values. |
| useNumGPU | Integer specifying how many devices to use. 0 = Implementation decides. |
References skepu::GenerateKernel_CU(), skepu::max(), MAX_GPU_DEVICES, and skepu::min().

| void skepu::Generate< GenerateFunc >::finishAll | ( | ) | [inline] |
Makes sure all operations on devices are finished.
References skepu::Environment< T >::finishAll().

| 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.
| numElements | The number of elements to be generated. |
| outputBegin | An iterator pointing to the first element in the range which will be overwritten with generated values. |
| 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.
| numElements | The number of elements to be generated. |
| output | The 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().

| 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.
| numElements | The number of elements to be generated. |
| outputBegin | An iterator pointing to the first element in the range which will be overwritten with generated values. |
| 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.
| numElements | The number of elements to be generated. |
| output | The output vector which will be overwritten with the generated values. |
| void skepu::Generate< GenerateFunc >::setConstant | ( | T | constant1 | ) | [inline] |
This function sets the constant that can be used in the generate user function.
1.7.4