26 #ifndef GALOIS_DISTTERMINATOR_H
27 #define GALOIS_DISTTERMINATOR_H
44 template <
typename Ty>
50 Ty local_mdata, global_mdata;
52 uint64_t prev_snapshot;
54 uint64_t global_snapshot;
56 #ifndef GALOIS_USE_LCI
57 MPI_Request snapshot_request;
59 lc_colreq snapshot_request;
114 if (local_mdata == 0)
115 local_mdata = mdata.
reduce();
126 Ty
read() {
return global_mdata; }
134 Ty retval = global_mdata;
136 local_mdata = global_mdata = 0;
141 #ifdef GALOIS_USE_LCI
142 lc_ialreduce(&snapshot, &global_snapshot,
sizeof(Ty),
143 &galois::runtime::internal::ompi_op_max<Ty>, lc_col_ep,
146 MPI_Iallreduce(&snapshot, &global_snapshot, 1, MPI_UNSIGNED_LONG, MPI_MAX,
147 MPI_COMM_WORLD, &snapshot_request);
152 bool active = (local_mdata != 0);
158 int snapshot_ended = 0;
160 #ifndef GALOIS_USE_LCI
161 MPI_Test(&snapshot_request, &snapshot_ended, MPI_STATUS_IGNORE);
163 lc_col_progress(&snapshot_request);
164 snapshot_ended = snapshot_request.flag;
175 if (snapshot_ended != 0) {
176 snapshot = global_snapshot;
179 prev_snapshot = snapshot;
184 }
else if (prev_snapshot != snapshot) {
185 prev_snapshot = snapshot;
213 Ty
reduce(std::string runID = std::string()) {
214 std::string timer_str(
"ReduceDGAccum_" + runID);
220 if (local_mdata == 0)
221 local_mdata = mdata.
reduce();
224 global_mdata = !halt;
228 static_cast<uint32_t>(
void reinitialize()
Definition: DTerminationDetector.h:70
void reset()
Definition: Reduction.h:113
Ty reset()
Reset the entire accumulator.
Definition: DTerminationDetector.h:133
DGTerminator & operator+=(const Ty &rhs)
Adds to accumulated value.
Definition: DTerminationDetector.h:83
void gDebug(Args &&...GALOIS_USED_ONLY_IN_DEBUG(args))
Prints a debug string from a sequence of things; prints nothing if NDEBUG is defined.
Definition: gIO.h:72
void operator=(const Ty rhs)
Sets current value stored in accumulator.
Definition: DTerminationDetector.h:93
virtual bool anyPendingSends()=0
static uint32_t ID
This machine's host ID.
Definition: Network.h:81
Distributed sum-reducer for getting the sum of some value across multiple hosts.
Definition: DTerminationDetector.h:45
LWCI header that includes lc.h (LCI library) and internal helper functions on arrays.
void set(const Ty rhs)
Sets current value stored in accumulator.
Definition: DTerminationDetector.h:103
Ty read_local()
Read local accumulated value.
Definition: DTerminationDetector.h:113
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...
NetworkInterface & getSystemNetworkInterface()
Get the network interface.
Definition: Network.cpp:131
virtual bool anyPendingReceives()=0
Ty reduce(std::string runID=std::string())
Reduce data across all hosts, saves the value, and returns the reduced value.
Definition: DTerminationDetector.h:213
void start()
Definition: Timer.cpp:82
void initiate_snapshot()
Definition: DTerminationDetector.h:140
T & reduce()
Returns the final reduction value.
Definition: Reduction.h:102
bool terminate()
Definition: DTerminationDetector.h:151
uint32_t evilPhase
Variable that keeps track of which network send/recv phase a program is currently on...
Definition: Network.cpp:36
A class that defines functions that a network interface in Galois should have.
Definition: Network.h:52
DGTerminator()
Default constructor.
Definition: DTerminationDetector.h:64
Ty read()
Read the value returned by the last reduce call.
Definition: DTerminationDetector.h:126