Skip to content

Commit 9af788a

Browse files
committed
#2389: vrt_coll: implement traced invoke calls on collection elements
1 parent 2c0d8ea commit 9af788a

File tree

4 files changed

+97
-0
lines changed

4 files changed

+97
-0
lines changed

src/vt/context/runnable_context/trace.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,22 @@ Trace::Trace(
6565
handler_(in_handler)
6666
{ }
6767

68+
Trace::Trace(
69+
trace::TraceEventIDType event, HandlerType const in_handler,
70+
NodeType const in_from_node, std::size_t msg_size,
71+
uint64_t in_idx1, uint64_t in_idx2, uint64_t in_idx3, uint64_t in_idx4
72+
) : is_collection_(false),
73+
event_(event),
74+
msg_size_(msg_size),
75+
is_traced_(HandlerManager::isHandlerTrace(in_handler)),
76+
from_node_(in_from_node),
77+
handler_(in_handler),
78+
idx1_(in_idx1),
79+
idx2_(in_idx2),
80+
idx3_(in_idx3),
81+
idx4_(in_idx4)
82+
{ }
83+
6884
void Trace::start(TimeType time) {
6985
if (not is_traced_) {
7086
return;

src/vt/context/runnable_context/trace.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,26 @@ struct Trace {
7575
NodeType const in_from_node, std::size_t msg_size
7676
);
7777

78+
/**
79+
* \brief Construct a new trace context (collection processing) without a
80+
* message directly
81+
*
82+
* \param[in] event the trace event
83+
* \param[in] in_handler the handler
84+
* \param[in] in_from_node from node
85+
* \param[in] msg_size size of message/payload (zero of not serializable
86+
* \param[in] in_idx1 1-dimension index
87+
* \param[in] in_idx2 2-dimension index
88+
* \param[in] in_idx3 3-dimension index
89+
* \param[in] in_idx4 4-dimension index
90+
*/
91+
Trace(
92+
trace::TraceEventIDType event, HandlerType const in_handler,
93+
NodeType const in_from_node, std::size_t msg_size,
94+
uint64_t in_idx1, uint64_t in_idx2, uint64_t in_idx3, uint64_t in_idx4
95+
);
96+
97+
7898
/**
7999
* \brief Construct a new trace context (basic processing event)
80100
*

src/vt/runnable/make_runnable.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,44 @@ inline RunnableMaker<BaseMsgType> makeRunnableVoidTraced(
399399
return RunnableMaker<BaseMsgType>{r, nullptr, handler, from};
400400
}
401401

402+
/**
403+
* \brief Make a new runnable without a message (void handler) with tracing for
404+
* collections
405+
*
406+
* \param[in] is_threaded whether it is threaded
407+
* \param[in] handler the handler bits
408+
* \param[in] from the node that caused this runnable to execute
409+
* \param[in] idx1 1-dimension index
410+
* \param[in] idx2 2-dimension index
411+
* \param[in] idx3 3-dimension index
412+
* \param[in] idx4 4-dimension index
413+
*
414+
* \return the maker for further customization
415+
*/
416+
inline RunnableMaker<BaseMsgType> makeRunnableVoidTraced(
417+
bool is_threaded, HandlerType handler, NodeType from,
418+
[[maybe_unused]] trace::TraceEventIDType trace_event,
419+
[[maybe_unused]] std::size_t msg_size,
420+
uint64_t idx1, uint64_t idx2, uint64_t idx3, uint64_t idx4
421+
) {
422+
// These are currently only types of registry entries that can be void
423+
auto r = new RunnableNew(is_threaded);
424+
r->addContextSetContext(r, from);
425+
426+
#if vt_check_enabled(trace_enabled)
427+
auto const han_type = HandlerManager::getHandlerRegistryType(handler);
428+
if (han_type == auto_registry::RegistryTypeEnum::RegVrtCollection or
429+
han_type == auto_registry::RegistryTypeEnum::RegVrtCollectionMember) {
430+
r->addContextTrace(
431+
trace_event, handler, from, msg_size, idx1, idx2, idx3, idx4
432+
);
433+
}
434+
#endif
435+
436+
return RunnableMaker<BaseMsgType>{r, nullptr, handler, from};
437+
}
438+
439+
402440
}} /* end namespace vt::runnable */
403441

404442
#include "vt/runnable/make_runnable.impl.h"

src/vt/vrt/collection/manager.impl.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,10 +465,33 @@ auto CollectionManager::invoke(
465465

466466
auto const this_node = theContext()->getNode();
467467

468+
#if vt_check_enabled(trace_enabled)
469+
auto const han = auto_registry::makeAutoHandlerCollectionMemParam<
470+
ColT, decltype(f), f, void
471+
>();
472+
auto const trace_event = theMsg()->makeTraceCreationSend(han, 0, false);
473+
474+
#if vt_check_enabled(trace_enabled)
475+
auto idx = ptr->getIndex();
476+
uint64_t const idx1 = idx.ndims() > 0 ? idx[0] : 0;
477+
uint64_t const idx2 = idx.ndims() > 1 ? idx[1] : 0;
478+
uint64_t const idx3 = idx.ndims() > 2 ? idx[2] : 0;
479+
uint64_t const idx4 = idx.ndims() > 3 ? idx[3] : 0;
480+
#endif
481+
482+
return runnable::makeRunnableVoidTraced(
483+
false, han, this_node, trace_event, 0, idx1, idx2, idx3, idx4
484+
)
485+
.withCollection(ptr)
486+
.withLBDataVoidMsg(ptr)
487+
.runLambda(f, ptr, std::forward<Args>(args)...);
488+
489+
#else
468490
return runnable::makeRunnableVoid(false, uninitialized_handler, this_node)
469491
.withCollection(ptr)
470492
.withLBDataVoidMsg(ptr)
471493
.runLambda(f, ptr, std::forward<Args>(args)...);
494+
#endif
472495
}
473496

474497
template <

0 commit comments

Comments
 (0)