Skip to content

Commit dc8cacb

Browse files
committed
In ADParser::getEvents, used fact that all data must have same pid, rid to replace multi-dim map with array in timestamp order check
1 parent 3675393 commit dc8cacb

1 file changed

Lines changed: 28 additions & 18 deletions

File tree

src/ad/ADParser.cpp

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,8 @@ std::vector<Event_t> ADParser::getEvents() const{
568568
out.reserve( getNumFuncData() + getNumCommData() + getNumCounterData() );
569569

570570
//Maintain latest timestamps to check ordering is correct
571-
typedef std::unordered_map<unsigned long, std::unordered_map< unsigned long, std::unordered_map< unsigned long, unsigned long> > > TSmap;
572-
TSmap latest_func_ts, latest_comm_ts, latest_count_ts, latest_ts;
571+
//Validation ensures all entries have the same pid and rid as those of this AD process
572+
std::vector<long> latest_func_ts, latest_comm_ts, latest_count_ts, latest_ts; //vector over threads
573573
other_timer.pause();
574574

575575

@@ -610,12 +610,16 @@ std::vector<Event_t> ADParser::getEvents() const{
610610
std::pair<Event_t,bool> evp = createAndValidateEvent(data, EventDataType::FUNC, idx_funcData,
611611
generate_event_id(m_rank, step, idx_funcData));
612612
if(evp.second){
613-
unsigned long* latest_func_ts_val = getElemPRT(evp.first.pid(), evp.first.rid(), evp.first.tid(), latest_func_ts);
614-
if(latest_func_ts_val != nullptr && evp.first.ts() < *latest_func_ts_val){
613+
unsigned long rid = evp.first.rid();
614+
unsigned long ts = evp.first.ts();
615+
if(latest_func_ts.size() < rid+1) latest_func_ts.resize(rid+1, -1);
616+
if(latest_ts.size() < rid+1) latest_ts.resize(rid+1, -1);
617+
618+
if(latest_func_ts[rid] != -1 && ts < latest_func_ts[rid]){
615619
std::stringstream ss;
616620
ss << "ADParser::getEvents parsed function data is not in time order: Event " << evp.first.get_json().dump()
617621
<< " for function \"" << m_funcMap.find(evp.first.fid())->second
618-
<< "\" has timestamp " << evp.first.ts() << " < " << *latest_func_ts_val << " of previous func insertion\n";
622+
<< "\" has timestamp " << evp.first.ts() << " < " << latest_func_ts[rid] << " of previous func insertion\n";
619623

620624
auto rit = out.rbegin();
621625
while(rit != out.rend()){
@@ -626,35 +630,41 @@ std::vector<Event_t> ADParser::getEvents() const{
626630
}
627631
fatal_error(ss.str());
628632
}
629-
unsigned long* latest_ts_val = getElemPRT(evp.first.pid(), evp.first.rid(), evp.first.tid(), latest_ts);
630-
if(latest_ts_val != nullptr && evp.first.ts() < *latest_ts_val) fatal_error("event ordering error! [func]");
633+
if(latest_ts[rid] != -1 && ts < latest_ts[rid]) fatal_error("event ordering error! [func]");
634+
631635
out.push_back(evp.first);
632-
latest_ts[evp.first.pid()][evp.first.rid()][evp.first.tid()] = latest_func_ts[evp.first.pid()][evp.first.rid()][evp.first.tid()] = evp.first.ts();
636+
latest_ts[rid] = latest_func_ts[rid] = ts;
633637
}
634638
funcData = this->getFuncData(++idx_funcData);
635639
}else if(data == commData){
636640
std::pair<Event_t,bool> evp = createAndValidateEvent(data, EventDataType::COMM, idx_commData,
637641
generate_event_id(m_rank, step, idx_commData));
638642

639643
if(evp.second){
640-
unsigned long* latest_comm_ts_val = getElemPRT(evp.first.pid(), evp.first.rid(), evp.first.tid(), latest_comm_ts);
641-
if(latest_comm_ts_val != nullptr && evp.first.ts() < *latest_comm_ts_val) fatal_error("parsed comm data is not in time order");
642-
unsigned long* latest_ts_val = getElemPRT(evp.first.pid(), evp.first.rid(), evp.first.tid(), latest_ts);
643-
if(latest_ts_val != nullptr && evp.first.ts() < *latest_ts_val) fatal_error("event ordering error! [comm]");
644+
unsigned long rid = evp.first.rid();
645+
unsigned long ts = evp.first.ts();
646+
if(latest_comm_ts.size() < rid+1) latest_comm_ts.resize(rid+1, -1);
647+
if(latest_ts.size() < rid+1) latest_ts.resize(rid+1, -1);
648+
649+
if(latest_comm_ts[rid] != -1 && ts < latest_comm_ts[rid]) fatal_error("parsed comm data is not in time order");
650+
if(latest_ts[rid] != -1 && ts < latest_ts[rid]) fatal_error("event ordering error! [comm]");
644651
out.push_back(evp.first);
645-
latest_ts[evp.first.pid()][evp.first.rid()][evp.first.tid()] = latest_comm_ts[evp.first.pid()][evp.first.rid()][evp.first.tid()] = evp.first.ts();
652+
latest_ts[rid] = latest_comm_ts[rid] = ts;
646653
}
647654
commData = this->getCommData(++idx_commData);
648655
}else if(data == counterData){
649656
std::pair<Event_t,bool> evp = createAndValidateEvent(data, EventDataType::COUNT, idx_counterData,
650657
generate_event_id(m_rank, step, idx_counterData));
651658
if(evp.second){
652-
unsigned long* latest_count_ts_val = getElemPRT(evp.first.pid(), evp.first.rid(), evp.first.tid(), latest_count_ts);
653-
if(latest_count_ts_val != nullptr && evp.first.ts() < *latest_count_ts_val) fatal_error("parsed counter data is not in time order");
654-
unsigned long* latest_ts_val = getElemPRT(evp.first.pid(), evp.first.rid(), evp.first.tid(), latest_ts);
655-
if(latest_ts_val != nullptr && evp.first.ts() < *latest_ts_val) fatal_error("event ordering error! [counter]");
659+
unsigned long rid = evp.first.rid();
660+
unsigned long ts = evp.first.ts();
661+
if(latest_count_ts.size() < rid+1) latest_count_ts.resize(rid+1, -1);
662+
if(latest_ts.size() < rid+1) latest_ts.resize(rid+1, -1);
663+
664+
if(latest_count_ts[rid] != -1 && ts < latest_count_ts[rid]) fatal_error("parsed counter data is not in time order");
665+
if(latest_ts[rid] != -1 && ts < latest_ts[rid]) fatal_error("event ordering error! [counter]");
656666
out.push_back(evp.first);
657-
latest_ts[evp.first.pid()][evp.first.rid()][evp.first.tid()] = latest_count_ts[evp.first.pid()][evp.first.rid()][evp.first.tid()] = evp.first.ts();
667+
latest_ts[rid] = latest_count_ts[rid] = ts;
658668
}
659669
counterData = this->getCounterData(++idx_counterData);
660670
}else{

0 commit comments

Comments
 (0)