SkePU  1.2
 All Classes Namespaces Files Functions Variables Enumerations Friends Macros Groups Pages
Public Member Functions | List of all members
skepu::Reduce< ReduceFuncRowWise, ReduceFuncColWise > Class Template Reference

A class representing the Reduce skeleton both for 1D and 2D reduce operation for 1D Vector, 2D Dense Matrix/Sparse matrices. More...

#include <reduce.h>

Public Member Functions

 Reduce (ReduceFuncRowWise *reduceFuncRowWise, ReduceFuncColWise *reduceFuncColWise)
 
 ~Reduce ()
 
template<typename T >
operator() (Matrix< T > &input)
 
template<typename T >
operator() (SparseMatrix< T > &input)
 
template<typename T >
CPU (Matrix< T > &input)
 
template<typename T >
CPU (SparseMatrix< T > &input)
 
template<typename T >
OMP (Matrix< T > &input)
 
template<typename T >
OMP (SparseMatrix< T > &input)
 
template<typename T >
CU (Matrix< T > &input, int useNumGPU=1)
 
template<typename T >
CU (SparseMatrix< T > &input, int useNumGPU=1)
 
template<typename T >
CL (Matrix< T > &input, int useNumGPU=1)
 
template<typename T >
CL (SparseMatrix< T > &input, int useNumGPU=1)
 

Detailed Description

template<typename ReduceFuncRowWise, typename ReduceFuncColWise = ReduceFuncRowWise>
class skepu::Reduce< ReduceFuncRowWise, ReduceFuncColWise >

A class representing the Reduce skeleton both for 1D and 2D reduce operation for 1D Vector, 2D Dense Matrix/Sparse matrices.

This class defines the Reduce skeleton which support following reduction operations: (a) (1D Reduction) Each element in the input range, yielding a scalar result by applying a commutative associative binary operator. Here we consider dense/sparse matrix as vector thus reducing all (non-zero) elements of the matrix. (b) (1D Reduction) Dense/Sparse matrix types: Where we reduce either row-wise or column-wise by applying a commutative associative binary operator. It returns a SkePU vector of results that corresponds to reduction on either dimension. (c) (2D Reduction) Dense/Sparse matrix types: Where we reduce both row- and column-wise by applying two commutative associative binary operators, one for row-wise reduction and one for column-wise reduction. It returns a scalar result. Two versions of this class are created using C++ partial class-template specialization to support (a) 1D reduction (where a "single" reduction operator is applied on all elements or to 1 direction for 2D Dense/Sparse matrix). (b) 2D reduction that works only for matrix (where two different reduction operations are used to reduce row-wise and column-wise separately.) Once instantiated, it is meant to be used as a function and therefore overloading operator(). The Reduce skeleton needs to be created with a 1 or 2 binary user function for 1D reduction and 2D reduction respectively.

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 ReduceFuncRowWise , typename ReduceFuncColWise >
skepu::Reduce< ReduceFuncRowWise, ReduceFuncColWise >::Reduce ( ReduceFuncRowWise *  reduceFuncRowWise,
ReduceFuncColWise *  reduceFuncColWise 
)

When creating an instance of the 2D Reduce (First row-wise then column-wise) 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
reduceFuncRowWiseA pointer to a valid binary user function used for row-wise reduction. Will be deleted in the destructor.
reduceFuncColWiseA pointer to a valid binary user function used for columns-wise reduction. Will be deleted in the destructor.

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

Here is the call graph for this function:

template<typename ReduceFuncRowWise , typename ReduceFuncColWise >
skepu::Reduce< ReduceFuncRowWise, ReduceFuncColWise >::~Reduce ( )

When the 2D Reduce skeleton is destroyed, it deletes the user functions it was created with.

Member Function Documentation

template<typename ReduceFuncRowWise , typename ReduceFuncColWise >
template<typename T >
T skepu::Reduce< ReduceFuncRowWise, ReduceFuncColWise >::CL ( Matrix< T > &  input,
int  useNumGPU = 1 
)

Performs the 2D Reduction (First row-wise then column-wise) on an input matrix by using OpenCL backend. Returns a scalar result. The function can be applied by any number of OpenCL devices, thus internally calling the reduceSingle_CL or reduceNumDevices_CL depending upon number of OpenCL devices specified/available.

Parameters
inputAn input matrix whose elements need to be reduced.
useNumGPUInteger specifying how many devices to use. 0 = implementation decides.
Returns
The scalar result of the 2D reduction performed.

Referenced by skepu::Reduce< ReduceFunc, ReduceFunc >::CL(), and skepu::Reduce< ReduceFunc, ReduceFunc >::operator()().

template<typename ReduceFuncRowWise , typename ReduceFuncColWise >
template<typename T >
T skepu::Reduce< ReduceFuncRowWise, ReduceFuncColWise >::CL ( SparseMatrix< T > &  input,
int  useNumGPU = 1 
)

Performs the 2D Reduction (First row-wise then column-wise) on an input sparse matrix by using OpenCL backend. Returns a scalar result. The function can be applied by any number of OpenCL devices, thus internally calling the reduceSingle_CL or reduceNumDevices_CL depending upon number of OpenCL devices specified/available.

