Skip to content

Commit 9301a53

Browse files
committed
Fix piextProgramCreateWithNativeHandle after merge
1 parent d628ef2 commit 9301a53

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

sycl/plugins/level_zero/pi_level0.cpp

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,12 +1906,27 @@ pi_result piextProgramCreateWithNativeHandle(pi_native_handle NativeHandle,
19061906
assert(Context);
19071907
assert(Program);
19081908

1909-
auto ZeModule = pi_cast<ze_module_handle_t *>(NativeHandle);
1910-
assert(*ZeModule);
1911-
// Create PI program from the given L0 module handle
1912-
auto ZePIProgram = new _pi_program(*ZeModule, Context);
1909+
auto ZeModule = pi_cast<ze_module_handle_t>(NativeHandle);
1910+
1911+
// Create PI program from the given L0 module handle.
1912+
//
1913+
// TODO: We don't have the real L0 module descriptor with
1914+
// which it was created, but that's only needed for zeModuleCreate,
1915+
// which we don't expect to be called on the interop program.
1916+
//
1917+
ze_module_desc_t ZeModuleDesc = {};
1918+
ZeModuleDesc.version = ZE_MODULE_DESC_VERSION_CURRENT;
1919+
ZeModuleDesc.format = ZE_MODULE_FORMAT_NATIVE;
1920+
ZeModuleDesc.inputSize = 0;
1921+
ZeModuleDesc.pInputModule = nullptr;
19131922

1914-
*Program = pi_cast<pi_program>(ZePIProgram);
1923+
try {
1924+
*Program = new _pi_program(ZeModule, ZeModuleDesc, Context);
1925+
} catch (const std::bad_alloc &) {
1926+
return PI_OUT_OF_HOST_MEMORY;
1927+
} catch (...) {
1928+
return PI_ERROR_UNKNOWN;
1929+
}
19151930
return PI_SUCCESS;
19161931
}
19171932

0 commit comments

Comments
 (0)