Skip to content

Commit 38e0246

Browse files
committed
address review
Signed-off-by: Sergey V Maslov <[email protected]>
1 parent 821aa16 commit 38e0246

File tree

6 files changed

+35
-32
lines changed

6 files changed

+35
-32
lines changed

sycl/doc/EnvironmentVariables.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ variables in production code.</span>
152152
| `SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE_FOR_D2D_COPY` (experimental) | Integer | Allows the use of copy engine, if available in the device, in Level Zero plugin for device to device copy operations. The default is 0. This option is experimental and will be removed once heuristics are added to make a decision about use of copy engine for device to device copy operations. |
153153
| `SYCL_PI_LEVEL_ZERO_DEVICE_SCOPE_EVENTS` | Any(\*) | Enable support of device-scope events whose state is not visible to the host. If enabled mode is SYCL_PI_LEVEL_ZERO_DEVICE_SCOPE_EVENTS=1 the Level Zero plugin would create all events having device-scope only and create proxy host-visible events for them when their status is needed (wait/query) on the host. If enabled mode is SYCL_PI_LEVEL_ZERO_DEVICE_SCOPE_EVENTS=2 the Level Zero plugin would create all events having device-scope and add proxy host-visible event at the end of each command-list submission. The default is 2, meaning only the last event in a batch is host-visible. |
154154
| `SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS` | Integer | When set to a positive value enables use of Level Zero immediate commandlists, which means there is no batching and all commands are immediately submitted for execution. Default is 0. Note: When immediate commandlist usage is enabled it is necessary to also set SYCL_PI_LEVEL_ZERO_DEVICE_SCOPE_EVENTS to either 0 or 1. |
155-
| `SYCL_PI_LEVEL_ZERO_ENABLE_TRACING` | Any(\*) | Enable XPTI-based tracing in L0 plugin |
156155

157156
## Debugging variables for CUDA Plugin
158157

sycl/plugins/level_zero/pi_level_zero.cpp

100644100755
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ static pi_result EventCreate(pi_context Context, pi_queue Queue,
3636
bool HostVisible, pi_event *RetEvent);
3737
}
3838

39-
void enableL0Tracing();
39+
// Defined in tracing.cpp
40+
void enableZeTracing();
41+
void disableZeTracing();
4042

4143
namespace {
4244

@@ -7944,10 +7946,7 @@ pi_result piPluginInit(pi_plugin *PluginInit) {
79447946
(PluginInit->PiFunctionTable).api = (decltype(&::api))(&api);
79457947
#include <CL/sycl/detail/pi.def>
79467948

7947-
if (std::getenv("SYCL_PI_LEVEL_ZERO_ENABLE_TRACING") != nullptr) {
7948-
enableL0Tracing();
7949-
}
7950-
7949+
enableZeTracing();
79517950
return PI_SUCCESS;
79527951
}
79537952

@@ -8054,6 +8053,8 @@ pi_result piTearDown(void *PluginParameter) {
80548053
}
80558054
if (LeakFound)
80568055
return PI_INVALID_MEM_OBJECT;
8056+
8057+
disableZeTracing();
80578058
return PI_SUCCESS;
80588059
}
80598060

sycl/plugins/level_zero/tracing.cpp

100644100755
Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-------------- tracing.cpp - L0 Host API Tracing ----------------------==//
1+
//===-------------- tracing.cpp - Level-Zero Host API Tracing --------------==//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
@@ -14,8 +14,8 @@
1414

1515
#include <iostream>
1616

17-
constexpr auto L0_CALL_STREAM_NAME = "sycl.experimental.level_zero.call";
18-
constexpr auto L0_DEBUG_STREAM_NAME = "sycl.experimental.level_zero.debug";
17+
constexpr auto ZE_CALL_STREAM_NAME = "sycl.experimental.level_zero.call";
18+
constexpr auto ZE_DEBUG_STREAM_NAME = "sycl.experimental.level_zero.debug";
1919

2020
thread_local uint64_t CallCorrelationID = 0;
2121
thread_local uint64_t DebugCorrelationID = 0;
@@ -35,25 +35,25 @@ enum class ZEApiKind {
3535
#undef _ZE_API
3636
};
3737

