Skip to content

Commit

Permalink
Module leak (intel#8153)
Browse files Browse the repository at this point in the history
When it is failed to build a program, L0 throws an exception, which
causes sycl::program to fail to create.
Because of this, RT won't call piProgramRelease(), which leads to memory
leaks.
The solution is to release ZeModule created by plugin when the program
build is failed.

---------

Signed-off-by: Byoungro So <[email protected]>
  • Loading branch information
bso-intel authored Mar 7, 2023
1 parent ecc3bc6 commit 77866ff
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion sycl/plugins/level_zero/pi_level_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3827,9 +3827,16 @@ pi_result piProgramBuild(pi_program Program, pi_uint32 NumDevices,
if (ZeResult != ZE_RESULT_SUCCESS) {
// We adjust pi_program below to avoid attempting to release zeModule when
// RT calls piProgramRelease().
ZeModule = nullptr;
Program->State = _pi_program::Invalid;
Result = mapError(ZeResult);
if (Program->ZeBuildLog) {
ZE_CALL_NOCHECK(zeModuleBuildLogDestroy, (Program->ZeBuildLog));
Program->ZeBuildLog = nullptr;
}
if (ZeModule) {
ZE_CALL_NOCHECK(zeModuleDestroy, (ZeModule));
ZeModule = nullptr;
}
} else {
// The call to zeModuleCreate does not report an error if there are
// unresolved symbols because it thinks these could be resolved later via a
Expand All @@ -3842,6 +3849,10 @@ pi_result piProgramBuild(pi_program Program, pi_uint32 NumDevices,
Result = (ZeResult == ZE_RESULT_ERROR_MODULE_LINK_FAILURE)
? PI_ERROR_BUILD_PROGRAM_FAILURE
: mapError(ZeResult);
if (ZeModule) {
ZE_CALL_NOCHECK(zeModuleDestroy, (ZeModule));
ZeModule = nullptr;
}
}
}

Expand Down

0 comments on commit 77866ff

Please sign in to comment.