Public Member Functions

skepu::Scan< ScanFunc > Class Template Reference
[Skeletons]

A class representing the Scan skeleton. More...

#include <scan.h>

Collaboration diagram for skepu::Scan< ScanFunc >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Scan (ScanFunc *scanFunc)
 ~Scan ()
template<typename T >
void operator() (Vector< T > &input, ScanType type, T init=T())
template<typename InputIterator >
void operator() (InputIterator inputBegin, InputIterator inputEnd, ScanType type, typename InputIterator::value_type init=typename InputIterator::value_type())
template<typename T >
void operator() (Vector< T > &input, Vector< T > &output, ScanType type, T init=T())
template<typename InputIterator , typename OutputIterator >
void operator() (InputIterator inputBegin, InputIterator inputEnd, OutputIterator outputBegin, ScanType type, typename InputIterator::value_type init=typename InputIterator::value_type())
template<typename T >
void CPU (Vector< T > &input, ScanType type=INCLUSIVE, T init=T())
template<typename InputIterator >
void CPU (InputIterator inputBegin, InputIterator inputEnd, ScanType type=INCLUSIVE, typename InputIterator::value_type init=typename InputIterator::value_type())
template<typename T >
void CPU (Vector< T > &input, Vector< T > &output, ScanType type=INCLUSIVE, T init=T())
template<typename InputIterator , typename OutputIterator >
void CPU (InputIterator inputBegin, InputIterator inputEnd, OutputIterator outputBegin, ScanType type=INCLUSIVE, typename InputIterator::value_type init=typename InputIterator::value_type())
template<typename T >
void OMP (Vector< T > &input, ScanType type=INCLUSIVE, T init=T())
template<typename InputIterator >
void OMP (InputIterator inputBegin, InputIterator inputEnd, ScanType type=INCLUSIVE, typename InputIterator::value_type init=typename InputIterator::value_type())
template<typename T >
void OMP (Vector< T > &input, Vector< T > &output, ScanType type=INCLUSIVE, T init=T())
template<typename InputIterator , typename OutputIterator >
void OMP (InputIterator inputBegin, InputIterator inputEnd, OutputIterator outputBegin, ScanType type=INCLUSIVE, typename InputIterator::value_type init=typename InputIterator::value_type())
template<typename T >
void CU (Vector< T > &input, ScanType type=INCLUSIVE, T init=T(), int useNumGPU=1)
template<typename InputIterator >
void CU (InputIterator inputBegin, InputIterator inputEnd, ScanType type=INCLUSIVE, typename InputIterator::value_type init=typename InputIterator::value_type(), int useNumGPU=1)
template<typename T >
void CU (Vector< T > &input, Vector< T > &output, ScanType type=INCLUSIVE, T init=T(), int useNumGPU=1)
template<typename InputIterator , typename OutputIterator >
void CU (InputIterator inputBegin, InputIterator inputEnd, OutputIterator outputBegin, ScanType type=INCLUSIVE, typename InputIterator::value_type init=typename InputIterator::value_type(), int useNumGPU=1)
template<typename T >
void CL (Vector< T > &input, ScanType type=INCLUSIVE, T init=T(), int useNumGPU=1)
template<typename InputIterator >
void CL (InputIterator inputBegin, InputIterator inputEnd, ScanType type=INCLUSIVE, typename InputIterator::value_type init=typename InputIterator::value_type(), int useNumGPU=1)
template<typename T >
void CL (Vector< T > &input, Vector< T > &output, ScanType type=INCLUSIVE, T init=T(), int useNumGPU=1)
template<typename InputIterator , typename OutputIterator >
void CL (InputIterator inputBegin, InputIterator inputEnd, OutputIterator outputBegin, ScanType type=INCLUSIVE, typename InputIterator::value_type init=typename InputIterator::value_type(), int useNumGPU=1)

Detailed Description

template<typename ScanFunc>
class skepu::Scan< ScanFunc >

A class representing the Scan skeleton.

Author:
Johan Enmyren
Version:
0.6

This class defines the Scan skeleton, also known as prefix sum. It is related to the Reduce operation but instead of producing a single scalar result it produces an output vector of the same length as the input with its elements being the reduction of itself all elements preceding it in the input. For example the input vector [4 3 7 6 9] would produce the result vector [4 7 14 20 29]. The Scan operation can either include or exclude the current element. It can be either inclusive or exclusive. In the previous example a inclusive scan was performed, the exclusive result would be [0 4 7 14 20]. Exclusive scan is sometimes called prescan. This Scan skeleton supports both variants by adding a parameter to the function calls, default is inclusive.

