SkePU 1.0

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 >  
T  operator() (Matrix< T > &input) 
template<typename T >  
T  operator() (SparseMatrix< T > &input) 
template<typename T >  
T  CPU (Matrix< T > &input) 
template<typename T >  
T  CPU (SparseMatrix< T > &input) 
template<typename T >  
T  OMP (Matrix< T > &input) 
template<typename T >  
T  OMP (SparseMatrix< T > &input) 
template<typename T >  
T  CU (Matrix< T > &input, int useNumGPU=1) 
template<typename T >  
T  CU (SparseMatrix< T > &input, int useNumGPU=1) 
template<typename T >  
T  CL (Matrix< T > &input, int useNumGPU=1) 
template<typename T >  
T  CL (SparseMatrix< T > &input, int useNumGPU=1) 
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 (nonzero) elements of the matrix. (b) (1D Reduction) Dense/Sparse matrix types: Where we reduce either rowwise or columnwise 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 columnwise by applying two commutative associative binary operators, one for rowwise reduction and one for columnwise reduction. It returns a scalar result. Two versions of this class are created using C++ partial classtemplate 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 rowwise and columnwise 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.
skepu::Reduce< ReduceFuncRowWise, ReduceFuncColWise >::Reduce  (  ReduceFuncRowWise *  reduceFuncRowWise, 
ReduceFuncColWise *  reduceFuncColWise  
) 
When creating an instance of the 2D Reduce (First rowwise then columnwise) 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.
reduceFuncRowWise  A pointer to a valid binary user function used for rowwise reduction. Will be deleted in the destructor. 
reduceFuncColWise  A pointer to a valid binary user function used for columnswise reduction. Will be deleted in the destructor. 
References skepu::Environment< T >::getInstance().
skepu::Reduce< ReduceFuncRowWise, ReduceFuncColWise >::~Reduce  (  ) 
When the 2D Reduce skeleton is destroyed, it deletes the user functions it was created with.
T skepu::Reduce< ReduceFuncRowWise, ReduceFuncColWise >::CL  (  Matrix< T > &  input, 
int  useNumGPU = 1 

) 
Performs the 2D Reduction (First rowwise then columnwise) 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.
input  An input matrix whose elements need to be reduced. 
useNumGPU  Integer specifying how many devices to use. 0 = implementation decides. 
T skepu::Reduce< ReduceFuncRowWise, ReduceFuncColWise >::CL  (  SparseMatrix< T > &  input, 
int  useNumGPU = 1 

) 
Performs the 2D Reduction (First rowwise then columnwise) 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.
input  An input sparse matrix whose elements need to be reduced. 
useNumGPU  Integer specifying how many devices to use. 0 = implementation decides. 
T skepu::Reduce< ReduceFuncRowWise, ReduceFuncColWise >::CPU  (  Matrix< T > &  input  ) 
Performs the 2D Reduction (First rowwise then columnwise) on a input Matrix. Returns a scalar result. Using the CPU as backend.
input  A matrix on which the 2D reduction will be performed on. 
References skepu::Matrix< T >::total_cols(), skepu::Matrix< T >::total_rows(), and skepu::Matrix< T >::updateHost().
T skepu::Reduce< ReduceFuncRowWise, ReduceFuncColWise >::CPU  (  SparseMatrix< T > &  input  ) 
Performs the 2D Reduction (First rowwise then columnwise) on a input Sparse Matrix. Returns a scalar result. Using the CPU as backend.
input  A sparse matrix on which the 2D reduction will be performed on. 
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().
T skepu::Reduce< ReduceFuncRowWise, ReduceFuncColWise >::CU  (  SparseMatrix< T > &  input, 
int  useNumGPU = 1 

) 
Performs the 2D Reduction (First rowwise then columnwise) 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.
input  An input sparse matrix whose elements need to be reduced. 
useNumGPU  Integer specifying how many devices to use. 0 = implementation decides. 
T skepu::Reduce< ReduceFuncRowWise, ReduceFuncColWise >::CU  (  Matrix< T > &  input, 
int  useNumGPU = 1 

) 
Performs the 2D Reduction (First rowwise then columnwise) 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.
input  An input matrix whose elements need to be reduced. 
useNumGPU  Integer specifying how many devices to use. 0 = implementation decides. 
T skepu::Reduce< ReduceFuncRowWise, ReduceFuncColWise >::OMP  (  SparseMatrix< T > &  input  ) 
Performs the 2D Reduction (First rowwise then columnwise) on a input Sparse Matrix. Returns a scalar result. Using the CPU as backend.
input  A sparse matrix on which the 2D reduction will be performed on. 
References skepu::SparseMatrix< T >::total_nnz(), skepu::SparseMatrix< T >::total_rows(), and skepu::SparseMatrix< T >::updateHost().
T skepu::Reduce< ReduceFuncRowWise, ReduceFuncColWise >::OMP  (  Matrix< T > &  input  ) 
Performs the 2D Reduction (First rowwise then columnwise) on a input Matrix. Returns a scalar result. Using the OpenMP as backend.
input  A matrix on which the 2D reduction will be performed on. 
References skepu::Matrix< T >::total_cols(), skepu::Matrix< T >::total_rows(), and skepu::Matrix< T >::updateHost().
T skepu::Reduce< ReduceFuncRowWise, ReduceFuncColWise >::operator()  (  Matrix< T > &  input  ) 
Performs the 2D Reduction (First rowwise then columnwise) 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.
input  A matrix on which the 2D reduction will be performed on. 
References skepu::Matrix< T >::size(), skepu::Matrix< T >::total_cols(), and skepu::Matrix< T >::total_rows().
T skepu::Reduce< ReduceFuncRowWise, ReduceFuncColWise >::operator()  (  SparseMatrix< T > &  input  ) 
Performs the 2D Reduction (First rowwise then columnwise) 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.
input  A matrix on which the 2D reduction will be performed on. 
References skepu::SparseMatrix< T >::total_cols(), skepu::SparseMatrix< T >::total_nnz(), and skepu::SparseMatrix< T >::total_rows().