From e4e471f0561e4f7f373b50ca334e6ce21398913d Mon Sep 17 00:00:00 2001 From: Caleb Schilly Date: Tue, 14 Jan 2025 12:24:34 -0500 Subject: [PATCH] #2387: overload + op for UserEventRegistry and implement gather for user_event_ --- src/vt/trace/trace.cc | 4 ---- src/vt/trace/trace.h | 8 ------- src/vt/trace/trace_lite.cc | 37 +++----------------------------- src/vt/trace/trace_lite.h | 1 - src/vt/trace/trace_user_event.cc | 23 ++++++++------------ 5 files changed, 12 insertions(+), 61 deletions(-) diff --git a/src/vt/trace/trace.cc b/src/vt/trace/trace.cc index d5e1077dab..c4d2ed0f1c 100644 --- a/src/vt/trace/trace.cc +++ b/src/vt/trace/trace.cc @@ -220,10 +220,6 @@ void insertNewUserEvent( #endif } -void Trace::addHashedEvent(UserEventIDType event_id) { - theTrace()->user_hashed_events_.push_back(event_id); -} - void Trace::addUserEvent(UserEventIDType event) { if (not checkDynamicRuntimeEnabled()) { return; diff --git a/src/vt/trace/trace.h b/src/vt/trace/trace.h index 87cc998664..232f36d4e5 100644 --- a/src/vt/trace/trace.h +++ b/src/vt/trace/trace.h @@ -220,13 +220,6 @@ struct Trace : runtime::component::Component, TraceLite { */ void registerUserEventManual(std::string const& name, UserSpecEventIDType id); - /** - * \brief Store a hashed event ID - * - * \param[in] event_id the hashed event ID - */ - void addHashedEvent(UserEventIDType event_id); - /** * \brief Log a user event * @@ -381,7 +374,6 @@ struct Trace : runtime::component::Component, TraceLite { | idle_begun_ | start_time_ | user_event_ - | user_hashed_events_ | prog_name_ | trace_name_ | full_trace_name_ diff --git a/src/vt/trace/trace_lite.cc b/src/vt/trace/trace_lite.cc index 1f082d8fb9..d52661cf73 100644 --- a/src/vt/trace/trace_lite.cc +++ b/src/vt/trace/trace_lite.cc @@ -59,7 +59,6 @@ #include #include #include -#include namespace vt { #if vt_check_enabled(trace_only) @@ -546,39 +545,9 @@ void TraceLite::writeTracesFile(int flush, bool is_incremental_flush) { auto const comm = theContext()->getComm(); auto const comm_size = theContext()->getNumNodes(); - // Gather all hashed events to rank 0 before writing sts file - using events_t = std::vector; - auto const root = 0; - events_t local_hashed_events = theTrace()->user_hashed_events_; - int local_size = local_hashed_events.size(); - std::vector all_sizes(comm_size); - MPI_Gather(&local_size, 1, MPI_INT, all_sizes.data(), 1, MPI_INT, 0, comm); - - // Compute displacements - std::vector displs(comm_size, 0); - if (node == 0) { - std::partial_sum(all_sizes.begin(), all_sizes.end() - 1, displs.begin() + 1); - } - - // Create vector in which to store all events - events_t all_hashed_events; - if (node == 0) { - int total_size = std::accumulate(all_sizes.begin(), all_sizes.end(), 0); - all_hashed_events.resize(total_size); - } - - // Gather events - MPI_Gatherv( - local_hashed_events.data(), // Send buffer - local_size, // Number of elements to send - MPI_UINT32_T, // Data type (adjust to match UserEventIDType) - all_hashed_events.data(), // Receive buffer (on root) - all_sizes.data(), // Number of elements to receive from each rank - displs.data(), // Displacements for each rank - MPI_UINT32_T, // Data type (adjust to match UserEventIDType) - root, // Root node - comm // Communicator - ); + vt::runInEpochCollective([&]{ + proxy.reduce(0, std::move(user_event_)); + }); size_t to_write = traces_.size(); diff --git a/src/vt/trace/trace_lite.h b/src/vt/trace/trace_lite.h index 1924f6c2ef..096a506b45 100644 --- a/src/vt/trace/trace_lite.h +++ b/src/vt/trace/trace_lite.h @@ -427,7 +427,6 @@ struct TraceLite { int incremental_flush_mode_ = 0; UserEventRegistry user_event_ = {}; - std::vector user_hashed_events_; EventHoldStackType event_holds_; TraceStackType open_events_; TraceContainerType traces_; diff --git a/src/vt/trace/trace_user_event.cc b/src/vt/trace/trace_user_event.cc index e5e3f7158b..3232ea0228 100644 --- a/src/vt/trace/trace_user_event.cc +++ b/src/vt/trace/trace_user_event.cc @@ -82,21 +82,12 @@ UserEventIDType UserEventRegistry::hash(std::string const& in_event_name) { id_hash = id_hash & 0x0FFF; auto ret = newEventImpl(false, false, in_event_name, id_hash, true); auto id = std::get<0>(ret); - auto inserted = std::get<1>(ret); - if (inserted) { - vt::theTrace()->addHashedEvent(id); - } return id; } UserEventIDType UserEventRegistry::rooted(std::string const& in_event_name) { auto ret = newEventImpl(false, true, in_event_name, cur_root_event_++); auto id = std::get<0>(ret); - auto const node = theContext()->getNode(); - if (node != 0) { - auto msg = makeMessage(false, id, in_event_name); - theMsg()->sendMsg(0, msg); - } return id; } @@ -105,11 +96,6 @@ UserEventIDType UserEventRegistry::user( ) { auto ret = newEventImpl(true, false, in_event_name, seq); auto id = std::get<0>(ret); - auto const node = theContext()->getNode(); - if (node != 0) { - auto msg = makeMessage(true, id, in_event_name); - theMsg()->sendMsg(0, msg); - } return id; } #endif @@ -141,9 +127,18 @@ bool UserEventRegistry::insertEvent( ); return true; } else { + user_event_[event] += " COLLISION " + name; return false; } } +UserEventRegistry operator+( + UserEventRegistry r1, UserEventRegistry const& r2 +) { + for (auto& [hash, event_str] : r2.getEvents()) { + r1.insertEvent(hash, event_str); + } + return r1; +} }} /* end namespace vt::trace */