Skip to content

[UR][OpenCL] Add missing mapping for CL_INVALID_KERNEL to UR OpenCL adapter and handle CL_INVALID_KERNEL_DEFINITION in urKernelCreate #18182

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 2 commits into from
May 8, 2025
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions unified-runtime/source/adapters/opencl/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ ur_result_t mapCLErrorToUR(cl_int Result) {
return UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_SIZE;
case CL_INVALID_SPEC_ID:
return UR_RESULT_ERROR_INVALID_SPEC_ID;
case CL_INVALID_KERNEL:
return UR_RESULT_ERROR_INVALID_KERNEL;
default:
return UR_RESULT_ERROR_UNKNOWN;
}
Expand Down
7 changes: 7 additions & 0 deletions unified-runtime/source/adapters/opencl/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ urKernelCreate(ur_program_handle_t hProgram, const char *pKernelName,
cl_int CLResult;
cl_kernel Kernel =
clCreateKernel(hProgram->CLProgram, pKernelName, &CLResult);

if (CLResult == CL_INVALID_KERNEL_DEFINITION) {
cl_adapter::setErrorMessage(
"clCreateKernel failed with CL_INVALID_KERNEL_DEFINITION", CLResult);
return UR_RESULT_ERROR_ADAPTER_SPECIFIC;
}

CL_RETURN_ON_FAILURE(CLResult);
auto URKernel = std::make_unique<ur_kernel_handle_t_>(Kernel, hProgram,
hProgram->Context);
Expand Down
Loading