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::Reduce< T(T)> Class Template Reference

An instance of the Reduce class describes a reduction calculation (a.k.a. accumulate) customized by a given binary user-defined function. More...

#include <Reduce.h>

Inheritance diagram for skelcl::Reduce< T(T)>:

Public Member Functions

 Reduce (const Source &source, const std::string &id="0", const std::string &funcName="func")
 Constructor taking the source code to customize the Reduce skeleton. More...
 
template<typename... Args>
Vector< T > operator() (const Vector< T > &input, Args &&...args)
 Function call operator. Executes the skeleton on the data provided as argument input and args. The resulting data is returned as a moved copy. More...
 
template<typename... Args>
Vector< T > & operator() (Out< Vector< T >> output, const Vector< T > &input, Args &&...args)
 Function call operator. Executes the skeleton on the data provided as argument input and args. The resulting data is stored in the provided Vector output. A reference to the output Vector is returned to allow for chaining skeleton calls. More...
 
std::string source () const
 Return the source code of the user defined function. More...
 
std::string func () const
 Return the name of the user defined function. More...
 
std::string id () const
 Return the identity for the user defined function. More...
 

Detailed Description

template<typename T>
class skelcl::Reduce< T(T)>

An instance of the Reduce class describes a reduction calculation (a.k.a. accumulate) customized by a given binary user-defined function.

On creation the Reduce skeleton is customized with source code defining a binary function. The binary function has to be associative and commutative. The Reduce skeleton can be executed by passing an input Vector. The given function is applied repetitively to calculate a single scalar value from all items of the input container.

More formally: When v is a Vector of length n with items v[0] .. v[n-1], f is the provided function, the Reduce skeleton calculates the output value y as follows: y = f(..f(f(v[0], v[1]), v[2]),.. v[n-1]) or written more easily using + as a symbol for the given function and using infix notation: y = v[0] + v[1] + v[2] ... + v[n-1].

Template Parameters
TType of the input and output data of the skeleton.

Definition at line 96 of file Reduce.h.

Constructor & Destructor Documentation

template<typename T >
skelcl::Reduce< T(T)>::Reduce ( const Source source,
const std::string &  id = "0",
const std::string &  funcName = "func" 
)

Constructor taking the source code to customize the Reduce skeleton.

Parameters
sourceSource code used to customize the skeleton.
idIdentity for he function named by funcName and defined in source. Meaning: if func is the name of the function defined in source, func(x, id) = x and func(id, x) = x for every possible value of x
funcNameName of the 'main' function (the starting point) of the given source code

Member Function Documentation

template<typename T >
std::string skelcl::Reduce< T(T)>::func ( ) const

Return the name of the user defined function.

Returns
The name of the user defined function.
template<typename T >
std::string skelcl::Reduce< T(T)>::id ( ) const

Return the identity for the user defined function.

Returns
The identity for the user defined function.
template<typename T >
template<typename... Args>
Vector<T> skelcl::Reduce< T(T)>::operator() ( const Vector< T > &  input,
Args &&...  args 
)

Function call operator. Executes the skeleton on the data provided as argument input and args. The resulting data is returned as a moved copy.

Parameters
inputThe input data for the skeleton managed inside a Vector. If no distribution is set the Single distribution using the device with id 0 is used. Currently only the Single distribution is supported for the input Vector! This will certainly be advanced in a future version.
argsAdditional arguments which are passed to the function named by funcName and defined in the source code at created. The individual arguments must be passed in the same order here as they where defined in the funcName function declaration.
template<typename T >
template<typename... Args>
Vector<T>& skelcl::Reduce< T(T)>::operator() ( Out< Vector< T >>  output,
const Vector< T > &  input,
Args &&...  args 
)

Function call operator. Executes the skeleton on the data provided as argument input and args. The resulting data is stored in the provided Vector output. A reference to the output Vector is returned to allow for chaining skeleton calls.

Parameters
outputThe Vector storing the result of the execution of the skeleton. A reference to this container is also returned. The Vector might be resized to fit the result. The distribution of the container might change.
inputThe input data for the skeleton managed inside a Vector. If no distribution is set the Single distribution using the device with id 0 is used. Currently only the Single distribution is supported for the input vector! This will certainly be advanced in a future version.
argsAdditional arguments which are passed to the function named by funcName and defined in the source code at created. The individual arguments must be passed in the same order here as they where defined in the funcName function declaration.
template<typename T >
std::string skelcl::Reduce< T(T)>::source ( ) const

Return the source code of the user defined function.

Returns
The source code of the user defined function.

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