A class representing the Reduce skeleton. More...
#include <reduce.h>

Public Member Functions | |
| Reduce (ReduceFunc *reduceFunc) | |
| ~Reduce () | |
| template<typename T > | |
| T | operator() (Vector< T > &input) |
| template<typename InputIterator > | |
| InputIterator::value_type | operator() (InputIterator inputBegin, InputIterator inputEnd) |
| template<typename T > | |
| T | CPU (Vector< T > &input) |
| template<typename InputIterator > | |
| InputIterator::value_type | CPU (InputIterator inputBegin, InputIterator inputEnd) |
| template<typename T > | |
| T | OMP (Vector< T > &input) |
| template<typename InputIterator > | |
| InputIterator::value_type | OMP (InputIterator inputBegin, InputIterator inputEnd) |
| template<typename T > | |
| T | CU (Vector< T > &input, int useNumGPU=1) |
| template<typename InputIterator > | |
| InputIterator::value_type | CU (InputIterator inputBegin, InputIterator inputEnd, int useNumGPU=1) |
| template<typename T > | |
| T | CL (Vector< T > &input, int useNumGPU=1) |
| template<typename InputIterator > | |
| InputIterator::value_type | CL (InputIterator inputBegin, InputIterator inputEnd, int useNumGPU=1) |
A class representing the Reduce skeleton.
This class defines the Reduce skeleton which applies a commutative associative binary operator between each element in the input range, yielding a scalar result. Once instantiated, it is meant to be used as a function and therefore overloading operator(). There are two overloaded variants of this operator one which takes iterators as inputs and one which takes a vector. The vector variant is merely a wrapper for the iterator one. The Reduce skeleton needs to be created with a binary user function.
If a certain backend 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.
The Reduce skeleton also includes a pointer to an Environment which includes the devices available to execute on.
| skepu::Reduce< ReduceFunc >::Reduce | ( | ReduceFunc * | reduceFunc | ) |
When creating an instance of the Reduce skeleton, a pointer to a binary 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.
| reduceFunc | A pointer to a valid binary user function. Will be deleted in the destructor. |
| skepu::Reduce< ReduceFunc >::~Reduce | ( | ) |
When the Reduce skeleton is destroyed, it deletes the user function it was created with.
| T skepu::Reduce< ReduceFunc >::CL | ( | Vector< T > & | input, | |
| int | useNumGPU = 1 | |||
| ) |
Performs the Reduction on a whole Vector. Returns a scalar result. A wrapper for CL(InputIterator inputBegin, InputIterator inputEnd, int useNumGPU). Using OpenCL as backend.
| input | A vector which the reduction will be performed on. | |
| useNumGPU | Integer specifying how many devices to use. 0 = implementation decides. |
References skepu::Vector< T >::begin(), and skepu::Vector< T >::end().

| InputIterator::value_type skepu::Reduce< ReduceFunc >::CL | ( | InputIterator | inputBegin, | |
| InputIterator | inputEnd, | |||
| int | useNumGPU = 1 | |||
| ) |
Performs the Reduction on a range of elements. Returns a scalar result. The function decides whether to perform the reduction on one device, calling reduceSingle_CL(InputIterator inputBegin, InputIterator inputEnd, int deviceID) or on multiple devices, calling reduceNumDevices_CL(InputIterator inputBegin, InputIterator inputEnd, int numDevices). Using OpenCL as backend.
| inputBegin | A Vector::iterator to the first element in the range. | |
| inputEnd | A Vector::iterator to the last element of the range. | |
| useNumGPU | Integer specifying how many devices to use. 0 = implementation decides. |
| T skepu::Reduce< ReduceFunc >::CPU | ( | Vector< T > & | input | ) |
Performs the Reduction on a whole Vector. Returns a scalar result. A wrapper for CPU(InputIterator inputBegin, InputIterator inputEnd). Using the CPU as backend.
| input | A vector which the reduction will be performed on. |
References skepu::Vector< T >::begin(), and skepu::Vector< T >::end().

