27 #ifndef GALOIS_RUNTIME_DIST_STATS_H
28 #define GALOIS_RUNTIME_DIST_STATS_H
31 #ifndef MORE_DIST_STATS
32 #define MORE_DIST_STATS 0
34 #ifndef GALOIS_COMM_STATS
36 #define GALOIS_COMM_STATS 0
38 #ifndef GALOIS_PER_ROUND_STATS
41 #define GALOIS_PER_ROUND_STATS 0
69 static constexpr
const char*
const HSTAT_NAME =
"HostValues";
70 static constexpr
const char*
const HSTAT_ENV_VAR =
"PRINT_PER_HOST_STATS";
72 static bool printingHostVals(
void);
74 template <
typename _UNUSED =
void>
75 struct HostTotalTypesImpl {
81 template <
typename _U>
82 void add(
const _U&)
const {}
87 using TMap = internal::BasicStatMap<DummyStat>;
92 void addToStat(
const Str& region,
const Str& category,
94 perThrdMap.getLocal()->addToStat(region, category, 0, hTotalTy);
101 GALOIS_ASSERT(perThrdMap.getLocal() == perThrdMap.getRemote(0),
102 "Must call from Thread 0");
104 auto* t0Map = perThrdMap.getRemote(0);
106 for (
unsigned t = 1; t < perThrdMap.size(); ++t) {
107 const auto* manager = perThrdMap.getRemote(t);
109 for (
auto i = manager->cbegin(), end_i = manager->cend(); i != end_i;
111 t0Map->addToStat(manager->region(i), manager->category(i), 0,
112 manager->stat(i).totalTy());
119 const TMap& mergedMap(
void)
const {
120 assert(merged &&
"Must merge first");
121 return *perThrdMap.getRemote(0);
125 using HostTotalTypes = HostTotalTypesImpl<>;
127 template <
typename T>
130 template <
typename T>
132 std::tuple<unsigned, T, StatTotal::Type, const ThrdVals<T>&>;
134 template <
typename T>
135 struct HostStat :
public internal::VecStat<T> {
136 using Base = internal::VecStat<T>;
137 using ThrdStats = internal::VecStat<T>;
140 PerHostThrdStats perHostThrdStats;
144 void add(
const HostStatVal<T>& val) {
145 const auto& hostID = std::get<0>(val);
146 const auto& thrdTotal = std::get<1>(val);
147 const auto& thrdTotalTy = std::get<2>(val);
148 const auto& thrdVals = std::get<3>(val);
152 auto p = perHostThrdStats.emplace(hostID, ThrdStats(thrdTotalTy));
153 auto& tstat = p.first->second;
155 for (
const auto& i : thrdVals) {
160 void printHostVals(std::ostream& out,
const Str& region,
161 const Str& category)
const {
164 out << region <<
SEP << category <<
SEP;
165 out << HSTAT_NAME <<
SEP;
167 const char* sep =
"";
169 for (
const auto& v : Base::values()) {
177 void printThreadVals(std::ostream& out,
const Str& region,
178 const Str& category)
const {
179 for (
const auto& p : perHostThrdStats) {
180 out << StatManager::statKind<T>() << SEP << p.first << SEP;
181 out << region << SEP << category << SEP;
182 out <<
StatTotal::str(p.second.totalTy()) << SEP << p.second.total();
185 out << StatManager::statKind<T>() << SEP << p.first << SEP;
186 out << region << SEP << category << SEP;
189 const char* sep =
"";
190 for (
const auto& v : p.second.values()) {
200 template <
typename T>
201 struct DistStatCombiner :
public internal::BasicStatMap<HostStat<T>> {
202 using Base = internal::BasicStatMap<HostStat<T>>;
225 void print(std::ostream& out)
const {
226 for (
auto i = Base::cbegin(), end_i = Base::cend(); i != end_i; ++i) {
229 out << Base::region(i) << SEP << Base::category(i) <<
SEP;
231 const HostStat<T>& hs = Base::stat(i);
233 out << htotalName(hs.totalTy()) << SEP << hs.total();
236 if (DistStatManager::printingHostVals()) {
237 hs.printHostVals(out, Base::region(i), Base::category(i));
241 hs.printThreadVals(out, Base::region(i), Base::category(i));
247 DistStatCombiner<int64_t> intDistStats;
248 DistStatCombiner<double> fpDistStats;
249 DistStatCombiner<Str> strDistStats;
250 HostTotalTypes hostTotalTypes;
288 template <
typename T>
289 void addToStat(
const Str& region,
const Str& category,
const T& val,
293 hostTotalTypes.addToStat(region, category, hTotalTy);
297 void combineAtHost_0_helper(
void);
298 void combineAtHost_0_helper2(
void);
299 void receiveAtHost_0_helper(
void);
300 void receiveAtHost_0_helper2(
void);
301 void combineAtHost_0(
void);
302 StatTotal::Type findHostTotalTy(
const Str& region,
const Str& category,
304 void addRecvdHostTotalTy(
const Str& region,
const Str& category,
306 void addRecvdStat(
unsigned hostID,
const Str& region,
const Str& category,
308 const ThrdVals<int64_t>& thrdVals);
309 void addRecvdStat(
unsigned hostID,
const Str& region,
const Str& category,
311 const ThrdVals<double>& thrdVals);
312 void addRecvdParam(
unsigned hostID,
const Str& region,
const Str& category,
314 const ThrdVals<Str>& thrdVals);
338 template <
typename S1,
typename S2,
typename T>
342 internal::distSysStatManager()->addToStat(
gstl::makeStr(region),
344 thrdTotalTy, hTotalTy);
350 #endif // GALOIS_RUNTIME_DIST_STATS_H
Definition: DistStats.cpp:53
void printHeader(std::ostream &out) const
Print the header of the stats file output.
Definition: DistStats.cpp:376
uint32_t getHostID()
Gets this host's ID.
Definition: Network.cpp:41
DummyStat(StatTotal::Type total)
Definition: DistStats.h:79
static constexpr const char *const TSTAT_NAME
Definition: Statistics.h:342
Definition: Statistics.h:157
Definition: Statistics.h:157
std::map< K, V, C, FixedSizeAlloc< std::pair< const K, V >>> Map
Definition: gstl.h:65
static constexpr const char *const SEP
Definition: Statistics.h:340
Type
Definition: Statistics.h:157
void add(const _U &) const
Definition: DistStats.h:82
Contains the network interface class which is the base class for all network layer implementations...
void addToStat(const Str ®ion, const Str &category, const T &val, const StatTotal::Type &thrdTotalTy, const StatTotal::Type &hTotalTy)
Adds a statistic to the statistics manager.
Definition: DistStats.h:289
#define GALOIS_ASSERT(cond,...)
Like assert but unconditionally executed.
Definition: gIO.h:102
void print(void)
Definition: Statistics.cpp:68
std::vector< T, Pow2Alloc< T >> Vector
[STL vector using Pow_2_VarSizeAlloc]
Definition: gstl.h:52
Definition: Statistics.h:335
static bool printingThreadVals(void)
Definition: Statistics.cpp:64
~DistStatManager()
Definition: DistStats.cpp:49
Str makeStr(const T &x)
Definition: gstl.h:102
DistStatManager(const std::string &outfile="")
Dist stat manager constructor.
Definition: DistStats.cpp:47
virtual void printStats(std::ostream &out)
Merge all stats.
Definition: DistStats.cpp:385
static const char * str(const Type &t)
Definition: Statistics.h:159
void reportDistStat(const S1 ®ion, const S2 &category, const T &value, const StatTotal::Type &thrdTotalTy, const StatTotal::Type &hTotalTy)
Adds a statistic to the statistics manager.
Definition: DistStats.h:339
const Ty add(std::atomic< Ty > &a, const Ty &b)
Definition: AtomicHelpers.h:98
Class responsible for tracking all statistics of a running distributed Galois program and reporting t...
Definition: DistStats.h:61
void addToStat(const S1 ®ion, const S2 &category, const T &val, const StatTotal::Type &type)
Definition: Statistics.h:508
const StatTotal::Type & totalTy(void) const
Definition: DistStats.h:84
Definition: Statistics.h:157
void mergeStats(void)
Merge all stats from each individual thread as well as each individual host as prescribed the the red...
Definition: DistStats.cpp:90
Definition: Statistics.h:157
static constexpr const char *const TSTAT_SEP
Definition: Statistics.h:341
StatTotal::Type m_totalTy
Definition: DistStats.h:77
Definition: Statistics.h:157
Definition: DistStats.h:76
std::basic_string< char, std::char_traits< char >, Pow2Alloc< char >> Str
Definition: gstl.h:75