Skip to content

Commit 2c61fd6

Browse files
committed
Fixed missing headers in Makefile
Added value constructors for Commdata_t, CounterData_t and ExecData_t ADCounter can now be passed CounterData_t instances directly rather than as an Event_t
1 parent 6da4407 commit 2c61fd6

5 files changed

Lines changed: 139 additions & 9 deletions

File tree

include/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nobase_include_HEADERS = chimbuko/chimbuko.hpp chimbuko/ad/ADOutlier.hpp chimbuko/ad/ADNetClient.hpp chimbuko/ad/ADAnomalyProvenance.hpp chimbuko/ad/ADParser.hpp chimbuko/ad/ADProvenanceDBengine.hpp chimbuko/ad/ADNormalEventProvenance.hpp chimbuko/ad/ADLocalFuncStatistics.hpp chimbuko/ad/ADMetadataParser.hpp chimbuko/ad/AnomalyData.hpp chimbuko/ad/ADDefine.hpp chimbuko/ad/ADglobalFunctionIndexMap.hpp chimbuko/ad/ADProvenanceDBclient.hpp chimbuko/ad/ADEvent.hpp chimbuko/ad/ADCounter.hpp chimbuko/ad/ADLocalCounterStatistics.hpp chimbuko/ad/ExecData.hpp chimbuko/ad/utils.hpp chimbuko/ad/ADio.hpp chimbuko/verbose.hpp chimbuko/pserver/PSProvenanceDBclient.hpp chimbuko/pserver/global_anomaly_stats.hpp chimbuko/pserver/PSglobalFunctionIndexMap.hpp chimbuko/pserver/PSstatSender.hpp chimbuko/pserver/AnomalyStat.hpp chimbuko/pserver/global_counter_stats.hpp chimbuko/param/sstd_param.hpp chimbuko/param/hbos_param.hpp chimbuko/AD.hpp chimbuko/message.hpp chimbuko/net.hpp chimbuko/pserver.hpp chimbuko/param.hpp chimbuko/net/zmqme_net.hpp chimbuko/net/mpi_net.hpp chimbuko/net/zmq_net.hpp chimbuko/util/RunStats.hpp chimbuko/util/ADIOS2parseUtils.hpp chimbuko/util/time.hpp chimbuko/util/map.hpp chimbuko/util/error.hpp chimbuko/util/string.hpp chimbuko/util/DispatchQueue.hpp chimbuko/util/PerfStats.hpp chimbuko/util/RunMetric.hpp chimbuko/util/memutils.hpp chimbuko/util/Anomalies.hpp chimbuko/util/barrier.hpp chimbuko/util/threadPool.hpp chimbuko/util/hash.hpp chimbuko/util/mtQueue.hpp chimbuko/util/commandLineParser.hpp
1+
nobase_include_HEADERS = chimbuko/chimbuko.hpp chimbuko/ad/ADOutlier.hpp chimbuko/ad/ADNetClient.hpp chimbuko/ad/ADAnomalyProvenance.hpp chimbuko/ad/ADParser.hpp chimbuko/ad/ADProvenanceDBengine.hpp chimbuko/ad/ADNormalEventProvenance.hpp chimbuko/ad/ADLocalFuncStatistics.hpp chimbuko/ad/ADMetadataParser.hpp chimbuko/ad/AnomalyData.hpp chimbuko/ad/ADDefine.hpp chimbuko/ad/ADglobalFunctionIndexMap.hpp chimbuko/ad/ADProvenanceDBclient.hpp chimbuko/ad/ADEvent.hpp chimbuko/ad/ADCounter.hpp chimbuko/ad/ADLocalCounterStatistics.hpp chimbuko/ad/ExecData.hpp chimbuko/ad/utils.hpp chimbuko/ad/ADio.hpp chimbuko/verbose.hpp chimbuko/pserver/PSProvenanceDBclient.hpp chimbuko/pserver/global_anomaly_stats.hpp chimbuko/pserver/PSglobalFunctionIndexMap.hpp chimbuko/pserver/PSstatSender.hpp chimbuko/pserver/AnomalyStat.hpp chimbuko/pserver/global_counter_stats.hpp chimbuko/param/sstd_param.hpp chimbuko/param/hbos_param.hpp chimbuko/AD.hpp chimbuko/message.hpp chimbuko/net.hpp chimbuko/pserver.hpp chimbuko/param.hpp chimbuko/net/zmqme_net.hpp chimbuko/net/mpi_net.hpp chimbuko/net/zmq_net.hpp chimbuko/net/local_net.hpp chimbuko/util/RunStats.hpp chimbuko/util/ADIOS2parseUtils.hpp chimbuko/util/time.hpp chimbuko/util/map.hpp chimbuko/util/error.hpp chimbuko/util/string.hpp chimbuko/util/DispatchQueue.hpp chimbuko/util/PerfStats.hpp chimbuko/util/RunMetric.hpp chimbuko/util/memutils.hpp chimbuko/util/Anomalies.hpp chimbuko/util/barrier.hpp chimbuko/util/threadPool.hpp chimbuko/util/hash.hpp chimbuko/util/mtQueue.hpp chimbuko/util/serialize.hpp chimbuko/util/commandLineParser.hpp

