26 #ifndef GALOIS_DISTACCUMULATOR_H
27 #define GALOIS_DISTACCUMULATOR_H
44 template <
typename Ty>
50 Ty local_mdata, global_mdata;
56 inline void reduce_lwci() {
57 lc_alreduce(&local_mdata, &global_mdata,
sizeof(Ty),
58 &galois::runtime::internal::ompi_op_sum<Ty>, lc_col_ep);
64 inline void reduce_mpi() {
65 if (
typeid(Ty) ==
typeid(int32_t)) {
66 MPI_Allreduce(&local_mdata, &global_mdata, 1, MPI_INT, MPI_SUM,
68 }
else if (
typeid(Ty) ==
typeid(int64_t)) {
69 MPI_Allreduce(&local_mdata, &global_mdata, 1, MPI_LONG, MPI_SUM,
71 }
else if (
typeid(Ty) ==
typeid(uint32_t)) {
72 MPI_Allreduce(&local_mdata, &global_mdata, 1, MPI_UNSIGNED, MPI_SUM,
74 }
else if (
typeid(Ty) ==
typeid(uint64_t)) {
75 MPI_Allreduce(&local_mdata, &global_mdata, 1, MPI_UNSIGNED_LONG, MPI_SUM,
77 }
else if (
typeid(Ty) ==
typeid(
float)) {
78 MPI_Allreduce(&local_mdata, &global_mdata, 1, MPI_FLOAT, MPI_SUM,
80 }
else if (
typeid(Ty) ==
typeid(
double)) {
81 MPI_Allreduce(&local_mdata, &global_mdata, 1, MPI_DOUBLE, MPI_SUM,
83 }
else if (
typeid(Ty) ==
typeid(
long double)) {
84 MPI_Allreduce(&local_mdata, &global_mdata, 1, MPI_LONG_DOUBLE, MPI_SUM,
88 "Type of DGAccumulator not supported for MPI reduction");
134 if (local_mdata == 0)
135 local_mdata = mdata.
reduce();
146 Ty
read() {
return global_mdata; }
154 Ty retval = global_mdata;
156 local_mdata = global_mdata = 0;
169 Ty
reduce(std::string runID = std::string()) {
170 std::string timer_str(
"ReduceDGAccum_" + runID);
176 if (local_mdata == 0)
177 local_mdata = mdata.
reduce();
179 #ifdef GALOIS_USE_LCI
199 template <
typename Ty>
205 Ty local_mdata, global_mdata;
207 #ifdef GALOIS_USE_LCI
211 inline void reduce_lwci() {
212 lc_alreduce(&local_mdata, &global_mdata,
sizeof(Ty),
213 &galois::runtime::internal::ompi_op_max<Ty>, lc_col_ep);
219 inline void reduce_mpi() {
220 if (
typeid(Ty) ==
typeid(int32_t)) {
221 MPI_Allreduce(&local_mdata, &global_mdata, 1, MPI_INT, MPI_MAX,
223 }
else if (
typeid(Ty) ==
typeid(int64_t)) {
224 MPI_Allreduce(&local_mdata, &global_mdata, 1, MPI_LONG, MPI_MAX,
226 }
else if (
typeid(Ty) ==
typeid(uint32_t)) {
227 MPI_Allreduce(&local_mdata, &global_mdata, 1, MPI_UNSIGNED, MPI_MAX,
229 }
else if (
typeid(Ty) ==
typeid(uint64_t)) {
230 MPI_Allreduce(&local_mdata, &global_mdata, 1, MPI_UNSIGNED_LONG, MPI_MAX,
232 }
else if (
typeid(Ty) ==
typeid(
float)) {
233 MPI_Allreduce(&local_mdata, &global_mdata, 1, MPI_FLOAT, MPI_MAX,
235 }
else if (
typeid(Ty) ==
typeid(
double)) {
236 MPI_Allreduce(&local_mdata, &global_mdata, 1, MPI_DOUBLE, MPI_MAX,
238 }
else if (
typeid(Ty) ==
typeid(
long double)) {
239 MPI_Allreduce(&local_mdata, &global_mdata, 1, MPI_LONG_DOUBLE, MPI_MAX,
242 static_assert(
true,
"Type of DGReduceMax not supported for MPI "
273 if (local_mdata == 0)
274 local_mdata = mdata.
reduce();
284 Ty
read() {
return global_mdata; }
293 Ty retval = global_mdata;
295 local_mdata = global_mdata = 0;
305 Ty
reduce(std::string runID = std::string()) {
306 std::string timer_str(
"ReduceDGReduceMax_" + runID);
312 if (local_mdata == 0)
313 local_mdata = mdata.
reduce();
315 #ifdef GALOIS_USE_LCI
334 template <
typename Ty>
340 Ty local_mdata, global_mdata;
342 #ifdef GALOIS_USE_LCI
346 inline void reduce_lwci() {
347 lc_alreduce(&local_mdata, &global_mdata,
sizeof(Ty),
348 &galois::runtime::internal::ompi_op_min<Ty>, lc_col_ep);
354 inline void reduce_mpi() {
355 if (
typeid(Ty) ==
typeid(int32_t)) {
356 MPI_Allreduce(&local_mdata, &global_mdata, 1, MPI_INT, MPI_MIN,
358 }
else if (
typeid(Ty) ==
typeid(int64_t)) {
359 MPI_Allreduce(&local_mdata, &global_mdata, 1, MPI_LONG, MPI_MIN,
361 }
else if (
typeid(Ty) ==
typeid(uint32_t)) {
362 MPI_Allreduce(&local_mdata, &global_mdata, 1, MPI_UNSIGNED, MPI_MIN,
364 }
else if (
typeid(Ty) ==
typeid(uint64_t)) {
365 MPI_Allreduce(&local_mdata, &global_mdata, 1, MPI_UNSIGNED_LONG, MPI_MIN,
367 }
else if (
typeid(Ty) ==
typeid(
float)) {
368 MPI_Allreduce(&local_mdata, &global_mdata, 1, MPI_FLOAT, MPI_MIN,
370 }
else if (
typeid(Ty) ==
typeid(
double)) {
371 MPI_Allreduce(&local_mdata, &global_mdata, 1, MPI_DOUBLE, MPI_MIN,
373 }
else if (
typeid(Ty) ==
typeid(
long double)) {
374 MPI_Allreduce(&local_mdata, &global_mdata, 1, MPI_LONG_DOUBLE, MPI_MIN,
377 static_assert(
true,
"Type of DGReduceMin not supported for MPI "
410 local_mdata = mdata.
reduce();
420 Ty
read() {
return global_mdata; }
429 Ty retval = global_mdata;
441 Ty
reduce(std::string runID = std::string()) {
442 std::string timer_str(
"ReduceDGReduceMin_" + runID);
449 local_mdata = mdata.
reduce();
451 #ifdef GALOIS_USE_LCI
Ty read_local()
Read the local reduced max value; if it has never been reduced, it will attempt get the global value ...
Definition: DReducible.h:272
Distributed sum-reducer for getting the sum of some value across multiple hosts.
Definition: DReducible.h:45
Ty reset()
Reset this accumulator.
Definition: DReducible.h:292
void update(const Ty rhs)
Update the local min-reduced value.
Definition: DReducible.h:398
DGAccumulator & operator+=(const Ty &rhs)
Adds to accumulated value.
Definition: DReducible.h:103
void set(const Ty rhs)
Sets current value stored in accumulator.
Definition: DReducible.h:123
void reset()
Definition: Reduction.h:113
DGReduceMax()
Default constructor; initializes everything to 0.
Definition: DReducible.h:252
DGReduceMin()
Default constructor; initializes everything to the max value of the type.
Definition: DReducible.h:387
Ty reduce(std::string runID=std::string())
Do a min reduction across all hosts by sending data to all other hosts and reducing received data...
Definition: DReducible.h:441
Ty reset()
Reset this accumulator.
Definition: DReducible.h:428
Ty reset()
Reset the entire accumulator.
Definition: DReducible.h:153
Ty read_local()
Read the local reduced min value; if it has never been reduced, it will attempt get the global value ...
Definition: DReducible.h:408
Ty read()
Read the global reduced min value.
Definition: DReducible.h:420
LWCI header that includes lc.h (LCI library) and internal helper functions on arrays.
const Ty max(std::atomic< Ty > &a, const Ty &b)
Definition: AtomicHelpers.h:40
Contains declaration of DistStatManager, which reports runtime statistics of a distributed applicatio...
Distributed min-reducer for getting the min of some value across multiple hosts.
Definition: DReducible.h:335
NetworkInterface & getSystemNetworkInterface()
Get the network interface.
Definition: Network.cpp:131
void update(const Ty rhs)
Update the local max-reduced value.
Definition: DReducible.h:262
Distributed max-reducer for getting the max of some value across multiple hosts.
Definition: DReducible.h:200
void operator=(const Ty rhs)
Sets current value stored in accumulator.
Definition: DReducible.h:113
void start()
Definition: Timer.cpp:82
Ty read_local()
Read local accumulated value.
Definition: DReducible.h:133
T & reduce()
Returns the final reduction value.
Definition: Reduction.h:102
DGAccumulator()
Default constructor.
Definition: DReducible.h:95
Ty read()
Read the global reduced max value.
Definition: DReducible.h:284
Ty reduce(std::string runID=std::string())
Reduce data across all hosts, saves the value, and returns the reduced value.
Definition: DReducible.h:169
void update(T &&rhs)
Updates the thread local value by applying the reduction operator to current and newly provided value...
Definition: Reduction.h:90
A class that defines functions that a network interface in Galois should have.
Definition: Network.h:52
Ty reduce(std::string runID=std::string())
Do a max reduction across all hosts by sending data to all other hosts and reducing received data...
Definition: DReducible.h:305
Ty read()
Read the value returned by the last reduce call.
Definition: DReducible.h:146