Skip to content

Commit

Permalink
#2187: Use TraceScopedNote instead of addUserBracketedNote(...)
Browse files Browse the repository at this point in the history
  • Loading branch information
thearusable authored and cz4rs committed Sep 20, 2024
1 parent cfa388b commit bd7c091
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 25 deletions.
9 changes: 4 additions & 5 deletions src/vt/event/event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,9 @@ AsyncEvent::EventStateType AsyncEvent::testEventComplete(EventType const& event)
void AsyncEvent::testEventsTrigger(int const& num_events) {
# if vt_check_enabled(trace_enabled)
int32_t num_completed = 0;
auto tr_begin = TimeType{0.0};

std::unique_ptr<trace::TraceScopedNote> trace_note;
if (theConfig()->vt_trace_event_polling) {
tr_begin = timing::getCurrentTime();
trace_note = std::make_unique<trace::TraceScopedNote>("", trace_event_polling);
}
# endif

Expand Down Expand Up @@ -356,9 +355,9 @@ void AsyncEvent::testEventsTrigger(int const& num_events) {
# if vt_check_enabled(trace_enabled)
if (theConfig()->vt_trace_event_polling) {
if (num_completed > 0) {
TimeType tr_end = timing::getCurrentTime();
auto tr_note = fmt::format("completed {} of {}", num_completed, cur);
trace::addUserBracketedNote(tr_begin, tr_end, tr_note, trace_event_polling);
trace_note->setNote(tr_note);
trace_note->end();
}
} else {
(void)num_completed;
Expand Down
32 changes: 16 additions & 16 deletions src/vt/messaging/active.cc
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,9 @@ EventType ActiveMessenger::sendMsgMPI(
{
VT_ALLOW_MPI_CALLS;
#if vt_check_enabled(trace_enabled)
auto tr_begin = TimeType{0.};
std::unique_ptr<trace::TraceScopedNote> trace_note;
if (theConfig()->vt_trace_mpi) {
tr_begin = vt::timing::getCurrentTime();
trace_note = std::make_unique<trace::TraceScopedNote>("", trace_isend);
}
#endif
int const ret = MPI_Isend(
Expand All @@ -362,9 +362,9 @@ EventType ActiveMessenger::sendMsgMPI(

#if vt_check_enabled(trace_enabled)
if (theConfig()->vt_trace_mpi) {
auto tr_end = vt::timing::getCurrentTime();
auto tr_note = fmt::format("Isend(AM): dest={}, bytes={}", dest, msg_size);
trace::addUserBracketedNote(tr_begin, tr_end, tr_note, trace_isend);
trace_note->setNote(tr_note);
trace_note->end();
}
#endif
}
Expand Down Expand Up @@ -581,9 +581,9 @@ std::tuple<EventType, int> ActiveMessenger::sendDataMPI(
);
{
#if vt_check_enabled(trace_enabled)
auto tr_begin = TimeType{0.};
std::unique_ptr<trace::TraceScopedNote> trace_note;
if (theConfig()->vt_trace_mpi) {
tr_begin = vt::timing::getCurrentTime();
trace_note = std::make_unique<trace::TraceScopedNote>("", trace_isend);
}
#endif

Expand All @@ -603,9 +603,9 @@ std::tuple<EventType, int> ActiveMessenger::sendDataMPI(

#if vt_check_enabled(trace_enabled)
if (theConfig()->vt_trace_mpi) {
auto tr_end = vt::timing::getCurrentTime();
auto tr_note = fmt::format("Isend(Data): dest={}, bytes={}", dest, subsize);
trace::addUserBracketedNote(tr_begin, tr_end, tr_note, trace_isend);
trace_note->setNote(tr_note);
trace_note->end();
}
#endif
}
Expand Down Expand Up @@ -771,9 +771,9 @@ void ActiveMessenger::recvDataDirect(
);

#if vt_check_enabled(trace_enabled)
auto tr_begin = TimeType{0.};
std::unique_ptr<trace::TraceScopedNote> trace_note;
if (theConfig()->vt_trace_mpi) {
tr_begin = vt::timing::getCurrentTime();
trace_note = std::make_unique<trace::TraceScopedNote>("", trace_irecv);
}
#endif

Expand All @@ -790,12 +790,12 @@ void ActiveMessenger::recvDataDirect(

#if vt_check_enabled(trace_enabled)
if (theConfig()->vt_trace_mpi) {
auto tr_end = vt::timing::getCurrentTime();
auto tr_note = fmt::format(
"Irecv(Data): from={}, bytes={}",
from, sublen
);
trace::addUserBracketedNote(tr_begin, tr_end, tr_note, trace_irecv);
trace_note->setNote(tr_note);
trace_note->end();
}
#endif

Expand Down Expand Up @@ -1008,9 +1008,9 @@ bool ActiveMessenger::tryProcessIncomingActiveMsg() {

{
#if vt_check_enabled(trace_enabled)
auto tr_begin = TimeType{0.};
std::unique_ptr<trace::TraceScopedNote> trace_note;
if (theConfig()->vt_trace_mpi) {
tr_begin = vt::timing::getCurrentTime();
trace_note = std::make_unique<trace::TraceScopedNote>("", trace_irecv);
}
#endif

Expand All @@ -1024,12 +1024,12 @@ bool ActiveMessenger::tryProcessIncomingActiveMsg() {

#if vt_check_enabled(trace_enabled)
if (theConfig()->vt_trace_mpi) {
auto tr_end = vt::timing::getCurrentTime();
auto tr_note = fmt::format(
"Irecv(AM): from={}, bytes={}",
stat.MPI_SOURCE, num_probe_bytes
);
trace::addUserBracketedNote(tr_begin, tr_end, tr_note, trace_irecv);
trace_note->setNote(tr_note);
trace_note->end();
}
#endif
}
Expand Down
8 changes: 4 additions & 4 deletions src/vt/messaging/request_holder.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ struct RequestHolder {
bool testAll(Callable c, int& num_mpi_tests) {
# if vt_check_enabled(trace_enabled)
std::size_t const holder_size_start = holder_.size();
auto tr_begin = TimeType{0.0};
std::unique_ptr<trace::TraceScopedNote> trace_note;
if (theConfig()->vt_trace_irecv_polling) {
tr_begin = vt::timing::getCurrentTime();
trace_note = std::make_unique<trace::TraceScopedNote>("", trace_user_event_);
}
# endif

Expand Down Expand Up @@ -131,13 +131,13 @@ struct RequestHolder {
# if vt_check_enabled(trace_enabled)
if (theConfig()->vt_trace_irecv_polling) {
if (holder_size_start > 0) {
auto tr_end = vt::timing::getCurrentTime();
auto tr_note = fmt::format(
"completed {} of {}",
holder_size_start - holder_.size(),
holder_size_start
);
trace::addUserBracketedNote(tr_begin, tr_end, tr_note, trace_user_event_);
trace_note->setNote(tr_note);
trace_note->end();
}
}
# endif
Expand Down
5 changes: 5 additions & 0 deletions src/vt/trace/trace_user.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ struct TraceScopedNote final {
if (event_ != no_user_event_id) {
auto end = TraceLite::getCurrentTime();
log_->end_time = end;
log_->setUserNote(note_);
theTrace()->decrementIncompleteEvents();
event_ = no_user_event_id;
}
Expand All @@ -328,6 +329,10 @@ struct TraceScopedNote final {
event_ = in_event;
}

void setNote(std::string const& in_note) {
note_ = in_note;
}

private:
TimeType begin_ = TimeType{0.0};
TraceEventIDType event_ = no_trace_event;
Expand Down

0 comments on commit bd7c091

Please sign in to comment.