Skip to content

Commit

Permalink
#1899: Don't add trace context when tracing is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
thearusable committed Aug 24, 2022
1 parent 05579f9 commit df61780
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/vt/runnable/make_runnable.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ struct RunnableMaker {
return std::move(*this);
}

#if vt_check_enabled(trace_enabled)
/**
* \brief Add a trace index (for collection elements)
*
Expand All @@ -229,6 +230,7 @@ struct RunnableMaker {
);
return std::move(*this);
}
#endif

/**
* \brief Add a tag to the handler
Expand Down Expand Up @@ -317,12 +319,14 @@ RunnableMaker<U> makeRunnable(
MsgSharedPtr<U> const& msg, bool is_threaded, HandlerType handler, NodeType from
) {
auto r = std::make_unique<RunnableNew>(msg, is_threaded);
#if vt_check_enabled(trace_enabled)
auto const han_type = HandlerManager::getHandlerRegistryType(handler);
if (han_type == auto_registry::RegistryTypeEnum::RegVrt or
han_type == auto_registry::RegistryTypeEnum::RegGeneral or
han_type == auto_registry::RegistryTypeEnum::RegObjGroup) {
r->template addContext<ctx::Trace>(msg, handler, from);
}
#endif
r->template addContext<ctx::SetContext>(r.get(), from);
return RunnableMaker<U>{std::move(r), msg, handler, from};
}
Expand Down
8 changes: 8 additions & 0 deletions src/vt/vrt/collection/manager.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,18 +211,22 @@ CollectionManager::collectionAutoMsgDeliver(
) {
auto user_msg = makeMessage<UserMsgT>(std::move(msg->getMsg()));

#if vt_check_enabled(trace_enabled)
// Expand out the index for tracing purposes; Projections takes up to
// 4-dimensions
auto idx = base->getIndex();
uint64_t const idx1 = idx.ndims() > 0 ? idx[0] : 0;
uint64_t const idx2 = idx.ndims() > 1 ? idx[1] : 0;
uint64_t const idx3 = idx.ndims() > 2 ? idx[2] : 0;
uint64_t const idx4 = idx.ndims() > 3 ? idx[3] : 0;
#endif

runnable::makeRunnable(user_msg, true, han, from)
.withTDEpoch(theMsg()->getEpochContextMsg(msg))
.withCollection(base)
#if vt_check_enabled(trace_enabled)
.withTraceIndex(event, idx1, idx2, idx3, idx4)
#endif
.withLBData(base, msg)
.runOrEnqueue(immediate);
}
Expand All @@ -233,19 +237,23 @@ CollectionManager::collectionAutoMsgDeliver(
MsgT* msg, Indexable<IndexT>* base, HandlerType han, NodeType from,
trace::TraceEventIDType event, bool immediate
) {
#if vt_check_enabled(trace_enabled)
// Expand out the index for tracing purposes; Projections takes up to
// 4-dimensions
auto idx = base->getIndex();
uint64_t const idx1 = idx.ndims() > 0 ? idx[0] : 0;
uint64_t const idx2 = idx.ndims() > 1 ? idx[1] : 0;
uint64_t const idx3 = idx.ndims() > 2 ? idx[2] : 0;
uint64_t const idx4 = idx.ndims() > 3 ? idx[3] : 0;
#endif

auto m = promoteMsg(msg);
runnable::makeRunnable(m, true, han, from)
.withTDEpoch(theMsg()->getEpochContextMsg(msg))
.withCollection(base)
#if vt_check_enabled(trace_enabled)
.withTraceIndex(event, idx1, idx2, idx3, idx4)
#endif
.withLBData(base)
.runOrEnqueue(immediate);
}
Expand Down

0 comments on commit df61780

Please sign in to comment.