include/chimbuko/ad/ADCounter.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ namespace chimbuko {
4545
*/
4646
void addCounter(const Event_t& event);
4747

48+
/**
49+
* @brief Insert a new counter in CounterData_t form
50+
* @param cdata CounterData_t instance
51+
*
52+
* This function does not require the counter index->name map to be linked, but if it is a consistency check will be performed
53+
*/
54+
void addCounter(const CounterData_t &cdata);
55+
4856
/**
4957
* @brief Return all counters collected in the timestep
5058
*/

include/chimbuko/ad/ExecData.hpp

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,22 @@ class CommData_t {
174174
* @param commType communication type (e.g. SEND/RECV)
175175
*/
176176
CommData_t(const Event_t& ev, const std::string &commType);
177+
178+
/**
179+
* @brief Construct a new CommData_t object by values
180+
* @param pid Program index
181+
* @param rid Rank index
182+
* @param tid Thread index
183+
* @param partner The other rank involved in the communication
184+
* @param bytes The number of bytes sent/received
185+
* @param tag The tag of the event
186+
* @param timestamp The time of the counter
187+
* @param commType Either "SEND" or "RECV" depending on the comm type
188+
*/
189+
CommData_t(unsigned long pid, unsigned long rid, unsigned long tid,
190+
unsigned long partner, unsigned long bytes, unsigned long tag,
191+
unsigned long timestamp, const std::string &commType);
192+
177193
/**
178194
* @brief Destroy the CommData_t object
179195
*
@@ -264,6 +280,21 @@ class CommData_t {
264280
*/
265281
CounterData_t(const Event_t& ev, const std::string &counter_name);
266282

283+
/**
284+
* @brief Construct a new CounterData_t object by values
285+
* @param pid Program index
286+
* @param rid Rank index
287+
* @param tid Thread index
288+
* @param counter_id Counter index
289+
* @param counter_name The name of the counter (should match the counter_id through the name map)
290+
* @param counter_value The value of the counter
291+
* @param timestamp The time of the counter
292+
*/
293+
CounterData_t(unsigned long pid, unsigned long rid, unsigned long tid,
294+
unsigned long counter_id, const std::string &counter_name,
295+
unsigned long counter_value,
296+
unsigned long timestamp);
297+
267298
/**
268299
* @brief Get the json object of this communication data
269300
*/
@@ -347,6 +378,24 @@ class ExecData_t {
347378
* @param ev constant reference to a Event_t object
348379
*/
349380
ExecData_t(const Event_t& ev);
381+
382+
383+
/**
384+
* @brief Construct a new ExecData_t object by values
385+
* @param id The id associated with the instance
386+
* @param pid Program index
387+
* @param rid Rank index
388+
* @param tid Thread index
389+
* @param fid Function index
390+
* @param func_name The name of the function (should match the function index through the name map)
391+
* @param entry Timestamp of function start (entry)
392+
* @param exit Timestamp of function exit. A value of -1 (default) indicates that the exit is not yet known. It should be set later using update_exit
393+
*/
394+
ExecData_t(const eventID &id,
395+
unsigned long pid, unsigned long rid, unsigned long tid,
396+
unsigned long fid, const std::string &func_name,
397+
long entry, long exit = -1);
398+
350399
/**
351400
* @brief Destroy the ExecData_t object
352401
*
@@ -467,7 +516,7 @@ class ExecData_t {
467516
*
468517
* @param funcname function name
469518
*/
470-
void set_funcname(std::string funcname) { m_funcname = funcname; }
519+
void set_funcname(const std::string &funcname) { m_funcname = funcname; }
471520

472521
/**
473522
* @brief update exit event of this execution
@@ -477,6 +526,15 @@ class ExecData_t {
477526
* @return false incorrect exit event
478527
*/
479528
bool update_exit(const Event_t& ev);
529+
530+
/**
531+
* @brief update exit event of this execution
532+
*
533+
* @param exit timestamp
534+
*/
535+
void update_exit(unsigned long exit);
536+
537+
480538
/**
481539
* @brief update exclusive running time
482540
*

src/ad/ADCounter.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,25 @@ void ADCounter::addCounter(const Event_t& event){
2222
m_countersByIdx[event.counter_id()].push_back(cit);
2323
}
2424

25+
void ADCounter::addCounter(const CounterData_t &cdata){
26+
//If the counter name map is linked, check the name matches
27+
if(m_counterMap){
28+
auto it = m_counterMap->find(cdata.get_counterid());
29+
if(it == m_counterMap->end()) fatal_error("Counter index " + std::to_string(cdata.get_counterid()) + " could not be found in map");
30+
if(it->second != cdata.get_countername()) fatal_error("Counter name " + cdata.get_countername() + " does not match the name in the index map, " + it->second);
31+
}
32+
33+
//If this is the first counter after a flush, we recreate the list
34+
if(!m_counters) m_counters = new CounterDataListMap_p_t;
35+
36+
auto &count_list_prt = (*m_counters)[cdata.get_pid()][cdata.get_rid()][cdata.get_tid()];
37+
CounterDataListIterator_t cit = count_list_prt.insert(count_list_prt.end(), cdata);
38+
m_timestampCounterMap[cdata.get_pid()][cdata.get_rid()][cdata.get_tid()][cdata.get_ts()].push_back(cit);
39+
m_countersByIdx[cdata.get_counterid()].push_back(cit);
40+
}
41+
42+
43+
2544
CounterDataListMap_p_t* ADCounter::flushCounters(){
2645
CounterDataListMap_p_t* ret = m_counters;
2746
m_counters = nullptr;

src/ad/ExecData.cpp

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "chimbuko/ad/ExecData.hpp"
2+
#include "chimbuko/util/error.hpp"
23

34
using namespace chimbuko;
45

@@ -22,18 +23,34 @@ ExecData_t::ExecData_t(const Event_t& ev) : ExecData_t()
2223
m_parent = eventID::root();
2324
}
2425

25-
ExecData_t::~ExecData_t() {
26+
ExecData_t::ExecData_t(const eventID &id, unsigned long pid, unsigned long rid, unsigned long tid, unsigned long fid,
27+
const std::string &func_name, long entry, long exit) : ExecData_t()
28+
{
29+
m_id = id;
30+
m_pid = pid;
31+
m_rid = rid;
32+
m_tid = tid;
33+
m_fid = fid;
34+
m_entry = entry;
35+
m_parent = eventID::root();
36+
m_funcname = func_name;
37+
if(exit != -1) update_exit(exit);
38+
}
39+
40+
ExecData_t::~ExecData_t() {}
2641

42+
void ExecData_t::update_exit(unsigned long exit){
43+
m_exit = exit;
44+
m_runtime = m_exit - m_entry;
45+
m_exclusive += m_runtime;
2746
}
2847

2948
bool ExecData_t::update_exit(const Event_t& ev)
3049
{
31-
if (m_fid != ev.fid() || m_entry > (long)ev.ts())
32-
return false;
33-
m_exit = ev.ts();
34-
m_runtime = m_exit - m_entry;
35-
m_exclusive += m_runtime;
36-
return true;
50+
if (m_fid != ev.fid() || m_entry > (long)ev.ts())
51+
return false;
52+
update_exit(ev.ts());
53+
return true;
3754
}
3855

3956
bool ExecData_t::add_message(const CommData_t& comm, ListEnd end) {
@@ -285,6 +302,19 @@ CommData_t::CommData_t(const Event_t& ev, const std::string &commType)
285302
m_ts = ev.ts();
286303
}
287304

305+
CommData_t::CommData_t(unsigned long pid, unsigned long rid, unsigned long tid,
306+
unsigned long partner, unsigned long bytes, unsigned long tag,
307+
unsigned long timestamp, const std::string &commType)
308+
: m_commType(commType), m_pid(pid), m_rid(rid), m_tid(tid), m_bytes(bytes), m_tag(tag), m_ts(timestamp){
309+
if (m_commType.compare("SEND") == 0) {
310+
m_src = m_rid;
311+
m_tar = partner;
312+
} else if (m_commType.compare("RECV") == 0){
313+
m_src = partner;
314+
m_tar = m_rid;
315+
}
316+
}
317+
288318
bool CommData_t::is_same(const CommData_t& other) const
289319
{
290320
if (!(m_commType == other.m_commType)) return false;
@@ -343,6 +373,21 @@ CounterData_t::CounterData_t(const Event_t& ev, const std::string &counter_name)
343373
m_value(ev.counter_value()),
344374
m_ts(ev.ts()){}
345375

376+
377+
CounterData_t::CounterData_t(unsigned long pid, unsigned long rid, unsigned long tid,
378+
unsigned long counter_id, const std::string &counter_name,
379+
unsigned long counter_value,
380+
unsigned long timestamp):
381+
m_countername(counter_name),
382+
m_pid(pid),
383+
m_rid(rid),
384+
m_tid(tid),
385+
m_cid(counter_id),
386+
m_value(counter_value),
387+
m_ts(timestamp){}
388+
389+
390+
346391
nlohmann::json CounterData_t::get_json() const{
347392
return {
348393
{"pid",m_pid},

0 commit comments

Comments
 (0)