38-
void enableL0Tracing() {
38+
void enableZeTracing() {
3939
#ifdef XPTI_ENABLE_INSTRUMENTATION
4040
if (!xptiTraceEnabled())
4141
return;
4242

43-
xptiRegisterStream(L0_CALL_STREAM_NAME);
44-
xptiInitialize(L0_CALL_STREAM_NAME, GMajVer, GMinVer, GVerStr);
45-
xptiRegisterStream(L0_DEBUG_STREAM_NAME);
46-
xptiInitialize(L0_DEBUG_STREAM_NAME, GMajVer, GMinVer, GVerStr);
43+
xptiRegisterStream(ZE_CALL_STREAM_NAME);
44+
xptiInitialize(ZE_CALL_STREAM_NAME, GMajVer, GMinVer, GVerStr);
45+
xptiRegisterStream(ZE_DEBUG_STREAM_NAME);
46+
xptiInitialize(ZE_DEBUG_STREAM_NAME, GMajVer, GMinVer, GVerStr);
4747

4848
uint64_t Dummy;
49-
xpti::payload_t L0Payload("Level Zero Plugin Layer");
49+
xpti::payload_t ZePayload("Level Zero Plugin Layer");
5050
GCallEvent =
51-
xptiMakeEvent("L0 Plugin Layer", &L0Payload, xpti::trace_algorithm_event,
51+
xptiMakeEvent("Level Zero Plugin Layer", &ZePayload, xpti::trace_algorithm_event,
5252
xpti_at::active, &Dummy);
5353

54-
xpti::payload_t L0DebugPayload("L0 Plugin Debug Layer");
54+
xpti::payload_t ZeDebugPayload("Level Zero Plugin Debug Layer");
5555
GDebugEvent =
56-
xptiMakeEvent("L0 Plugin Debug Layer", &L0DebugPayload,
56+
xptiMakeEvent("Level Zero Plugin Debug Layer", &ZeDebugPayload,
5757
xpti::trace_algorithm_event, xpti_at::active, &Dummy);
5858

5959
ze_result_t Status = zeInit(0);
@@ -70,7 +70,7 @@ void enableL0Tracing() {
7070
Status = zelTracerCreate(&TracerDesc, &Tracer);
7171

7272
if (Status != ZE_RESULT_SUCCESS || Tracer == nullptr) {
73-
std::cerr << "[WARNING] Failed to create L0 tracer: " << Status << "\n";
73+
std::cerr << "[WARNING] Failed to create Level Zero tracer: " << Status << "\n";
7474
return;
7575
}
7676

@@ -80,8 +80,8 @@ void enableL0Tracing() {
8080
#define _ZE_API(call, domain, cb, params_type) \
8181
Prologue.domain.cb = [](params_type *Params, ze_result_t, void *, void **) { \
8282
if (xptiTraceEnabled()) { \
83-
uint8_t CallStreamID = xptiRegisterStream(L0_CALL_STREAM_NAME); \
84-
uint8_t DebugStreamID = xptiRegisterStream(L0_DEBUG_STREAM_NAME); \
83+
uint8_t CallStreamID = xptiRegisterStream(ZE_CALL_STREAM_NAME); \
84+
uint8_t DebugStreamID = xptiRegisterStream(ZE_DEBUG_STREAM_NAME); \
8585
CallCorrelationID = xptiGetUniqueId(); \
8686
DebugCorrelationID = xptiGetUniqueId(); \
8787
const char *FuncName = #call; \
@@ -100,8 +100,8 @@ void enableL0Tracing() {
100100
Epilogue.domain.cb = [](params_type *Params, ze_result_t Result, void *, \
101101
void **) { \
102102
if (xptiTraceEnabled()) { \
103-
uint8_t CallStreamID = xptiRegisterStream(L0_CALL_STREAM_NAME); \
104-
uint8_t DebugStreamID = xptiRegisterStream(L0_DEBUG_STREAM_NAME); \
103+
uint8_t CallStreamID = xptiRegisterStream(ZE_CALL_STREAM_NAME); \
104+
uint8_t DebugStreamID = xptiRegisterStream(ZE_DEBUG_STREAM_NAME); \
105105
const char *FuncName = #call; \
106106
xptiNotifySubscribers(CallStreamID, \
107107
(uint16_t)xpti::trace_point_type_t::function_end, \
@@ -122,24 +122,29 @@ void enableL0Tracing() {
122122

123123
Status = zelTracerSetPrologues(Tracer, &Prologue);
124124
if (Status != ZE_RESULT_SUCCESS) {
125-
std::cerr << "Failed to enable L0 tracing\n";
125+
std::cerr << "Failed to enable Level Zero tracing\n";
126126
std::terminate();
127127
}
128128
Status = zelTracerSetEpilogues(Tracer, &Epilogue);
129129
if (Status != ZE_RESULT_SUCCESS) {
130-
std::cerr << "Failed to enable L0 tracing\n";
130+
std::cerr << "Failed to enable Level Zero tracing\n";
131131
std::terminate();
132132
}
133133

134134
Status = zelTracerSetEnabled(Tracer, true);
135135
if (Status != ZE_RESULT_SUCCESS) {
136-
std::cerr << "Failed to enable L0 tracing\n";
136+
std::cerr << "Failed to enable Level Zero tracing\n";
137137
std::terminate();
138138
}
139-
#endif
139+
#endif // XPTI_ENABLE_INSTRUMENTATION
140140
}
141141

142-
void disableL0Tracing() {
143-
xptiFinalize(L0_CALL_STREAM_NAME);
144-
xptiFinalize(L0_DEBUG_STREAM_NAME);
142+
void disableZeTracing() {
143+
#ifdef XPTI_ENABLE_INSTRUMENTATION
144+
if (!xptiTraceEnabled())
145+
return;
146+
147+
xptiFinalize(ZE_CALL_STREAM_NAME);
148+
xptiFinalize(ZE_DEBUG_STREAM_NAME);
149+
#endif // XPTI_ENABLE_INSTRUMENTATION
145150
}

sycl/tools/sycl-prof/main.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ int main(int argc, char **argv, char *env[]) {
4545
NewEnv.push_back("XPTI_FRAMEWORK_DISPATCHER=libxptifw.so");
4646
NewEnv.push_back("XPTI_SUBSCRIBERS=libsycl_profiler_collector.so");
4747
NewEnv.push_back("XPTI_TRACE_ENABLE=1");
48-
NewEnv.push_back("SYCL_PI_LEVEL_ZERO_ENABLE_TRACING=1");
4948
NewEnv.push_back("ZE_ENABLE_TRACING_LAYER=1");
5049

5150
std::vector<std::string> Args;

sycl/tools/sycl-trace/collector.cpp

100644100755
File mode changed.

sycl/tools/sycl-trace/main.cpp

100644100755
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ int main(int argc, char **argv, char *env[]) {
5656
};
5757
const auto EnableZETrace = [&]() {
5858
NewEnv.push_back("SYCL_TRACE_ZE_ENABLE=1");
59-
NewEnv.push_back("SYCL_PI_LEVEL_ZERO_ENABLE_TRACING=1");
6059
NewEnv.push_back("ZE_ENABLE_TRACING_LAYER=1");
6160
};
6261

0 commit comments

Comments
 (0)