Once instantiated, it is meant to be used as a function and therefore overloading operator(). There are a few overloaded variants of this operator depending on if a seperate output vector is provided or if vectors or iterators are used as parameters.

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 Scan skeleton also includes a pointer to an Environment which, in turn, includes the devices available to execute on.


Constructor & Destructor Documentation

template<typename ScanFunc >
skepu::Scan< ScanFunc >::Scan ( ScanFunc *  scanFunc  ) 

When creating an instance of the Scan 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:
scanFunc A pointer to a valid binary user function. Will be deleted in the destructor.
template<typename ScanFunc >
skepu::Scan< ScanFunc >::~Scan (  ) 

When the Scan skeleton is destroyed, it deletes the user function it was created with.


Member Function Documentation

template<typename ScanFunc >
template<typename T >
void skepu::Scan< ScanFunc >::CL ( Vector< T > &  input,
ScanType  type = INCLUSIVE,
init = T(),
int  useNumGPU = 1 
)

Performs the Scan on a whole Vector using OpenCL with the input as output. A wrapper for CL(InputIterator inputBegin, InputIterator inputEnd, OutputIterator outputBegin, ScanType type, typename InputIterator::value_type init, int useNumGPU).

Parameters:
input A vector which will be scanned. It will be overwritten with the result.
type The scan type, either INCLUSIVE or EXCLUSIVE.
init The initialization value for exclusive scans.
useNumGPU Integer specifying how many devices to use. 0 = Implementation decides.

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

Here is the call graph for this function:

template<typename ScanFunc >
template<typename InputIterator >
void skepu::Scan< ScanFunc >::CL ( InputIterator  inputBegin,
InputIterator  inputEnd,
ScanType  type = INCLUSIVE,
typename InputIterator::value_type  init = typename InputIterator::value_type(),
int  useNumGPU = 1 
)

Performs the Scan on an input range using OpenCL with the input range also used as an output. A wrapper for CL(InputIterator inputBegin, InputIterator inputEnd, OutputIterator outputBegin, ScanType type, typename InputIterator::value_type init, int useNumGPU).

Parameters:
inputBegin A Vector::iterator to the first element in the range.
inputEnd A Vector::iterator to the last element of the range.
type The scan type, either INCLUSIVE or EXCLUSIVE.
init The initialization value for exclusive scans.
useNumGPU Integer specifying how many devices to use. 0 = Implementation decides.

References skepu::Scan< ScanFunc >::CL().

Here is the call graph for this function:

template<typename ScanFunc >
template<typename T >
void skepu::Scan< ScanFunc >::CL ( Vector< T > &  input,
Vector< T > &  output,
ScanType  type = INCLUSIVE,
init = T(),
int  useNumGPU = 1 
)

Performs the Scan on a whole Vector using OpenCL with a separate Vector as output. The output Vector will be resized an overwritten. A wrapper for CL(InputIterator inputBegin, InputIterator inputEnd, OutputIterator outputBegin, ScanType type, typename InputIterator::value_type init, int useNumGPU).

Parameters:
input A vector which will be scanned.
output The result vector, will be overwritten with the result and resized if needed.
type The scan type, either INCLUSIVE or EXCLUSIVE.
init The initialization value for exclusive scans.
useNumGPU Integer specifying how many devices to use. 0 = Implementation decides.

References skepu::Vector< T >::begin(), skepu::Scan< ScanFunc >::CL(), skepu::Vector< T >::clear(), skepu::Vector< T >::end(), skepu::Vector< T >::resize(), and skepu::Vector< T >::size().

Here is the call graph for this function:

template<typename ScanFunc >
template<typename InputIterator , typename OutputIterator >
void skepu::Scan< ScanFunc >::CL ( InputIterator  inputBegin,
InputIterator  inputEnd,
OutputIterator  outputBegin,
ScanType  type = INCLUSIVE,
typename InputIterator::value_type  init = typename InputIterator::value_type(),
int  useNumGPU = 1 
)

Performs the Scan on a range of elements. Returns a scalar result. The function decides whether to perform the reduction on one device, calling scanSingle_CL or on multiple devices, calling scanNumDevices_CL. Using OpenCL as backend.

