Skip to content

Commit 31b654f

Browse files
authored
Merge pull request #1053 from jandres742/url0leakkey
[UR][L0] Add UR_L0_LEAKS_DEBUG key
2 parents 71957e8 + 3da2133 commit 31b654f

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

source/adapters/level_zero/adapter.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ ur_result_t adapterStateTeardown() {
3838
// Print the balance of various create/destroy native calls.
3939
// The idea is to verify if the number of create(+) and destroy(-) calls are
4040
// matched.
41-
if (ZeCallCount && (UrL0Debug & UR_L0_DEBUG_CALL_COUNT) != 0) {
41+
if (ZeCallCount && (UrL0LeaksDebug) != 0) {
4242
// clang-format off
4343
//
4444
// The format of this table is such that each row accounts for a
@@ -79,8 +79,7 @@ ur_result_t adapterStateTeardown() {
7979
//
8080
// clang-format on
8181

82-
fprintf(stderr, "ZE_DEBUG=%d: check balance of create/destroy calls\n",
83-
UR_L0_DEBUG_CALL_COUNT);
82+
fprintf(stderr, "Check balance of create/destroy calls\n");
8483
fprintf(stderr,
8584
"----------------------------------------------------------\n");
8685
for (const auto &Row : CreateDestroySet) {

source/adapters/level_zero/common.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ ze_result_t ZeCall::doCall(ze_result_t ZeResult, const char *ZeName,
149149
const char *ZeArgs, bool TraceError) {
150150
urPrint("ZE ---> %s%s\n", ZeName, ZeArgs);
151151

152-
if (UrL0Debug & UR_L0_DEBUG_CALL_COUNT) {
152+
if (UrL0LeaksDebug) {
153153
++(*ZeCallCount)[ZeName];
154154
}
155155

source/adapters/level_zero/common.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ enum UrDebugLevel {
187187
UR_L0_DEBUG_NONE = 0x0,
188188
UR_L0_DEBUG_BASIC = 0x1,
189189
UR_L0_DEBUG_VALIDATION = 0x2,
190-
UR_L0_DEBUG_CALL_COUNT = 0x4,
191190
UR_L0_DEBUG_ALL = -1
192191
};
193192

@@ -203,6 +202,13 @@ const int UrL0Debug = [] {
203202
return DebugMode;
204203
}();
205204

205+
const int UrL0LeaksDebug = [] {
206+
const char *UrRet = std::getenv("UR_L0_LEAKS_DEBUG");
207+
if (!UrRet)
208+
return 0;
209+
return std::atoi(UrRet);
210+
}();
211+
206212
// Controls Level Zero calls serialization to w/a Level Zero driver being not MT
207213
// ready. Recognized values (can be used as a bit mask):
208214
enum {

source/adapters/level_zero/platform.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urPlatformGet(
3030
static std::once_flag ZeCallCountInitialized;
3131
try {
3232
std::call_once(ZeCallCountInitialized, []() {
33-
if (UrL0Debug & UR_L0_DEBUG_CALL_COUNT) {
33+
if (UrL0LeaksDebug) {
3434
ZeCallCount = new std::map<std::string, int>;
3535
}
3636
});

0 commit comments

Comments
 (0)