Skip to content

Commit 93f66e7

Browse files
authored
[PTI-SDK] Fix disabling XPTI when sycl runtime tracing is not enabled (#36)
Until the user enables sycl runtime tracing, XPTI should be disabled after it is able to capture all the proper tracing streams (e.g. `sycl` and `sycl.pi`). This fixes a bug where this operation was happening in the wrong place. The `sycl.pi` stream does not have `graph_create` trace type. Instead, we moved it to the `funcion_begin` trace type. This will happen when the first sycl function is called. Signed-off-by: Schilling, Matthew <[email protected]>
1 parent 4b7f02c commit 93f66e7

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

sdk/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.0
1+
0.1.1

sdk/src/syclpi/sycl_collector.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,17 +179,20 @@ class SyclCollector {
179179
*/
180180

181181
switch (trace_type) {
182-
case xpti::trace_point_type_t::graph_create:
183-
SyclCollector::Instance().sycl_pi_graph_created_ = true;
182+
case xpti::trace_point_type_t::function_begin:
184183
// Until the user calls EnableTracing(), disable tracing when we are
185184
// able to capture the sycl runtime streams sycl and sycl.pi
186-
if (!SyclCollector::Instance().enabled_) {
187-
SyclCollector::Instance().DisableTracing();
185+
// Empirically, we found the sycl.pi stream gets emitted after the sycl
186+
// stream.
187+
if(!SyclCollector::Instance().sycl_pi_graph_created_) {
188+
SyclCollector::Instance().sycl_pi_graph_created_ = true;
189+
if (!SyclCollector::Instance().enabled_) {
190+
SyclCollector::Instance().DisableTracing();
191+
}
188192
}
189-
break;
190-
case xpti::trace_point_type_t::function_begin:
191193
sycl_data_kview.cid_ = UniCorrId::GetUniCorrId();
192194
sycl_data_mview.cid_ = sycl_data_kview.cid_;
195+
193196
if (UserData) {
194197
auto function_name = static_cast<const char*>(UserData);
195198
SPDLOG_DEBUG("\tSYCL.PI Function Begin: {}", function_name);
@@ -376,8 +379,6 @@ XPTI_CALLBACK_API void xptiTraceInit(unsigned int /*major_version*/, unsigned in
376379
SPDLOG_DEBUG("Registered callbacks for {}", stream_name);
377380
} else if (strcmp(stream_name, "sycl.pi") == 0) {
378381
stream_id = xptiRegisterStream(stream_name);
379-
xptiRegisterCallback(stream_id, static_cast<uint16_t>(xpti::trace_point_type_t::graph_create),
380-
SyclCollector::TpCallback);
381382
xptiRegisterCallback(stream_id, static_cast<uint16_t>(xpti::trace_point_type_t::function_begin),
382383
SyclCollector::TpCallback);
383384
xptiRegisterCallback(stream_id, static_cast<uint16_t>(xpti::trace_point_type_t::function_end),

0 commit comments

Comments
 (0)