GrPPI  1.0
Generic and Reusable Parallel Pattern Interface
Public Member Functions | List of all members
grppi::reduce_t< Combiner, Identity > Class Template Reference

Representation of reduce pattern. Represents a reduction that can be used as a stage on a pipeline. More...

#include <reduce_pattern.h>

Public Member Functions

 reduce_t (int wsize, int offset, Identity id, Combiner &&combine_op)
 Construct a reduction pattern object. More...
 
void add_item (Identity &&item)
 Add an item to the reduction buffer. If there are remaining items before reaching the next window start the item is discarded. More...
 
bool reduction_needed () const
 Check if a reduction can be performed. More...
 
Combiner combiner () const
 Get the combiner. More...
 
int window_size () const
 Get the window size. More...
 
int offset () const
 Get the offset. More...
 
template<typename E >
auto reduce_window (const E &e)
 Reduce values from a window. More...
 
template<typename T >
auto operator() (T &&)
 

Detailed Description

template<typename Combiner, typename Identity>
class grppi::reduce_t< Combiner, Identity >

Representation of reduce pattern. Represents a reduction that can be used as a stage on a pipeline.

Template Parameters
CombinerCallable type for the combine operation used in the reduction.
IdentityIdentity value for the combiner.

Constructor & Destructor Documentation

◆ reduce_t()

template<typename Combiner , typename Identity >
grppi::reduce_t< Combiner, Identity >::reduce_t ( int  wsize,
int  offset,
Identity  id,
Combiner &&  combine_op 
)
inline

Construct a reduction pattern object.

Parameters
wsizeWindow size.
offsetOffset between window starts.
IdIdentity value.
combine_opCombiner used for the reduction.

Member Function Documentation

◆ add_item()

template<typename Combiner , typename Identity >
void grppi::reduce_t< Combiner, Identity >::add_item ( Identity &&  item)
inline

Add an item to the reduction buffer. If there are remaining items before reaching the next window start the item is discarded.

Parameters
itemto be added.

◆ combiner()

template<typename Combiner , typename Identity >
Combiner grppi::reduce_t< Combiner, Identity >::combiner ( ) const
inline

Get the combiner.

Returns
The combiner held by the reduction object.

◆ offset()

template<typename Combiner , typename Identity >
int grppi::reduce_t< Combiner, Identity >::offset ( ) const
inline

Get the offset.

Returns
The offset the reduction object.

◆ operator()()

template<typename Combiner , typename Identity >
template<typename T >
auto grppi::reduce_t< Combiner, Identity >::operator() ( T &&  )
inline

◆ reduce_window()

template<typename Combiner , typename Identity >
template<typename E >
auto grppi::reduce_t< Combiner, Identity >::reduce_window ( const E &  e)
inline

Reduce values from a window.

Returns
The result of the reduction.

◆ reduction_needed()

template<typename Combiner , typename Identity >
bool grppi::reduce_t< Combiner, Identity >::reduction_needed ( ) const
inline

Check if a reduction can be performed.

Precondition
items.size() < static_cast<int>(std::numeric_limits<int>::max())

◆ window_size()

template<typename Combiner , typename Identity >
int grppi::reduce_t< Combiner, Identity >::window_size ( ) const
inline

Get the window size.

Returns
The window size of the reduction object.

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