Skip to content

[SYCL][PI][L0] Skip modules without kernel inside when creating target kernel on L0 #3614

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 9 commits into from
May 14, 2021
18 changes: 14 additions & 4 deletions sycl/plugins/level_zero/pi_level_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3501,10 +3501,20 @@ pi_result piKernelCreate(pi_program Program, const char *KernelName,
ze_result_t ZeResult = ZE_RESULT_ERROR_INVALID_KERNEL_NAME;
_pi_program::ModuleIterator ModIt(Program);
while (!ModIt.Done()) {
ZeResult =
ZE_CALL_NOCHECK(zeKernelCreate, (*ModIt, &ZeKernelDesc, &ZeKernel));
if (ZeResult != ZE_RESULT_ERROR_INVALID_KERNEL_NAME)
break;
// For a module with valid sycl kernel inside, zeKernelCreate API
// should return ZE_RESULT_SUCCESS if target kernel is found and
// ZE_RESULT_ERROR_INVALID_KERNEL_NAME otherwise. However, some module
// may not include any sycl kernel such as device library modules. For such
// modules, zeKernelCreate will return ZE_RESULT_ERROR_INVALID_ARGUMENT and
// we should skip them.
uint32_t KernelNum = 0;
ZE_CALL(zeModuleGetKernelNames, (*ModIt, &KernelNum, nullptr));
if (KernelNum != 0) {
ZeResult =
ZE_CALL_NOCHECK(zeKernelCreate, (*ModIt, &ZeKernelDesc, &ZeKernel));
if (ZeResult != ZE_RESULT_ERROR_INVALID_KERNEL_NAME)
break;
}
ModIt++;
}
if (ZeResult != ZE_RESULT_SUCCESS)
Expand Down