Skip to content

Commit 7068457

Browse files
[SYCL] L0 relax device check (#5339)
Solve the issue when gpu on multi-adapter system is filtered out on device check stage.
1 parent 5746906 commit 7068457

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3814,7 +3814,6 @@ pi_result piProgramLink(pi_context Context, pi_uint32 NumDevices,
38143814
void (*PFnNotify)(pi_program Program, void *UserData),
38153815
void *UserData, pi_program *RetProgram) {
38163816
// We only support one device with Level Zero currently.
3817-
pi_device Device = Context->Devices[0];
38183817
if (NumDevices != 1) {
38193818
zePrint("piProgramLink: level_zero supports only one device.");
38203819
return PI_INVALID_VALUE;
@@ -3834,7 +3833,13 @@ pi_result piProgramLink(pi_context Context, pi_uint32 NumDevices,
38343833
}
38353834

38363835
// Validate input parameters.
3837-
PI_ASSERT(DeviceList && DeviceList[0] == Device, PI_INVALID_DEVICE);
3836+
PI_ASSERT(DeviceList, PI_INVALID_DEVICE);
3837+
{
3838+
auto DeviceEntry =
3839+
find(Context->Devices.begin(), Context->Devices.end(), DeviceList[0]);
3840+
if (DeviceEntry == Context->Devices.end())
3841+
return PI_INVALID_DEVICE;
3842+
}
38383843
PI_ASSERT(!PFnNotify && !UserData, PI_INVALID_VALUE);
38393844
if (NumInputPrograms == 0 || InputPrograms == nullptr)
38403845
return PI_INVALID_VALUE;
@@ -4017,7 +4022,14 @@ pi_result piProgramBuild(pi_program Program, pi_uint32 NumDevices,
40174022
PI_ASSERT(!PFnNotify && !UserData, PI_INVALID_VALUE);
40184023

40194024
std::scoped_lock Guard(Program->Mutex);
4020-
4025+
// Check if device belongs to associated context.
4026+
PI_ASSERT(Program->Context, PI_INVALID_PROGRAM);
4027+
{
4028+
auto DeviceEntry = find(Program->Context->Devices.begin(),
4029+
Program->Context->Devices.end(), DeviceList[0]);
4030+
if (DeviceEntry == Program->Context->Devices.end())
4031+
return PI_INVALID_VALUE;
4032+
}
40214033
// It is legal to build a program created from either IL or from native
40224034
// device code.
40234035
if (Program->State != _pi_program::IL &&

0 commit comments

Comments
 (0)