Parameters:
inputBegin A Vector::iterator to the first element in the range.
inputEnd A Vector::iterator to the last element of the range.
outputBegin A Vector::iterator to the first element of the output range.
type The scan type, either INCLUSIVE or EXCLUSIVE.
init The initialization value for exclusive scans.
useNumGPU Integer specifying how many devices to use. 0 = Implementation decides.
template<typename ScanFunc >
template<typename InputIterator >
void skepu::Scan< ScanFunc >::CPU ( InputIterator  inputBegin,
InputIterator  inputEnd,
ScanType  type = INCLUSIVE,
typename InputIterator::value_type  init = typename InputIterator::value_type() 
)

Performs the Scan on a range of elements on the CPU with the same range as output.

Parameters:
inputBegin A Vector::iterator to the first element in the range.
inputEnd A Vector::iterator to the last element of the range.
type The scan type, either INCLUSIVE or EXCLUSIVE.
init The initialization value for exclusive scans.
template<typename ScanFunc >
template<typename T >
void skepu::Scan< ScanFunc >::CPU ( Vector< T > &  input,
Vector< T > &  output,
ScanType  type = INCLUSIVE,
init = T() 
)

Performs the Scan on a whole Vector on the CPU with a seperate output vector. Wrapper for CPU(InputIterator inputBegin, InputIterator inputEnd, OutputIterator outputBegin, ScanType type, typename InputIterator::value_type init).

Parameters:
input A vector which will be scanned.
output The result vector, will be overwritten with the result and resized if needed.
type The scan type, either INCLUSIVE or EXCLUSIVE.
init The initialization value for exclusive scans.

References skepu::Vector< T >::begin(), skepu::Vector< T >::clear(), skepu::Scan< ScanFunc >::CPU(), skepu::Vector< T >::end(), skepu::Vector< T >::resize(), and skepu::Vector< T >::size().

Here is the call graph for this function:

template<typename ScanFunc >
template<typename InputIterator , typename OutputIterator >
void skepu::Scan< ScanFunc >::CPU ( InputIterator  inputBegin,
InputIterator  inputEnd,
OutputIterator  outputBegin,
ScanType  type = INCLUSIVE,
typename InputIterator::value_type  init = typename InputIterator::value_type() 
)

Performs the Scan on a range of elements on the CPU with a seperate output range.

Parameters:
inputBegin A Vector::iterator to the first element in the range.
inputEnd A Vector::iterator to the last element of the range.
outputBegin A Vector::iterator to the first element of the output range.
type The scan type, either INCLUSIVE or EXCLUSIVE.
init The initialization value for exclusive scans.
template<typename ScanFunc >
template<typename T >
void skepu::Scan< ScanFunc >::CPU ( Vector< T > &  input,
ScanType  type = INCLUSIVE,
init = T() 
)

Performs the Scan on a whole Vector on the CPU with itself as output. A wrapper for CPU(InputIterator inputBegin, InputIterator inputEnd, ScanType type, typename InputIterator::value_type init).

Parameters:
input A vector which will be scanned. It will be overwritten with the result.
type The scan type, either INCLUSIVE or EXCLUSIVE.
init The initialization value for exclusive scans.

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

Here is the call graph for this function:

template<typename ScanFunc >
template<typename InputIterator >
void skepu::Scan< ScanFunc >::CU ( InputIterator  inputBegin,
InputIterator  inputEnd,
ScanType  type = INCLUSIVE,
typename InputIterator::value_type  init = typename InputIterator::value_type(),
int  useNumGPU = 1 
)

Performs the Scan on an input range using CUDA with the input range also used as an output. A wrapper for CU(InputIterator inputBegin, InputIterator inputEnd, OutputIterator outputBegin, ScanType type, typename InputIterator::value_type init, int useNumGPU).

Parameters:
inputBegin A Vector::iterator to the first element in the range.
inputEnd A Vector::iterator to the last element of the range.
type The scan type, either INCLUSIVE or EXCLUSIVE.
init The initialization value for exclusive scans.
useNumGPU Integer specifying how many devices to use. 0 = Implementation decides.

References skepu::Scan< ScanFunc >::CU().

Here is the call graph for this function:

template<typename ScanFunc >
template<typename T >
void skepu::Scan< ScanFunc >::CU ( Vector< T > &  input,
Vector< T > &  output,
ScanType  type = INCLUSIVE,
init = T(),
int  useNumGPU = 1 
)

