Galois
|
A Reducible stores per-thread values of a variable of type T and merges multiple values into one. More...
#include <Reduction.h>
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 () |
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();
using galois::Reducible< T, MergeFunc, IdFunc >::value_type = T |
|
inline |
|
inline |
Returns a reference to the local value of T.
|
inline |
Returns the final reduction value.
Only valid outside the parallel region.
|
inline |
|
inline |
Updates the thread local value by applying the reduction operator to current and newly provided value.
|
inline |