Skip to content

Commit e1b2ff4

Browse files
committed
#2387: trace: fix callback in reduce call
1 parent 86979fe commit e1b2ff4

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

src/vt/trace/trace.cc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ void Trace::setProxy(objgroup::proxy::Proxy<Trace> in_proxy) {
125125
proxy_ = in_proxy;
126126
}
127127

128-
/*static*/ std::unique_ptr<Trace> Trace::construct() {
129-
auto ptr = std::make_unique<Trace>();
128+
/*static*/ std::unique_ptr<Trace> Trace::construct(std::string const& in_prog_name) {
129+
auto ptr = std::make_unique<Trace>(in_prog_name);
130130
auto proxy = theObjGroup()->makeCollective<Trace>(
131131
ptr.get(), "Trace"
132132
);
@@ -210,13 +210,12 @@ void Trace::addUserData(int32_t data) {
210210
);
211211
}
212212

213-
void Trace::reducedEventsHan(UserEventRegistry gathered_user_events) {
214-
vtAssert(theContext()->getNode() == 0, "Must be node 0");
215-
user_event_ = gathered_user_events;
213+
void Trace::setUserEvents(const UserEventRegistry& events) {
214+
user_event_ = std::move(events);
216215
}
217216

218217
void Trace::gatherUserEvents() {
219-
proxy_.reduce<&Trace::reducedEventsHan, vt::collective::PlusOp>(0, std::move(user_event_));
218+
proxy_.reduce<&reducedEventsHan, vt::collective::PlusOp>(0, user_event_);
220219
}
221220

222221
UserEventIDType Trace::registerUserEventRoot(std::string const& name) {
@@ -233,6 +232,11 @@ void Trace::registerUserEventManual(
233232
user_event_.user(name, id);
234233
}
235234

235+
void reducedEventsHan(const UserEventRegistry& gathered_user_events) {
236+
vtAssert(theContext()->getNode() == 0, "Must be node 0");
237+
theTrace()->setUserEvents(gathered_user_events);
238+
}
239+
236240
void insertNewUserEvent(
237241
[[maybe_unused]] UserEventIDType event,
238242
[[maybe_unused]] std::string const& name

src/vt/trace/trace.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@
6565

6666
namespace vt { namespace trace {
6767

68+
// Callback for gathering user events on node 0
69+
void reducedEventsHan(const UserEventRegistry& gathered_user_events);
70+
6871
/// Tracking information for beginProcessing/endProcessing.
6972
struct TraceProcessingTag {
7073

@@ -108,8 +111,6 @@ struct TraceProcessingTag {
108111
* java Projections tool.
109112
*/
110113
struct Trace : runtime::component::Component<Trace>, TraceLite {
111-
112-
113114
/**
114115
* \internal \brief System call to construct the trace component
115116
*
@@ -123,12 +124,12 @@ struct Trace : runtime::component::Component<Trace>, TraceLite {
123124

124125
friend struct Log;
125126

127+
static std::unique_ptr<Trace> construct(std::string const& in_prog_name = "Trace");
126128
void initialize() override;
127129
void startup() override;
128130
void finalize() override;
129131

130132
void setProxy(objgroup::proxy::Proxy<Trace> in_proxy);
131-
static std::unique_ptr<Trace> construct();
132133

133134
/**
134135
* \brief Initiate a paired processing event.
@@ -295,7 +296,7 @@ struct Trace : runtime::component::Component<Trace>, TraceLite {
295296
* \brief Update event registry on Node 0 with all gathered events
296297
* \param[in] gathered_user_events summed registry of user events from all nodes
297298
*/
298-
void reducedEventsHan(UserEventRegistry gathered_user_events);
299+
void setUserEvents(const UserEventRegistry& events);
299300

300301
/**
301302
* \brief Gathers all user-defined event hashes onto node 0.

0 commit comments

Comments
 (0)