Performs the Scan on a whole Vector using CUDA with a separate Vector as output. The output Vector will be resized an overwritten. A wrapper for CU(InputIterator inputBegin, InputIterator inputEnd, OutputIterator outputBegin, ScanType type, typename InputIterator::value_type init, int useNumGPU).

Parameters:
input A vector which will be scanned.
output The result vector, will be overwritten with the result and resized if needed.
type The scan type, either INCLUSIVE or EXCLUSIVE.
init The initialization value for exclusive scans.
useNumGPU Integer specifying how many devices to use. 0 = Implementation decides.

References skepu::Vector< T >::begin(), skepu::Vector< T >::clear(), skepu::Scan< ScanFunc >::CU(), skepu::Vector< T >::end(), skepu::Vector< T >::resize(), and skepu::Vector< T >::size().

Here is the call graph for this function:

template<typename ScanFunc >
template<typename InputIterator , typename OutputIterator >
void skepu::Scan< ScanFunc >::CU ( InputIterator  inputBegin,
InputIterator  inputEnd,
OutputIterator  outputBegin,
ScanType  type = INCLUSIVE,
typename InputIterator::value_type  init = typename InputIterator::value_type(),
int  useNumGPU = 1 
)

Performs the Scan on an input range using CUDA with a separate output range. The function decides whether to perform the scan on one device, calling scanSingleThread_CU or on multiple devices, starting one new host thread per device calling scanThreadFunc_CU for each thread.

Parameters:
inputBegin A Vector::iterator to the first element in the range.
inputEnd A Vector::iterator to the last element of the range.
outputBegin A Vector::iterator to the first element of the output range.
type The scan type, either INCLUSIVE or EXCLUSIVE.
init The initialization value for exclusive scans.
useNumGPU Integer specifying how many devices to use. 0 = Implementation decides.

References skepu::Scan< ScanFunc >::CPU(), skepu::Threads::fork(), skepu::Threads::join(), and skepu::Vector< T >::push_back().

Here is the call graph for this function:

template<typename ScanFunc >
template<typename T >
void skepu::Scan< ScanFunc >::CU ( Vector< T > &  input,
ScanType  type = INCLUSIVE,
init = T(),
int  useNumGPU = 1 
)

Performs the Scan on a whole Vector using CUDA with the input as output. A wrapper for CU(InputIterator inputBegin, InputIterator inputEnd, OutputIterator outputBegin, ScanType type, typename InputIterator::value_type init, int useNumGPU).

Parameters:
input A vector which will be scanned. It will be overwritten with the result.
type The scan type, either INCLUSIVE or EXCLUSIVE.
init The initialization value for exclusive scans.
useNumGPU Integer specifying how many devices to use. 0 = Implementation decides.

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

Here is the call graph for this function:

template<typename ScanFunc >
template<typename T >
void skepu::Scan< ScanFunc >::OMP ( Vector< T > &  input,
Vector< T > &  output,
ScanType  type = INCLUSIVE,
init = T() 
)

Performs the Scan on a whole Vector with a seperate output vector using OpenMP as backend. Wrapper for OMP(InputIterator inputBegin, InputIterator inputEnd, OutputIterator outputBegin, ScanType type, typename InputIterator::value_type init).

Parameters:
input A vector which will be scanned.
output The result vector, will be overwritten with the result and resized if needed.
type The scan type, either INCLUSIVE or EXCLUSIVE.
init The initialization value for exclusive scans.

References skepu::Vector< T >::begin(), skepu::Vector< T >::clear(), skepu::Vector< T >::end(), skepu::Scan< ScanFunc >::OMP(), skepu::Vector< T >::resize(), and skepu::Vector< T >::size().

Here is the call graph for this function:

template<typename ScanFunc >
template<typename InputIterator , typename OutputIterator >
void skepu::Scan< ScanFunc >::OMP ( InputIterator  inputBegin,
InputIterator  inputEnd,
OutputIterator  outputBegin,
ScanType  type = INCLUSIVE,
typename InputIterator::value_type  init = typename InputIterator::value_type() 
)

Performs the Scan on a range of elements with a seperate output range using OpenMP as backend.

