SkelCL
SkelCL is a high level multi GPU skeleton library developed at the university of M√ľnster, Germany.
 All Classes Namespaces Files Functions Variables Typedefs Groups
Public Member Functions | List of all members
skelcl::AllPairs< Tout(Tleft, Tright)> Class Template Reference

An instance of the AllPairs class describes a calculation of pairs of row vectors and column vectors with a user defined function which can be performed on a device. More...

#include <AllPairs.h>

Inheritance diagram for skelcl::AllPairs< Tout(Tleft, Tright)>:

Public Member Functions

 AllPairs (const Reduce< Tout(Tout)> &reduce, const Zip< Tout(Tleft, Tright)> &zip)
 Constructor taking a Reduce and a Zip skeleton used to customize the AllPairs skeleton. More...
 
 AllPairs (const std::string &source, const std::string &func=std::string("func"))
 Constructor taking the source code used to customize the AllPairs skeleton. More...
 
template<typename... Args>
Matrix< Tout > operator() (const Matrix< Tleft > &left, const Matrix< Tright > &right, Args &&...args)
 Executes the skeleton on the data provided as arguments left, right and args. The resulting data is stored in a newly created output matrix. More...
 
template<typename... Args>
Matrix< Tout > & operator() (Out< Matrix< Tout > > output, const Matrix< Tleft > &left, const Matrix< Tright > &right, Args &&...args)
 Executes the skeleton on the provided containers. The resulting data is stored in the provided output container and a reference to this container is returned. More...
 

Detailed Description

template<typename Tleft, typename Tright, typename Tout>
class skelcl::AllPairs< Tout(Tleft, Tright)>

An instance of the AllPairs class describes a calculation of pairs of row vectors and column vectors with a user defined function which can be performed on a device.

On creation the AllPairs skeleton is customized with either a given Reduce<T(T)> and Zip<Tout(Tleft, Tright)> skeleton or with source code defining a function. The source code function header receives two vectors of the same length and the length as an integer as follows:

Tout func(lmatrix_t* row, rmatrix_t* col, const unsigned int dim).

The i-th element of the row-vector row of type lmatrix_t can be accessed via the API-Function getElementFromRow(row, i) and the i-th element of the column-vector col of type rmatrix_t can be accessed via the API-function getElementFromColumn(col, i).

The AllPairs skeleton can be executed by passing two matrix containers. The AllPairs skeleton will compute the results of all pairs of row-vectors from the left matrix and column-vectors from the right matrix and store them in a result matrix. More formally: M is a matrix of size heigt x dim and N is a matrix of size dim x width and F is the customized function that receives a row-vector from M, a column-vector from N and calculates a scalar value. Then P is the result matrix of size height x width. Every P[i,j] is the scalar result from F(M_i, N_j), where M_i is the ith row vector in M for i in [0,..,height-1] and N_j is the jth column vector in N for j in [0,...,width-1]. When a Zip<Tout(Tleft, Tright)> and a Reduce<T(T)> skeleton is used to customize the allpairs skeleton, then function F is Reduce(Zip(M_i,N_j)). Passing a Zip<Tout(Tleft, Tright)> and Reduce<T(T)> skeleton yields a better runtime than defining a function as source code, as local memory is used automatically.

Template Parameters
TleftType of the left input data of the skeleton.
TrightType of the right input data of the skeleton.
ToutType of the output data of the skeleton.

Definition at line 118 of file AllPairs.h.

Constructor & Destructor Documentation

template<typename Tleft , typename Tright , typename Tout >
skelcl::AllPairs< Tout(Tleft, Tright)>::AllPairs ( const Reduce< Tout(Tout)> &  reduce,
const Zip< Tout(Tleft, Tright)> &  zip 
)

Constructor taking a Reduce and a Zip skeleton used to customize the AllPairs skeleton.

Parameters
reduceReduce skeleton
zipZip skeleton
template<typename Tleft , typename Tright , typename Tout >
skelcl::AllPairs< Tout(Tleft, Tright)>::AllPairs ( const std::string &  source,
const std::string &  func = std::string("func") 
)

Constructor taking the source code used to customize the AllPairs skeleton.

Parameters
sourceSource code used to customize the skeleton
funcName of the 'main' function (the starting point) of the given source code

Member Function Documentation

template<typename Tleft , typename Tright , typename Tout >
template<typename... Args>
Matrix<Tout> skelcl::AllPairs< Tout(Tleft, Tright)>::operator() ( const Matrix< Tleft > &  left,
const Matrix< Tright > &  right,
Args &&...  args 
)

Executes the skeleton on the data provided as arguments left, right and args. The resulting data is stored in a newly created output matrix.

Template Parameters
ArgsThe types of the arguments which are passed to the user-defined function in addition to the input container.
Parameters
leftThe first (left) input data for the skeleton managed inside a matrix. If no distribution is set for this container as well as for the right container as default the Block distribution is selected. If no distribution is set for this container and a distribution is set for the right container the implementation will try to select a suitable distribution for allpairs computations.
rightThe second (right) input data for the skeleton managed inside a matrix. If no distribution is set for this matrix as well as for the left matrix as default the Copy distribution is selected. If no distribution is set for this matrix and a distribution is set for the left matrix the implementation will try to select a suitable distribution for allpairs computations
argsThe values of the arguments which are passed to the user-defined function in addition to the input container.
Returns
A newly created Matrix storing the elements which get computed by performing the allpairs computation.
template<typename Tleft , typename Tright , typename Tout >
template<typename... Args>
Matrix<Tout>& skelcl::AllPairs< Tout(Tleft, Tright)>::operator() ( Out< Matrix< Tout > >  output,
const Matrix< Tleft > &  left,
const Matrix< Tright > &  right,
Args &&...  args 
)

Executes the skeleton on the provided containers. The resulting data is stored in the provided output container and a reference to this container is returned.

Template Parameters
ArgsThe types of the arguments which are passed to the user-defined function in addition to the input container.
Parameters
outputThe output matrix in which the resulting data is stored. The type of this argument is not the type of the matrix itself, but instead a wrapping class tagging that this container is written into. The utility function skelcl::out can be used to create this wrapper for an arbitrary container.
leftThe first (left) input data for the skeleton managed inside a matrix. If no distribution is set for this matrix as well as for the right matrix as default the Block distribution is selected. If no distribution is set for this matrix and a distribution is set for the right matrix the implementation will try to select a suitable distribution for allpairs computations
rightThe second (right) input data for the skeleton managed inside a matrix. If no distribution is set for this matrix as well as for the left matrix as default the Copy distribution is selected. If no distribution is set for this matrix and a distribution is set for the left matrix the implementation will try to select a suitable distribution for allpairs computations
argsThe values of the arguments which are passed to the user-defined function in addition to the input container.
Returns
A reference to the provided output Matrix. This Matrix contains the elements which gets computed by performing the allpairs computation.

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