Skip to content

L0 relax device check #5339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions sycl/plugins/level_zero/pi_level_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3786,7 +3786,6 @@ pi_result piProgramLink(pi_context Context, pi_uint32 NumDevices,
void (*PFnNotify)(pi_program Program, void *UserData),
void *UserData, pi_program *RetProgram) {
// We only support one device with Level Zero currently.
pi_device Device = Context->Devices[0];
if (NumDevices != 1) {
zePrint("piProgramLink: level_zero supports only one device.");
return PI_INVALID_VALUE;
Expand All @@ -3806,7 +3805,13 @@ pi_result piProgramLink(pi_context Context, pi_uint32 NumDevices,
}

// Validate input parameters.
PI_ASSERT(DeviceList && DeviceList[0] == Device, PI_INVALID_DEVICE);
PI_ASSERT(DeviceList, PI_INVALID_DEVICE);
{
auto DeviceEntry =
find(Context->Devices.begin(), Context->Devices.end(), DeviceList[0]);
if (DeviceEntry == Context->Devices.end())
return PI_INVALID_DEVICE;
}
PI_ASSERT(!PFnNotify && !UserData, PI_INVALID_VALUE);
if (NumInputPrograms == 0 || InputPrograms == nullptr)
return PI_INVALID_VALUE;
Expand Down Expand Up @@ -3989,7 +3994,14 @@ pi_result piProgramBuild(pi_program Program, pi_uint32 NumDevices,
PI_ASSERT(!PFnNotify && !UserData, PI_INVALID_VALUE);

std::scoped_lock Guard(Program->Mutex);

// Check if device belongs to associated context.
PI_ASSERT(Program->Context, PI_INVALID_PROGRAM);
{
auto DeviceEntry = find(Program->Context->Devices.begin(),
Program->Context->Devices.end(), DeviceList[0]);
if (DeviceEntry == Program->Context->Devices.end())
return PI_INVALID_VALUE;
}
// It is legal to build a program created from either IL or from native
// device code.
if (Program->State != _pi_program::IL &&
Expand Down