Skip to content

Commit

Permalink
#2187: trace: first fix regular user events without a note
Browse files Browse the repository at this point in the history
  • Loading branch information
lifflander committed Sep 5, 2023
1 parent 62920a9 commit 016bb11
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 11 deletions.
28 changes: 24 additions & 4 deletions src/vt/trace/trace_lite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -247,21 +247,41 @@ bool TraceLite::checkDynamicRuntimeEnabled(bool is_end_event) {
(trace_enabled_cur_phase_ or is_end_event);
}

void TraceLite::addUserEventBracketed(
UserEventIDType event, double begin, double end) {
void TraceLite::addUserEventBracketedBegin(
UserEventIDType event, double begin
) {
if (not checkDynamicRuntimeEnabled()) {
return;
}

vt_debug_print(
normal, trace,
"Trace::addUserEventBracketed: event={:x}, begin={}, end={}\n",
event, begin, end);
"Trace::addUserEventBracketedBegin: event={:x}, begin={}\n",
event, begin
);

auto const type = TraceConstantsType::UserEventPair;
NodeType const node = theContext()->getNode();

logEvent(LogType{begin, type, node, event, true});
}

void TraceLite::addUserEventBracketedEnd(
UserEventIDType event, double end
) {
if (not checkDynamicRuntimeEnabled()) {
return;
}

vt_debug_print(
normal, trace,
"Trace::addUserEventBracketedEnd: event={:x}, end={}\n",
event, end
);

auto const type = TraceConstantsType::UserEventPair;
NodeType const node = theContext()->getNode();

logEvent(LogType{end, type, node, event, false});
}

Expand Down
11 changes: 9 additions & 2 deletions src/vt/trace/trace_lite.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,20 @@ struct TraceLite {
void disableTracing();

/**
* \brief Log a bracketed user event with start and end time
* \brief Log a bracketed user event with begin time
*
* \param[in] event the ID for the sts file
* \param[in] begin the begin time
*/
void addUserEventBracketedBegin(UserEventIDType event, double begin);

/**
* \brief Log a bracketed user event with end time
*
* \param[in] event the ID for the sts file
* \param[in] end the end time
*/
void addUserEventBracketed(UserEventIDType event, double begin, double end);
void addUserEventBracketedEnd(UserEventIDType event, double end);

/**
* \brief Log a user bracketed event with a note
Expand Down
11 changes: 6 additions & 5 deletions src/vt/trace/trace_user.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ struct TraceScopedEventHash final {
str_(in_str)
{
event_ = registerEventHashed(str_);
theTrace()->addUserEventBracketedBegin(event_, begin_);
}

TraceScopedEventHash& operator=(TraceScopedEventHash const&) = delete;
Expand All @@ -185,8 +186,7 @@ struct TraceScopedEventHash final {
void end() {
if (event_ != no_user_event_id) {
double end = TraceLite::getCurrentTime();
theTrace()->addUserEventBracketed(event_, begin_, end);

theTrace()->addUserEventBracketedEnd(event_, end);
event_ = no_user_event_id;
}
}
Expand Down Expand Up @@ -216,7 +216,9 @@ struct TraceScopedEvent final {
explicit TraceScopedEvent(UserEventIDType event)
: begin_(event != no_user_event_id ? TraceLite::getCurrentTime() : 0),
event_(event)
{ }
{
theTrace()->addUserEventBracketedBegin(event_, begin_);
}

TraceScopedEvent(TraceScopedEvent const&) = delete;
TraceScopedEvent(TraceScopedEvent &&other) noexcept
Expand All @@ -241,8 +243,7 @@ struct TraceScopedEvent final {
void end() {
if (event_ != no_user_event_id) {
double end = TraceLite::getCurrentTime();
theTrace()->addUserEventBracketed(event_, begin_, end);

theTrace()->addUserEventBracketedEnd(event_, end);
event_ = no_user_event_id;
}
}
Expand Down

0 comments on commit 016bb11

Please sign in to comment.