| InputIterator::value_type skepu::Reduce< ReduceFunc >::CPU | ( | InputIterator | inputBegin, | |
| InputIterator | inputEnd | |||
| ) |
Performs the Reduction on a range of elements. Returns a scalar result. Does the reduction on the CPU by iterating over all elements in the range.
| inputBegin | A Vector::iterator to the first element in the range. | |
| inputEnd | A Vector::iterator to the last element of the range. |
| InputIterator::value_type skepu::Reduce< ReduceFunc >::CU | ( | InputIterator | inputBegin, | |
| InputIterator | inputEnd, | |||
| int | useNumGPU = 1 | |||
| ) |
Performs the Reduction on a range of elements. Returns a scalar result. The function decides whether to perform the reduction on one device, calling reduceSingleThread_CU(InputIterator inputBegin, InputIterator inputEnd, int deviceID) or on multiple devices, starting one new host thread per device and at the end reducing each threads result on the CPU.
| inputBegin | A Vector::iterator to the first element in the range. | |
| inputEnd | A Vector::iterator to the last element of the range. | |
| useNumGPU | Integer specifying how many devices to use. 0 = implementation decides. |
References skepu::Threads::fork(), and skepu::Threads::join().

| T skepu::Reduce< ReduceFunc >::CU | ( | Vector< T > & | input, | |
| int | useNumGPU = 1 | |||
| ) |
Performs the Reduction on a whole Vector. Returns a scalar result. A wrapper for CU(InputIterator inputBegin, InputIterator inputEnd, int useNumGPU). Using CUDA as backend.
| input | A vector which the reduction will be performed on. | |
| useNumGPU | Integer specifying how many devices to use. 0 = implementation decides. |
References skepu::Vector< T >::begin(), and skepu::Vector< T >::end().

| InputIterator::value_type skepu::Reduce< ReduceFunc >::OMP | ( | InputIterator | inputBegin, | |
| InputIterator | inputEnd | |||
| ) |
Performs the Reduction on a range of elements. Returns a scalar result. Divides the elements among all OpenMP threads and does reduction of the parts in parallel. The results from each thread are then reduced on the CPU.
| inputBegin | A Vector::iterator to the first element in the range. | |
| inputEnd | A Vector::iterator to the last element of the range. |
| T skepu::Reduce< ReduceFunc >::OMP | ( | Vector< T > & | input | ) |
Performs the Reduction on a whole Vector. Returns a scalar result. A wrapper for OMP(InputIterator inputBegin, InputIterator inputEnd). Using OpenMP as backend.
| input | A vector which the reduction will be performed on. |
References skepu::Vector< T >::begin(), and skepu::Vector< T >::end().

| T skepu::Reduce< ReduceFunc >::operator() | ( | Vector< T > & | input | ) |
Performs the Reduction on a whole Vector. Returns a scalar result.
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.
| input | A vector which the reduction will be performed on. |
References skepu::Reduce< ReduceFunc >::CL(), skepu::Reduce< ReduceFunc >::CPU(), skepu::Reduce< ReduceFunc >::CU(), skepu::Reduce< ReduceFunc >::OMP(), and skepu::Vector< T >::size().

| InputIterator::value_type skepu::Reduce< ReduceFunc >::operator() | ( | InputIterator | inputBegin, | |
| InputIterator | inputEnd | |||
| ) |
Performs the Reduction on a range of elements. Returns a scalar result.
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.
| inputBegin | A Vector::iterator to the first element in the range. | |
| inputEnd | A Vector::iterator to the last element of the range. |
References skepu::Reduce< ReduceFunc >::CL(), skepu::Reduce< ReduceFunc >::CPU(), skepu::Reduce< ReduceFunc >::CU(), and skepu::Reduce< ReduceFunc >::OMP().

1.7.1