Parameters:
inputBegin A Vector::iterator to the first element in the range.
inputEnd A Vector::iterator to the last element of the range.
outputBegin A Vector::iterator to the first element of the output range.
type The scan type, either INCLUSIVE or EXCLUSIVE.
init The initialization value for exclusive scans.
template<typename ScanFunc >
template<typename T >
void skepu::Scan< ScanFunc >::OMP ( Vector< T > &  input,
ScanType  type = INCLUSIVE,
init = T() 
)

Performs the Scan on a whole Vector with itself as output using OpenMP as backend. A wrapper for OMP(InputIterator inputBegin, InputIterator inputEnd, ScanType type, typename InputIterator::value_type init).

Parameters:
input A vector which will be scanned. It will be overwritten with the result.
type The scan type, either INCLUSIVE or EXCLUSIVE.
init The initialization value for exclusive scans.

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

Here is the call graph for this function:

template<typename ScanFunc >
template<typename InputIterator >
void skepu::Scan< ScanFunc >::OMP ( InputIterator  inputBegin,
InputIterator  inputEnd,
ScanType  type = INCLUSIVE,
typename InputIterator::value_type  init = typename InputIterator::value_type() 
)

Performs the Scan on a range of elements with the same range as output using OpenMP as backend.

Parameters:
inputBegin A Vector::iterator to the first element in the range.
inputEnd A Vector::iterator to the last element of the range.
type The scan type, either INCLUSIVE or EXCLUSIVE.
init The initialization value for exclusive scans.
template<typename ScanFunc >
template<typename T >
void skepu::Scan< ScanFunc >::operator() ( Vector< T > &  input,
Vector< T > &  output,
ScanType  type,
init = T() 
)

Performs the Scan on a whole Vector. With a seperate Vector as output.

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:
input A vector which will be scanned.
output The result vector, will be overwritten with the result and resized if needed.
type The scan type, either INCLUSIVE or EXCLUSIVE.
init The initialization value for exclusive scans.

References skepu::Scan< ScanFunc >::CL(), skepu::Scan< ScanFunc >::CPU(), skepu::Scan< ScanFunc >::CU(), skepu::Scan< ScanFunc >::OMP(), and skepu::Vector< T >::size().

Here is the call graph for this function:

template<typename ScanFunc >
template<typename T >
void skepu::Scan< ScanFunc >::operator() ( Vector< T > &  input,
ScanType  type,
init = T() 
)

Performs the Scan on a whole Vector. With itself as output.

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:
input A vector which will be scanned. It will be overwritten with the result.
type The scan type, either INCLUSIVE or EXCLUSIVE.
init The initialization value for exclusive scans.

References skepu::Scan< ScanFunc >::CL(), skepu::Scan< ScanFunc >::CPU(), skepu::Scan< ScanFunc >::CU(), skepu::Scan< ScanFunc >::OMP(), and skepu::Vector< T >::size().

Here is the call graph for this function:

template<typename ScanFunc >
template<typename InputIterator >
void skepu::Scan< ScanFunc >::operator() ( InputIterator  inputBegin,
InputIterator  inputEnd,
ScanType  type,
typename InputIterator::value_type  init = typename InputIterator::value_type() 
)

Performs the Scan on a range of elements. With the same range as output.

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:
inputBegin A Vector::iterator to the first element in the range.
inputEnd A Vector::iterator to the last element of the range.
type The scan type, either INCLUSIVE or EXCLUSIVE.
init The initialization value for exclusive scans.

References skepu::Scan< ScanFunc >::CL(), skepu::Scan< ScanFunc >::CPU(), skepu::Scan< ScanFunc >::CU(), and skepu::Scan< ScanFunc >::OMP().

Here is the call graph for this function:

template<typename ScanFunc >
template<typename InputIterator , typename OutputIterator >
void skepu::Scan< ScanFunc >::operator() ( InputIterator  inputBegin,
InputIterator  inputEnd,
OutputIterator  outputBegin,
ScanType  type,
typename InputIterator::value_type  init = typename InputIterator::value_type() 
)

Performs the Scan on a range of elements. With a seperate output range.

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:
inputBegin A Vector::iterator to the first element in the range.
inputEnd A Vector::iterator to the last element of the range.
outputBegin A Vector::iterator to the first element of the output range.
type The scan type, either INCLUSIVE or EXCLUSIVE.
init The initialization value for exclusive scans.

References skepu::Scan< ScanFunc >::CL(), skepu::Scan< ScanFunc >::CPU(), skepu::Scan< ScanFunc >::CU(), and skepu::Scan< ScanFunc >::OMP().

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