25 #include "galois/config.h"
29 template <
typename Ty>
30 const Ty
atomicMax(std::atomic<Ty>& a,
const Ty b) {
34 !a.compare_exchange_weak(old_a, b, std::memory_order_relaxed))
39 template <
typename Ty>
40 const Ty
max(std::atomic<Ty>& a,
const Ty& b) {
49 template <
typename Ty>
50 const Ty
max(Ty& a,
const Ty& b) {
60 template <
typename Ty>
61 const Ty
atomicMin(std::atomic<Ty>& a,
const Ty b) {
64 !a.compare_exchange_weak(old_a, b, std::memory_order_relaxed))
69 template <
typename Ty>
70 const Ty
min(std::atomic<Ty>& a,
const Ty& b) {
78 template <
typename Ty>
79 const Ty
min(Ty& a,
const Ty& b) {
88 template <
typename Ty>
89 const Ty
atomicAdd(std::atomic<Ty>& val, Ty delta) {
91 while (!val.compare_exchange_weak(old_val, old_val + delta,
92 std::memory_order_relaxed))
97 template <
typename Ty>
98 const Ty
add(std::atomic<Ty>& a,
const Ty& b) {
104 template <
typename Ty>
105 const Ty
add(Ty& a, std::atomic<Ty>& b) {
111 template <
typename Ty>
112 const Ty
add(Ty& a,
const Ty& b) {
122 template <
typename Ty>
125 while (!val.compare_exchange_weak(old_val, old_val - delta,
126 std::memory_order_relaxed))
131 template <
typename Ty>
132 const Ty
set(Ty& a,
const Ty& b) {
137 template <
typename Ty>
138 const Ty
set(std::atomic<Ty>& a,
const Ty& b) {
144 template <
typename Ty>
146 return (a + b) / 2.0;
149 template <
typename Ty>
151 for (
unsigned i = 0; i < a_vec.size(); ++i) {
152 a_vec[i] = (a_vec[i] + b_vec[i]) / 2.0;
156 template <
typename Ty>
159 std::fill(a_arr.begin(), a_arr.end(), 0);
162 template <
typename Ty>
164 for (
unsigned i = 0; i < a_arr.size(); ++i) {
165 a_arr[i] = (a_arr[i] + b_arr[i]) / 2.0;
169 template <
typename Ty>
171 for (
unsigned i = 0; i < a_arr.size(); ++i) {
172 a_arr[i] = (a_arr[i] + b_arr[i]);
176 template <
typename Ty>
178 std::for_each(a_vec.begin(), a_vec.end(), [](Ty& ele) { ele = 0; });
182 template <
typename ItrTy,
typename Ty>
183 Ty
innerProduct(ItrTy a_begin, ItrTy a_end, ItrTy b_begin, Ty init_value) {
185 for (
auto ii = a_begin; ii != a_end; ++ii, ++jj) {
186 init_value += (*ii) * (*jj);
192 template <
typename ItrTy,
typename Ty>
194 auto jj = b_arr.begin();
195 for (
auto ii = a_arr.begin(); ii != a_arr.end(); ++ii, ++jj) {
196 init_value += (*ii) * (*jj);
201 template <
typename Ty>
206 template <
typename Ty>
207 void reset(std::atomic<Ty>& var, Ty val) {
const Ty atomicAdd(std::atomic< Ty > &val, Ty delta)
galois::atomicAdd
Definition: AtomicHelpers.h:89
const Ty atomicMin(std::atomic< Ty > &a, const Ty b)
galois::atomicMin
Definition: AtomicHelpers.h:61
const Ty pairWiseAvg(Ty a, Ty b)
Pair Wise Average function.
Definition: AtomicHelpers.h:145
const Ty max(std::atomic< Ty > &a, const Ty &b)
Definition: AtomicHelpers.h:40
Ty innerProduct(ItrTy a_begin, ItrTy a_end, ItrTy b_begin, Ty init_value)
Definition: AtomicHelpers.h:183
void reset(Ty &var, Ty val)
Definition: AtomicHelpers.h:202
const Ty min(std::atomic< Ty > &a, const Ty &b)
Definition: AtomicHelpers.h:70
const Ty set(Ty &a, const Ty &b)
Definition: AtomicHelpers.h:132
const Ty add(std::atomic< Ty > &a, const Ty &b)
Definition: AtomicHelpers.h:98
const Ty atomicSubtract(std::atomic< Ty > &val, Ty delta)
atomic subtraction of delta (because atomicAdd with negative numbers implies a signed integer cast) ...
Definition: AtomicHelpers.h:123
void resetVec(Ty &a_arr)
Definition: AtomicHelpers.h:157
void for_each(const RangeFunc &rangeMaker, FunctionTy &&fn, const Args &...args)
Galois unordered set iterator.
Definition: Loops.h:52
const Ty atomicMax(std::atomic< Ty > &a, const Ty b)
galois::atomicMax + non-atomic max calls
Definition: AtomicHelpers.h:30
void pairWiseAvg_vec(std::vector< Ty > &a_vec, std::vector< Ty > &b_vec)
Definition: AtomicHelpers.h:150
void addArray(Ty &a_arr, Ty &b_arr)
Definition: AtomicHelpers.h:170