Skip to content

[SYCL] Reduce cost of XPTI instrumentation #5158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions sycl/source/detail/plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,16 @@ class plugin {
// the per_instance_user_data field.
const char *PIFnName = PiCallInfo.getFuncName();
uint64_t CorrelationID = pi::emitFunctionBeginTrace(PIFnName);
auto ArgsData =
packCallArguments<PiApiOffset>(std::forward<ArgsT>(Args)...);
uint64_t CorrelationIDWithArgs =
pi::emitFunctionWithArgsBeginTrace(static_cast<uint32_t>(PiApiOffset),
PIFnName, ArgsData.data(), *MPlugin);
uint64_t CorrelationIDWithArgs = 0;
unsigned char *ArgsDataPtr = nullptr;
// TODO check if stream is observed when corresponding API is present.
if (xptiTraceEnabled()) {
auto ArgsData =
packCallArguments<PiApiOffset>(std::forward<ArgsT>(Args)...);
ArgsDataPtr = ArgsData.data();
CorrelationIDWithArgs = pi::emitFunctionWithArgsBeginTrace(
static_cast<uint32_t>(PiApiOffset), PIFnName, ArgsDataPtr, *MPlugin);
}
#endif
RT::PiResult R;
if (pi::trace(pi::TraceLevel::PI_TRACE_CALLS)) {
Expand All @@ -175,7 +180,7 @@ class plugin {
pi::emitFunctionEndTrace(CorrelationID, PIFnName);
pi::emitFunctionWithArgsEndTrace(CorrelationIDWithArgs,
static_cast<uint32_t>(PiApiOffset),
PIFnName, ArgsData.data(), R, *MPlugin);
PIFnName, ArgsDataPtr, R, *MPlugin);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should you also put lines 180-181 under if (xptiTraceEnabled())?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. Bodies of those functions are wrapped with if (xptiTraceEnabled()) already. The main overhead here is from packing arguments.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It just looks strange that the call to emitFunctionWithArgsBeginTrace is guarded above (I assume their bodies also have that check) but these are not. Anyways, I am fine as is if you don't want to change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I'm planning some more changes to shut down notifications, that are not received by any party. This is a temporary fix for the problem anyway.

#endif
return R;
}
Expand Down