SkePU 0.7
Public Member Functions
skepu::Reduce< ReduceFunc > Class Template Reference

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 T >
operator() (Matrix< T > &input)
template<typename InputIterator >
InputIterator::value_type operator() (InputIterator inputBegin, InputIterator inputEnd)
template<typename T >
CPU (Vector< T > &input)
template<typename T >
CPU (Matrix< T > &input)
template<typename InputIterator >
InputIterator::value_type CPU (InputIterator inputBegin, InputIterator inputEnd)
template<typename T >
OMP (Vector< T > &input)
template<typename T >
OMP (Matrix< 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 T >
CU (Matrix< 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 T >
CL (Matrix< 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.

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 container (vector, matrix). The container 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:
reduceFuncA pointer to a valid binary user function. Will be deleted in the destructor.

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

Here is the call graph for this function:

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:
inputA vector which the reduction will be performed on.
useNumGPUInteger 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 T >
T skepu::Reduce< ReduceFunc >::CL ( Matrix< T > &  input,
int  useNumGPU = 1 
)

Performs the Reduction on a whole Matrix. Returns a scalar result. A wrapper for CL(InputIterator inputBegin, InputIterator inputEnd, int useNumGPU). Using OpenCL as backend.

Parameters:
inputA matrix which the reduction will be performed on.
useNumGPUInteger specifying how many devices to use. 0 = implementation decides.
Returns:
The scalar result of the reduction performed.

References skepu::Matrix< T >::begin(), and skepu::Matrix< 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:
inputBeginAn iterator to the first element in the range.
inputEndAn iterator to the last element of the range.
useNumGPUInteger specifying how many devices to use. 0 = implementation decides.
Returns:
The scalar result of the reduction performed.
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:
inputBeginAn iterator to the first element in the range.
inputEndAn 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 >::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:
inputA 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 >::CPU ( Matrix< T > &  input)

Performs the Reduction on a whole Matrix. Returns a scalar result. A wrapper for CPU(InputIterator inputBegin, InputIterator inputEnd). Using the CPU as backend.

Parameters:
inputA matrix which the reduction will be performed on.
Returns:
The scalar result of the reduction performed.

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

Here is the call graph for this function:

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, dividing the range of elements equally among the participating devices each reducing its part. The results are then reduced themselves on the CPU.

Parameters:
inputBeginAn iterator to the first element in the range.
inputEndAn iterator to the last element of the range.
useNumGPUInteger specifying how many devices to use. 0 = implementation decides.
Returns:
The scalar result of the reduction performed.

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

Here is the call graph for this function:

template<typename ReduceFunc >
template<typename T >
T skepu::Reduce< ReduceFunc >::CU ( Matrix< T > &  input,
int  useNumGPU = 1 
)

Performs the Reduction on a whole Matrix. Returns a scalar result. A wrapper for CU(InputIterator inputBegin, InputIterator inputEnd, int useNumGPU). Using CUDA as backend.

Parameters:
inputA matrix which the reduction will be performed on.
useNumGPUInteger specifying how many devices to use. 0 = implementation decides.
Returns:
The scalar result of the reduction performed.

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

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:
inputA vector which the reduction will be performed on.
useNumGPUInteger 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 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:
inputA 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 >::OMP ( Matrix< T > &  input)

Performs the Reduction on a whole Matrix. Returns a scalar result. A wrapper for OMP(InputIterator inputBegin, InputIterator inputEnd). Using OpenMP as backend.

Parameters:
inputA matrix which the reduction will be performed on.
Returns:
The scalar result of the reduction performed.

References skepu::Matrix< T >::begin(), and skepu::Matrix< 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:
inputBeginAn iterator to the first element in the range.
inputEndAn 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 >::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:
inputBeginAn iterator to the first element in the range.
inputEndAn 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 >::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:
inputA vector which the reduction will be performed on.
Returns:
The scalar result of the reduction performed.

References skepu::Vector< T >::size().

Here is the call graph for this function:

template<typename ReduceFunc >
template<typename T >
T skepu::Reduce< ReduceFunc >::operator() ( Matrix< T > &  input)

Performs the Reduction on a whole Matrix. 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:
inputA matrix which the reduction will be performed on.
Returns:
The scalar result of the reduction performed.

References skepu::Matrix< T >::size().

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