Skip to content

Commit 927fb89

Browse files
author
Alexander Batashev
authored
[SYCL] Reduce cost of XPTI instrumentation (#5158)
Argument pack added unwanted overhead. Guard it with `xptiTraceEnabled()` with the intention to guard it with new API, that would allow instrumented apps to check if the stream is observed.
1 parent 7224cb2 commit 927fb89

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

sycl/source/detail/plugin.hpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,16 @@ class plugin {
150150
// the per_instance_user_data field.
151151
const char *PIFnName = PiCallInfo.getFuncName();
152152
uint64_t CorrelationID = pi::emitFunctionBeginTrace(PIFnName);
153-
auto ArgsData =
154-
packCallArguments<PiApiOffset>(std::forward<ArgsT>(Args)...);
155-
uint64_t CorrelationIDWithArgs =
156-
pi::emitFunctionWithArgsBeginTrace(static_cast<uint32_t>(PiApiOffset),
157-
PIFnName, ArgsData.data(), *MPlugin);
153+
uint64_t CorrelationIDWithArgs = 0;
154+
unsigned char *ArgsDataPtr = nullptr;
155+
// TODO check if stream is observed when corresponding API is present.
156+
if (xptiTraceEnabled()) {
157+
auto ArgsData =
158+
packCallArguments<PiApiOffset>(std::forward<ArgsT>(Args)...);
159+
ArgsDataPtr = ArgsData.data();
160+
CorrelationIDWithArgs = pi::emitFunctionWithArgsBeginTrace(
161+
static_cast<uint32_t>(PiApiOffset), PIFnName, ArgsDataPtr, *MPlugin);
162+
}
158163
#endif
159164
RT::PiResult R;
160165
if (pi::trace(pi::TraceLevel::PI_TRACE_CALLS)) {
@@ -175,7 +180,7 @@ class plugin {
175180
pi::emitFunctionEndTrace(CorrelationID, PIFnName);
176181
pi::emitFunctionWithArgsEndTrace(CorrelationIDWithArgs,
177182
static_cast<uint32_t>(PiApiOffset),
178-
PIFnName, ArgsData.data(), R, *MPlugin);
183+
PIFnName, ArgsDataPtr, R, *MPlugin);
179184
#endif
180185
return R;
181186
}

0 commit comments

Comments
 (0)