Public Member Functions

skepu::Reduce< ReduceFunc > Class Template Reference
[Skeletons]

A class representing the Reduce skeleton. More...

#include <reduce.h>

Collaboration diagram for skepu::Reduce< ReduceFunc >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Reduce (ReduceFunc *reduceFunc)
 ~Reduce ()
template<typename T >
operator() (Vector< T > &input)
template<typename InputIterator >
InputIterator::value_type operator() (InputIterator inputBegin, InputIterator inputEnd)
template<typename T >
CPU (Vector< T > &input)
template<typename InputIterator >
InputIterator::value_type CPU (InputIterator inputBegin, InputIterator inputEnd)
template<typename T >
OMP (Vector< T > &input)
template<typename InputIterator >
InputIterator::value_type OMP (InputIterator inputBegin, InputIterator inputEnd)
template<typename 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 >
CL (Vector< T > &input, int useNumGPU=1)
template<typename InputIterator >
InputIterator::value_type CL (InputIterator inputBegin, InputIterator inputEnd, int useNumGPU=1)

Detailed Description

template<typename ReduceFunc>
class skepu::Reduce< ReduceFunc >

A class representing the Reduce skeleton.

Author:
Johan Enmyren
Version:
0.6

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.


Constructor & Destructor Documentation

template<typename ReduceFunc >
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.

Parameters:
reduceFunc A pointer to a valid binary user function. Will be deleted in the destructor.
template<typename ReduceFunc >
skepu::Reduce< ReduceFunc >::~Reduce (  ) 

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


Member Function Documentation

template<typename ReduceFunc >
template<typename T >
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.

Parameters:
input A vector which the reduction will be performed on.
useNumGPU Integer specifying how many devices to use. 0 = implementation decides.
Returns:
The scalar result of the reduction performed.

References skepu::Vector< T >::begin(), and skepu::Vector< T >::end().

Here is the call graph for this function:

template<typename ReduceFunc >
template<typename InputIterator >
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.

Parameters:
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.
Returns:
The scalar result of the reduction performed.
template<typename ReduceFunc >
template<typename T >
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.

Parameters:
input A vector which the reduction will be performed on.
Returns:
The scalar result of the reduction performed.

References skepu::Vector< T >::begin(), and skepu::Vector< T >::end().

Here is the call graph for this function:

template<typename ReduceFunc >
template<typename InputIterator >
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.

Parameters:
inputBegin A Vector::iterator to the first element in the range.
inputEnd A Vector::iterator to the last element of the range.
Returns:
The scalar result of the reduction performed.
template<typename ReduceFunc >
template<typename InputIterator >
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.

Parameters:
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.
Returns:
The scalar result of the reduction performed.

References skepu::Threads::fork(), and skepu::Threads::join().

Here is the call graph for this function:

template<typename ReduceFunc >
template<typename T >
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.

Parameters:
input A vector which the reduction will be performed on.
useNumGPU Integer specifying how many devices to use. 0 = implementation decides.
Returns:
The scalar result of the reduction performed.

References skepu::Vector< T >::begin(), and skepu::Vector< T >::end().

Here is the call graph for this function:

template<typename ReduceFunc >
template<typename InputIterator >
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.

Parameters:
inputBegin A Vector::iterator to the first element in the range.
inputEnd A Vector::iterator to the last element of the range.
Returns:
The scalar result of the reduction performed.
template<typename ReduceFunc >
template<typename T >
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.

Parameters:
input A vector which the reduction will be performed on.
Returns:
The scalar result of the reduction performed.

References skepu::Vector< T >::begin(), and skepu::Vector< T >::end().

Here is the call graph for this function:

template<typename ReduceFunc >
template<typename T >
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.

Parameters:
input A vector which the reduction will be performed on.
Returns:
The scalar result of the reduction performed.

References skepu::Reduce< ReduceFunc >::CL(), skepu::Reduce< ReduceFunc >::CPU(), skepu::Reduce< ReduceFunc >::CU(), skepu::Reduce< ReduceFunc >::OMP(), and skepu::Vector< T >::size().

Here is the call graph for this function:

template<typename ReduceFunc >
template<typename InputIterator >
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.

Parameters:
inputBegin A Vector::iterator to the first element in the range.
inputEnd A Vector::iterator to the last element of the range.
Returns:
The scalar result of the reduction performed.

References skepu::Reduce< ReduceFunc >::CL(), skepu::Reduce< ReduceFunc >::CPU(), skepu::Reduce< ReduceFunc >::CU(), and skepu::Reduce< ReduceFunc >::OMP().

Here is the call graph for this function:


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Enumerations Friends Defines