Skip to content

Commit 239fb5e

Browse files
authored
[SYCL][L0] Fix mismatched ZE call count (#4559)
We should create ZeCallCount map only once. Signed-off-by: Byoungro So byoungro.so@intel.com
1 parent 4c93051 commit 239fb5e

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,8 +1529,17 @@ pi_result piPlatformsGet(pi_uint32 NumEntries, pi_platform *Platforms,
15291529
PrintPiTrace = true;
15301530
}
15311531

1532-
if (ZeDebug & ZE_DEBUG_CALL_COUNT) {
1533-
ZeCallCount = new std::map<const char *, int>;
1532+
static std::once_flag ZeCallCountInitialized;
1533+
try {
1534+
std::call_once(ZeCallCountInitialized, []() {
1535+
if (ZeDebug & ZE_DEBUG_CALL_COUNT) {
1536+
ZeCallCount = new std::map<const char *, int>;
1537+
}
1538+
});
1539+
} catch (const std::bad_alloc &) {
1540+
return PI_OUT_OF_HOST_MEMORY;
1541+
} catch (...) {
1542+
return PI_ERROR_UNKNOWN;
15341543
}
15351544

15361545
if (NumEntries == 0 && Platforms != nullptr) {

0 commit comments

Comments
 (0)