Skip to content

Commit

Permalink
#2387: trace: inherit virtual gather function from TraceLite
Browse files Browse the repository at this point in the history
  • Loading branch information
cwschilly committed Jan 15, 2025
1 parent 2daccb6 commit 1742430
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 6 deletions.
7 changes: 7 additions & 0 deletions src/vt/trace/trace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,12 @@ void Trace::addUserData(int32_t data) {
);
}

void Trace::gatherUserEvents() {
vt::runInEpochCollective([&]{
proxy.reduce<vt::collective::PlusOp>(0, std::move(user_event_));
});
}

UserEventIDType Trace::registerUserEventRoot(std::string const& name) {
return user_event_.rooted(name);
}
Expand Down Expand Up @@ -519,6 +525,7 @@ void Trace::setTraceEnabledCurrentPhase(PhaseType cur_phase) {
// Go ahead and perform a trace flush when tracing is disabled (and was
// previously enabled) to reduce memory footprint.
if (not ret and theConfig()->vt_trace_flush_size != 0) {
gatherUserEvents();
writeTracesFile(incremental_flush_mode, true);
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/vt/trace/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,11 @@ struct Trace : runtime::component::Component<Trace>, TraceLite {
*/
void addUserData(int32_t data);

/**
* \brief Gathers all user-defined event hashes onto node 0.
*/
void gatherUserEvents() override;

/**
* \brief Log a memory usage event
*
Expand Down
4 changes: 0 additions & 4 deletions src/vt/trace/trace_lite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -543,10 +543,6 @@ void TraceLite::flushTracesFile(bool useGlobalSync) {
void TraceLite::writeTracesFile(int flush, bool is_incremental_flush) {
auto const node = theContext()->getNode();

vt::runInEpochCollective([&]{
proxy.reduce<vt::collective::PlusOp>(0, std::move(user_event_));
});

size_t to_write = traces_.size();

if (traceWritingEnabled(node) and to_write > 0) {
Expand Down
5 changes: 5 additions & 0 deletions src/vt/trace/trace_lite.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ struct TraceLite {

virtual ~TraceLite();

/**
* \brief Gathers all user-defined event hashes onto node 0.
*/
virtual void gatherUserEvents();

/**
* \brief Set zlib incremental flush mode for trace file.
*
Expand Down
4 changes: 2 additions & 2 deletions src/vt/trace/trace_user_event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ bool UserEventRegistry::insertEvent(
std::forward_as_tuple(name)
);
return true;
} else {
} else if (user_event_[event] != name){
user_event_[event] += " COLLISION " + name;
return false;
}
return false;
}

UserEventRegistry operator+(
Expand Down
2 changes: 2 additions & 0 deletions src/vt/trace/trace_user_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ struct UserEventRegistry {

friend void insertNewUserEvent(UserEventIDType event, std::string const& name);

friend UserEventRegistry operator+(UserEventRegistry r1, UserEventRegistry const& r2);

template <typename Serializer>
void serialize(Serializer& s) {
s | cur_root_event_
Expand Down

0 comments on commit 1742430

Please sign in to comment.