20 #ifndef GALOIS_REDUCTION_H
21 #define GALOIS_REDUCTION_H
26 #include "galois/config.h"
64 template <
typename T,
typename MergeFunc,
typename IdFunc>
69 void merge(T& lhs, T&& rhs) {
70 T v{std::move(MergeFunc::operator()(lhs, std::move(rhs)))};
80 : MergeFunc(merge_func), IdFunc(id_func) {
81 for (
unsigned i = 0; i < data_.size(); ++i) {
82 *(data_.getRemote(i)) = IdFunc::operator()();
90 void update(T&& rhs) { merge(*data_.getLocal(), std::move(rhs)); }
92 void update(
const T& rhs) { merge(*data_.getLocal(), rhs); }
103 T& lhs = *data_.getLocal();
104 for (
unsigned int i = 1; i < data_.size(); ++i) {
105 T& rhs = *data_.getRemote(i);
106 merge(lhs, std::move(rhs));
114 for (
unsigned int i = 0; i < data_.size(); ++i) {
124 template <
typename MergeFn,
typename IdFn>
130 template <
typename T>
133 return std::max<T>(lhs, rhs);
138 template <
typename T>
141 return std::min<T>(lhs, rhs);
145 template <
typename T, T value>
153 template <
typename T>
158 template <
typename T>
163 template <
typename T>
169 template <
typename T>
188 template <
typename T>
197 template <
typename T>
207 identity_value<bool, true>> {
218 identity_value<bool, false>> {
228 #endif // GALOIS_REDUCTION_H
constexpr T operator()() const
Definition: Reduction.h:155
GAccumulator & operator+=(const T &rhs)
Definition: Reduction.h:176
void reset()
Definition: Reduction.h:113
constexpr T operator()(const T &lhs, const T &rhs) const
Definition: Reduction.h:132
constexpr T operator()() const
Definition: Reduction.h:147
constexpr T operator()() const
Definition: Reduction.h:160
GReduceLogicalAnd()
Definition: Reduction.h:212
Definition: Reduction.h:159
Accumulator for T where accumulation is plus.
Definition: Reduction.h:170
GReduceMin()
Definition: Reduction.h:202
A Reducible stores per-thread values of a variable of type T and merges multiple values into one...
Definition: Reduction.h:65
Accumulator for T where accumulation is max.
Definition: Reduction.h:189
T & getLocal()
Returns a reference to the local value of T.
Definition: Reduction.h:97
const Ty max(std::atomic< Ty > &a, const Ty &b)
Definition: AtomicHelpers.h:40
Definition: PerThreadStorage.h:88
void update(const T &rhs)
Definition: Reduction.h:92
gmax is the functional form of std::max
Definition: Reduction.h:139
GReduceMax()
Definition: Reduction.h:193
Accumulator for T where accumulation is min.
Definition: Reduction.h:198
auto make_reducible(const MergeFn &mergeFn, const IdFn &idFn)
make_reducible creates a Reducible from a merge function and identity function.
Definition: Reduction.h:125
GReduceLogicalOr()
Definition: Reduction.h:223
GAccumulator()
Definition: Reduction.h:174
void operator()(void)
Definition: Executor_ParaMeter.h:417
Definition: Reduction.h:164
gmax is the functional form of std::max
Definition: Reduction.h:131
const Ty min(std::atomic< Ty > &a, const Ty &b)
Definition: AtomicHelpers.h:70
Definition: Reduction.h:146
Definition: Reduction.h:154
T & reduce()
Returns the final reduction value.
Definition: Reduction.h:102
constexpr T operator()(const T &lhs, const T &rhs) const
Definition: Reduction.h:140
logical OR reduction
Definition: Reduction.h:217
void update(T &&rhs)
Updates the thread local value by applying the reduction operator to current and newly provided value...
Definition: Reduction.h:90
T value_type
Definition: Reduction.h:77
constexpr T operator()() const
Definition: Reduction.h:165
GAccumulator & operator-=(const T &rhs)
Definition: Reduction.h:181
Reducible(MergeFunc merge_func, IdFunc id_func)
Definition: Reduction.h:79
logical AND reduction
Definition: Reduction.h:206