From 5536b39e3f9e6161559648c3a9d8ac01d68e38d4 Mon Sep 17 00:00:00 2001 From: Arkadiusz Szczepkowicz Date: Fri, 5 Jul 2024 15:35:54 +0200 Subject: [PATCH] #2187: Fix order of traces for addUserNotePre/Epi --- src/vt/trace/trace_user.cc | 31 ++++++++++++++----------------- src/vt/trace/trace_user.h | 6 ++++++ 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/vt/trace/trace_user.cc b/src/vt/trace/trace_user.cc index ba59e6d302..89a5eace7c 100644 --- a/src/vt/trace/trace_user.cc +++ b/src/vt/trace/trace_user.cc @@ -118,39 +118,36 @@ void addUserBracketedNote( } #if vt_check_enabled(trace_enabled) -struct UserSplitHolder final { - static std::unordered_map split_; +struct UserNoteHolder final { + static std::unordered_map notes_; }; -/*static*/ std::unordered_map UserSplitHolder::split_ = {}; +/*static*/ std::unordered_map 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 } diff --git a/src/vt/trace/trace_user.h b/src/vt/trace/trace_user.h index 6bdf198ece..29e70d0f7c 100644 --- a/src/vt/trace/trace_user.h +++ b/src/vt/trace/trace_user.h @@ -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 @@ -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 */