Parameters
inputAn input sparse matrix whose elements need to be reduced.
useNumGPUInteger specifying how many devices to use. 0 = implementation decides.
Returns
The scalar result of the 2D reduction performed.
template<typename ReduceFuncRowWise , typename ReduceFuncColWise >
template<typename T >
T skepu::Reduce< ReduceFuncRowWise, ReduceFuncColWise >::CPU ( Matrix< T > &  input)

Performs the 2D Reduction (First row-wise then column-wise) on a input Matrix. Returns a scalar result. Using the CPU as backend.

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

Referenced by skepu::Reduce< ReduceFunc, ReduceFunc >::CPU(), skepu::cpu_tune_wrapper_reduce(), and skepu::Reduce< ReduceFunc, ReduceFunc >::operator()().

template<typename ReduceFuncRowWise , typename ReduceFuncColWise >
template<typename T >
T skepu::Reduce< ReduceFuncRowWise, ReduceFuncColWise >::CPU ( SparseMatrix< T > &  input)

Performs the 2D Reduction (First row-wise then column-wise) on a input Sparse Matrix. Returns a scalar result. Using the CPU as backend.

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

References skepu::SparseMatrix< T >::begin(), skepu::SparseMatrix< T >::total_cols(), skepu::SparseMatrix< T >::total_nnz(), skepu::SparseMatrix< T >::total_rows(), and skepu::SparseMatrix< T >::updateHost().

Here is the call graph for this function:

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

Performs the 2D Reduction (First row-wise then column-wise) on an input matrix by using CUDA backend. Returns a scalar result. The function can be applied by any number of CUDA devices, thus internally calling the reduceSingle_CL or reduceNumDevices_CL depending upon number of CUDA devices specified/available.

Parameters
inputAn input matrix whose elements need to be reduced.
useNumGPUInteger specifying how many devices to use. 0 = implementation decides.
Returns
The scalar result of the 2D reduction performed.

Referenced by skepu::Reduce< ReduceFunc, ReduceFunc >::CU(), skepu::cuda_tune_wrapper_reduce(), and skepu::Reduce< ReduceFunc, ReduceFunc >::operator()().

template<typename ReduceFuncRowWise , typename ReduceFuncColWise >
template<typename T >
T skepu::Reduce< ReduceFuncRowWise, ReduceFuncColWise >::CU ( SparseMatrix< T > &  input,
int  useNumGPU = 1 
)

Performs the 2D Reduction (First row-wise then column-wise) on a input Sparse Matrix. Returns a scalar result. Using the CUDA as backend. The function can be applied by any number of CUDA devices, thus internally calling the reduceSingle_CL or reduceNumDevices_CL depending upon number of CUDA devices specified/available.

Parameters
inputAn input sparse matrix whose elements need to be reduced.
useNumGPUInteger specifying how many devices to use. 0 = implementation decides.
Returns
The scalar result of the 2D reduction performed.
template<typename ReduceFuncRowWise , typename ReduceFuncColWise >
template<typename T >
T skepu::Reduce< ReduceFuncRowWise, ReduceFuncColWise >::OMP ( Matrix< T > &  input)

Performs the 2D Reduction (First row-wise then column-wise) on a input Matrix. Returns a scalar result. Using the OpenMP as backend.

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

Referenced by skepu::Reduce< ReduceFunc, ReduceFunc >::OMP(), skepu::omp_tune_wrapper_reduce(), and skepu::Reduce< ReduceFunc, ReduceFunc >::operator()().

template<typename ReduceFuncRowWise , typename ReduceFuncColWise >
template<typename T >
T skepu::Reduce< ReduceFuncRowWise, ReduceFuncColWise >::OMP ( SparseMatrix< T > &  input)

Performs the 2D Reduction (First row-wise then column-wise) on a input Sparse Matrix. Returns a scalar result. Using the CPU as backend.

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

References skepu::SparseMatrix< T >::total_nnz(), skepu::SparseMatrix< T >::total_rows(), and skepu::SparseMatrix< T >::updateHost().

Here is the call graph for this function:

template<typename ReduceFuncRowWise , typename ReduceFuncColWise >
template<typename T >
T skepu::Reduce< ReduceFuncRowWise, ReduceFuncColWise >::operator() ( Matrix< T > &  input)

Performs the 2D Reduction (First row-wise then column-wise) 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 on which the 2D reduction will be performed on.
Returns
The scalar result of the 2D reduction performed.

It might be the case that in a complex program suchg as SPH, some skeleton obj use default exec plan as are not perf relevant...

template<typename ReduceFuncRowWise , typename ReduceFuncColWise >
template<typename T >
T skepu::Reduce< ReduceFuncRowWise, ReduceFuncColWise >::operator() ( SparseMatrix< T > &  input)

Performs the 2D Reduction (First row-wise then column-wise) 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 on which the 2D reduction will be performed on.
Returns
The scalar result of the 2D reduction performed.

It might be the case that in a complex program suchg as SPH, some skeleton obj use default exec plan as are not perf relevant...

References skepu::SparseMatrix< T >::isModified_CU(), skepu::SparseMatrix< T >::isSparseMatrixOnDevice_CU(), skepu::SparseMatrix< T >::total_cols(), skepu::SparseMatrix< T >::total_nnz(), and skepu::SparseMatrix< T >::total_rows().

Here is the call graph for this function:


The documentation for this class was generated from the following files: