Skip to content

Commit 2930a94

Browse files
authored
[SYCL] Workaround bugs in Level Zero driver (#5380)
Work around two bugs in the Level Zero driver, related to the "ze_module_program_exp_desc_t" extension (aka "static linking").
1 parent 19369b6 commit 2930a94

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3900,10 +3900,30 @@ pi_result piProgramLink(pi_context Context, pi_uint32 NumDevices,
39003900
ZeModuleDesc.pNext = &ZeExtModuleDesc;
39013901
ZeModuleDesc.format = ZE_MODULE_FORMAT_IL_SPIRV;
39023902

3903+
// This works around a bug in the Level Zero driver. When "ZE_DEBUG=-1",
3904+
// the driver does validation of the API calls, and it expects
3905+
// "pInputModule" to be non-NULL and "inputSize" to be non-zero. This
3906+
// validation is wrong when using the "ze_module_program_exp_desc_t"
3907+
// extension because those fields are supposed to be ignored. As a
3908+
// workaround, set both fields to 1.
3909+
//
3910+
// TODO: Remove this workaround when the driver is fixed.
3911+
ZeModuleDesc.pInputModule = reinterpret_cast<const uint8_t *>(1);
3912+
ZeModuleDesc.inputSize = 1;
3913+
39033914
// We need a Level Zero extension to compile multiple programs together into
39043915
// a single Level Zero module. However, we don't need that extension if
39053916
// there happens to be only one input program.
3906-
if (!PiDriverModuleProgramExtensionFound) {
3917+
//
3918+
// The "|| (NumInputPrograms == 1)" term is a workaround for a bug in the
3919+
// Level Zero driver. The driver's "ze_module_program_exp_desc_t"
3920+
// extension should work even in the case when there is just one input
3921+
// module. However, there is currently a bug in the driver that leads to a
3922+
// crash. As a workaround, do not use the extension when there is one
3923+
// input module.
3924+
//
3925+
// TODO: Remove this workaround when the driver is fixed.
3926+
if (!PiDriverModuleProgramExtensionFound || (NumInputPrograms == 1)) {
39073927
if (NumInputPrograms == 1) {
39083928
ZeModuleDesc.pNext = nullptr;
39093929
ZeModuleDesc.inputSize = ZeExtModuleDesc.inputSizes[0];

0 commit comments

Comments
 (0)