Skip to content

Commit

Permalink
Merge pull request #2093 from lslusarczyk/memleak-fix
Browse files Browse the repository at this point in the history
fixed issue #1990, L0 leaks checker counts successful create/destroy only
  • Loading branch information
pbalcer authored Sep 18, 2024
2 parents 3cd6eae + 4bb6a10 commit 6298474
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
12 changes: 6 additions & 6 deletions source/adapters/level_zero/adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,11 @@ void globalAdapterOnDemandCleanup() {
}

ur_result_t adapterStateTeardown() {
bool LeakFound = false;

// Print the balance of various create/destroy native calls.
// The idea is to verify if the number of create(+) and destroy(-) calls are
// matched.
if (ZeCallCount && (UrL0LeaksDebug) != 0) {
bool LeakFound = false;
// clang-format off
//
// The format of this table is such that each row accounts for a
Expand Down Expand Up @@ -276,11 +275,12 @@ ur_result_t adapterStateTeardown() {
ZeCallCount->clear();
delete ZeCallCount;
ZeCallCount = nullptr;
if (LeakFound)
return UR_RESULT_ERROR_INVALID_MEM_OBJECT;
}
if (LeakFound)
return UR_RESULT_ERROR_INVALID_MEM_OBJECT;
// Due to multiple DLLMain definitions with SYCL, register to cleanup the
// Global Adapter after refcnt is 0

// Due to multiple DLLMain definitions with SYCL, register to cleanup the
// Global Adapter after refcnt is 0
#if defined(_WIN32)
umfTearDown();
std::atexit(globalAdapterOnDemandCleanup);
Expand Down
9 changes: 6 additions & 3 deletions source/adapters/level_zero/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,14 @@ ze_result_t ZeCall::doCall(ze_result_t ZeResult, const char *ZeName,
const char *ZeArgs, bool TraceError) {
logger::debug("ZE ---> {}{}", ZeName, ZeArgs);

if (UrL0LeaksDebug) {
++(*ZeCallCount)[ZeName];
if (ZeResult == ZE_RESULT_SUCCESS) {
if (UrL0LeaksDebug) {
++(*ZeCallCount)[ZeName];
}
return ZE_RESULT_SUCCESS;
}

if (ZeResult && TraceError) {
if (TraceError) {
const char *ErrorString = "Unknown";
zeParseError(ZeResult, ErrorString);
logger::error("Error ({}) in {}", ErrorString, ZeName);
Expand Down

0 comments on commit 6298474

Please sign in to comment.