Galois
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
galois::Reducible< T, MergeFunc, IdFunc > Class Template Reference

A Reducible stores per-thread values of a variable of type T and merges multiple values into one. More...

#include <Reduction.h>

Inheritance diagram for galois::Reducible< T, MergeFunc, IdFunc >:

Public Types

using value_type = T
 

Public Member Functions

 Reducible (MergeFunc merge_func, IdFunc id_func)
 
void update (T &&rhs)
 Updates the thread local value by applying the reduction operator to current and newly provided value. More...
 
void update (const T &rhs)
 
T & getLocal ()
 Returns a reference to the local value of T. More...
 
T & reduce ()
 Returns the final reduction value. More...
 
void reset ()
 

Detailed Description

template<typename T, typename MergeFunc, typename IdFunc>
class galois::Reducible< T, MergeFunc, IdFunc >

A Reducible stores per-thread values of a variable of type T and merges multiple values into one.

The reduced value is obtained by merging per thread values using the binary functor MergeFunc. MergeFunc takes two values of type T and produces the resulting merged value:

T operator()(T lhs, T rhs)

If T is expensive to copy, a moving merge function is more appropriate:

T& operator()(T& lhs, T&& rhs)

IdFunc returns the identity element, which is used to initialize and reset the per thread values.

Both MergeFunc and IdFunc should be copy constructable.

The MergeFunc and IdFunc should be related as follows:

MergeFunc(x, IdFunc()) == x for all x in X

An example of using a move merge function:

auto merge_func = [](T& lhs, T&& rhs) -> T& { ... } auto identity_func = []() -> T { ... }

auto r = make_reducible(merge_func, identity_func); T u = ... r.update(std::move(u)); T& result = r.reduce();

Member Typedef Documentation

template<typename T, typename MergeFunc, typename IdFunc>
using galois::Reducible< T, MergeFunc, IdFunc >::value_type = T

Constructor & Destructor Documentation

template<typename T, typename MergeFunc, typename IdFunc>
galois::Reducible< T, MergeFunc, IdFunc >::Reducible ( MergeFunc  merge_func,
IdFunc  id_func 
)
inline

Member Function Documentation

template<typename T, typename MergeFunc, typename IdFunc>
T& galois::Reducible< T, MergeFunc, IdFunc >::getLocal ( )
inline

Returns a reference to the local value of T.

template<typename T, typename MergeFunc, typename IdFunc>
T& galois::Reducible< T, MergeFunc, IdFunc >::reduce ( )
inline

Returns the final reduction value.

Only valid outside the parallel region.

template<typename T, typename MergeFunc, typename IdFunc>
void galois::Reducible< T, MergeFunc, IdFunc >::reset ( )
inline
template<typename T, typename MergeFunc, typename IdFunc>
void galois::Reducible< T, MergeFunc, IdFunc >::update ( T &&  rhs)
inline

Updates the thread local value by applying the reduction operator to current and newly provided value.

template<typename T, typename MergeFunc, typename IdFunc>
void galois::Reducible< T, MergeFunc, IdFunc >::update ( const T &  rhs)
inline

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