Skip to content

Commit

Permalink
#2389: trace: start tracing invoke calls (starting with objgroup)
Browse files Browse the repository at this point in the history
  • Loading branch information
lifflander committed Jan 13, 2025
1 parent 57843f0 commit 0f740e6
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 3 deletions.
11 changes: 11 additions & 0 deletions src/vt/context/runnable_context/trace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@

namespace vt { namespace ctx {

Trace::Trace(
trace::TraceEventIDType event, HandlerType const in_handler,
NodeType const in_from_node, std::size_t msg_size
) : is_collection_(false),
event_(event),
msg_size_(msg_size),
is_traced_(HandlerManager::isHandlerTrace(in_handler)),
from_node_(in_from_node),
handler_(in_handler)
{ }

void Trace::start(TimeType time) {
if (not is_traced_) {
return;
Expand Down
14 changes: 14 additions & 0 deletions src/vt/context/runnable_context/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@ struct Trace {

Trace() = default;

/**
* \brief Construct a new trace context (basic processing) without a message
* directly
*
* \param[in] event the trace event
* \param[in] in_handler the handler
* \param[in] in_from_node from node
* \param[in] msg_size size of message/payload (zero of not serializable
*/
Trace(
trace::TraceEventIDType event, HandlerType const in_handler,
NodeType const in_from_node, std::size_t msg_size
);

/**
* \brief Construct a new trace context (basic processing event)
*
Expand Down
17 changes: 16 additions & 1 deletion src/vt/objgroup/manager.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,26 @@ ObjGroupManager::invoke(ProxyElmType<ObjT> proxy, Args&&... args) {
dest_node == this_node,
fmt::format(
"Attempting to invoke handler on node:{} instead of node:{}!\n",
this_node, dest_node));
this_node, dest_node
)
);

#if vt_check_enabled(trace_enabled)
auto const ctrl = proxy::ObjGroupProxy::getID(proxy.getProxy());
auto const han = auto_registry::makeAutoHandlerObjGroupParam<
ObjT, decltype(f), f, void
>(ctrl);
auto const trace_event = theMsg()->makeTraceCreationSend(han, 0, false);

return runnable::makeRunnableVoidTraced(false, han, this_node, trace_event, 0)
.withObjGroup(get(proxy))
.runLambda(f, get(proxy), std::forward<Args>(args)...);

#else
return runnable::makeRunnableVoid(false, uninitialized_handler, this_node)
.withObjGroup(get(proxy))
.runLambda(f, get(proxy), std::forward<Args>(args)...);
#endif
}


Expand Down
34 changes: 32 additions & 2 deletions src/vt/runnable/make_runnable.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,8 @@ RunnableMaker<U> makeRunnable(
}

/**
* \brief Make a new runnable without a message (void handler)
* \brief Make a new runnable without a message (void handler) -- untraced
* variant. Call \c makeRunnableVoidTraced if you want it to show up in tracing
*
* \param[in] is_threaded whether it is threaded
* \param[in] handler the handler bits
Expand All @@ -364,11 +365,40 @@ inline RunnableMaker<BaseMsgType> makeRunnableVoid(
) {
// These are currently only types of registry entries that can be void
auto r = new RunnableNew(is_threaded);
// @todo: figure out how to trace this?
r->addContextSetContext(r, from);
return RunnableMaker<BaseMsgType>{r, nullptr, handler, from};
}

/**
* \brief Make a new runnable without a message (void handler) with tracing
*
* \param[in] is_threaded whether it is threaded
* \param[in] handler the handler bits
* \param[in] from the node that caused this runnable to execute
*
* \return the maker for further customization
*/
inline RunnableMaker<BaseMsgType> makeRunnableVoidTraced(
bool is_threaded, HandlerType handler, NodeType from,
[[maybe_unused]] trace::TraceEventIDType trace_event,
[[maybe_unused]] std::size_t msg_size
) {
// These are currently only types of registry entries that can be void
auto r = new RunnableNew(is_threaded);
r->addContextSetContext(r, from);

#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->addContextTrace(trace_event, handler, from, msg_size);
}
#endif

return RunnableMaker<BaseMsgType>{r, nullptr, handler, from};
}

}} /* end namespace vt::runnable */

#include "vt/runnable/make_runnable.impl.h"
Expand Down

0 comments on commit 0f740e6

Please sign in to comment.