Skip to content

Commit 7d9f5ac

Browse files
authored
[SYCL] Retain build-log when program build failed (#8848)
We should retain the build log when the program build failed. The build log is retrieved by SYCL RT. --------- Signed-off-by: Byoungro So <[email protected]>
1 parent e12574f commit 7d9f5ac

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4004,10 +4004,6 @@ pi_result piProgramBuild(pi_program Program, pi_uint32 NumDevices,
40044004
// RT calls piProgramRelease().
40054005
Program->State = _pi_program::Invalid;
40064006
Result = mapError(ZeResult);
4007-
if (Program->ZeBuildLog) {
4008-
ZE_CALL_NOCHECK(zeModuleBuildLogDestroy, (Program->ZeBuildLog));
4009-
Program->ZeBuildLog = nullptr;
4010-
}
40114007
if (ZeModule) {
40124008
ZE_CALL_NOCHECK(zeModuleDestroy, (ZeModule));
40134009
ZeModule = nullptr;
@@ -4075,6 +4071,18 @@ pi_result piProgramGetBuildInfo(pi_program Program, pi_device Device,
40754071
if (ParamValueSizeRet) {
40764072
*ParamValueSizeRet = LogSize;
40774073
}
4074+
if (ParamValue) {
4075+
// When the program build fails in piProgramBuild(), we delayed cleaning
4076+
// up the build log because RT later calls this routine to get the
4077+
// failed build log.
4078+
// To avoid memory leaks, we should clean up the failed build log here
4079+
// because RT does not create sycl::program when piProgramBuild() fails,
4080+
// thus it won't call piProgramRelease() to clean up the build log.
4081+
if (Program->State == _pi_program::Invalid) {
4082+
ZE_CALL_NOCHECK(zeModuleBuildLogDestroy, (Program->ZeBuildLog));
4083+
Program->ZeBuildLog = nullptr;
4084+
}
4085+
}
40784086
return PI_SUCCESS;
40794087
}
40804088

0 commit comments

Comments
 (0)