Skip to content

Commit

Permalink
#2187: Fix order of traces for addUserNotePre/Epi
Browse files Browse the repository at this point in the history
  • Loading branch information
thearusable authored and cz4rs committed Sep 20, 2024
1 parent bd7c091 commit 5536b39
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
31 changes: 14 additions & 17 deletions src/vt/trace/trace_user.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,39 +118,36 @@ void addUserBracketedNote(
}

#if vt_check_enabled(trace_enabled)
struct UserSplitHolder final {
static std::unordered_map<std::string, TimeType> split_;
struct UserNoteHolder final {
static std::unordered_map<std::string, TraceScopedNote> notes_;
};

/*static*/ std::unordered_map<std::string, TimeType> UserSplitHolder::split_ = {};
/*static*/ std::unordered_map<std::string, TraceScopedNote> UserNoteHolder::notes_ = {};
#endif

void addUserNotePre(
[[maybe_unused]] std::string const& note,
[[maybe_unused]] TraceEventIDType const
[[maybe_unused]] std::string const& in_note,
[[maybe_unused]] TraceEventIDType const in_event
) {
#if vt_check_enabled(trace_enabled)
auto iter = UserSplitHolder::split_.find(note);
vtAssertExpr(iter == UserSplitHolder::split_.end());
UserSplitHolder::split_.emplace(
auto iter = UserNoteHolder::notes_.find(in_note);
vtAssertExpr(iter == UserNoteHolder::notes_.end());
UserNoteHolder::notes_.emplace(
std::piecewise_construct,
std::forward_as_tuple(note),
std::forward_as_tuple(Trace::getCurrentTime())
std::forward_as_tuple(in_note),
std::forward_as_tuple(in_note, in_event)
);
#endif
}

void addUserNoteEpi(
[[maybe_unused]] std::string const& in_note,
[[maybe_unused]] TraceEventIDType const event
[[maybe_unused]] TraceEventIDType const in_event
) {
#if vt_check_enabled(trace_enabled)
auto iter = UserSplitHolder::split_.find(in_note);
vtAssertExpr(iter != UserSplitHolder::split_.end());
auto begin = iter->second;
auto end = Trace::getCurrentTime();
theTrace()->addUserBracketedNote(begin, end, in_note, event);
UserSplitHolder::split_.erase(iter);
auto iter = UserNoteHolder::notes_.find(in_note);
vtAssertExpr(iter != UserNoteHolder::notes_.end());
UserNoteHolder::notes_.erase(iter);
#endif
}

Expand Down
6 changes: 6 additions & 0 deletions src/vt/trace/trace_user.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ void addUserBracketedNote(

/**
* \brief Log the start for a bracketed user event with a note
*
* \note See \c TraceScopedNote for a safer scope-based logging mechanism for
* bracketed user events with a note.
*
* \param[in] note the note
* \param[in] event the pre-registered user event ID
Expand All @@ -144,6 +147,9 @@ void addUserNotePre(std::string const& note, TraceEventIDType const event);
/**
* \brief Log the end for a bracketed user event with a note
*
* \note See \c TraceScopedNote for a safer scope-based logging mechanism for
* bracketed user events with a note.
*
* \param[in] note the note
* \param[in] event the pre-registered user event ID
*/
Expand Down

0 comments on commit 5536b39

Please sign in to comment.