From ceeda4ab1b1a91afa78efca722b8aa478daf3410 Mon Sep 17 00:00:00 2001 From: Martin Morrison-Grant <martin.morrisongrant@codeplay.com> Date: Thu, 24 Apr 2025 16:58:54 +0100 Subject: [PATCH 1/2] Add missing mapping for CL_INVALID_KERNEL to UR OpenCL adapter and add check for CL_INVALID_KERNEL_DEFINITION inside urKernelCreate. --- unified-runtime/source/adapters/opencl/common.cpp | 2 ++ unified-runtime/source/adapters/opencl/kernel.cpp | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/unified-runtime/source/adapters/opencl/common.cpp b/unified-runtime/source/adapters/opencl/common.cpp index 356c755d4ac21..123e7378a989f 100644 --- a/unified-runtime/source/adapters/opencl/common.cpp +++ b/unified-runtime/source/adapters/opencl/common.cpp @@ -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; } diff --git a/unified-runtime/source/adapters/opencl/kernel.cpp b/unified-runtime/source/adapters/opencl/kernel.cpp index 62fcabbf48efa..e220178c8f2db 100644 --- a/unified-runtime/source/adapters/opencl/kernel.cpp +++ b/unified-runtime/source/adapters/opencl/kernel.cpp @@ -67,6 +67,14 @@ 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( + "urKernelCreate failing with CL_INVALID_KERNEL_DEFINITION", + UR_RESULT_ERROR_ADAPTER_SPECIFIC); + return UR_RESULT_ERROR_ADAPTER_SPECIFIC; + } + CL_RETURN_ON_FAILURE(CLResult); auto URKernel = std::make_unique<ur_kernel_handle_t_>(Kernel, hProgram, hProgram->Context); From dde83bf5babf47db3771c429a2268fe532169742 Mon Sep 17 00:00:00 2001 From: Martin Grant <martingrant@outlook.com> Date: Wed, 30 Apr 2025 13:39:02 +0100 Subject: [PATCH 2/2] Update unified-runtime/source/adapters/opencl/kernel.cpp Co-authored-by: Kenneth Benzie (Benie) <k.benzie83@gmail.com> --- unified-runtime/source/adapters/opencl/kernel.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/unified-runtime/source/adapters/opencl/kernel.cpp b/unified-runtime/source/adapters/opencl/kernel.cpp index e220178c8f2db..0be1574d8c084 100644 --- a/unified-runtime/source/adapters/opencl/kernel.cpp +++ b/unified-runtime/source/adapters/opencl/kernel.cpp @@ -70,8 +70,7 @@ urKernelCreate(ur_program_handle_t hProgram, const char *pKernelName, if (CLResult == CL_INVALID_KERNEL_DEFINITION) { cl_adapter::setErrorMessage( - "urKernelCreate failing with CL_INVALID_KERNEL_DEFINITION", - UR_RESULT_ERROR_ADAPTER_SPECIFIC); + "clCreateKernel failed with CL_INVALID_KERNEL_DEFINITION", CLResult); return UR_RESULT_ERROR_ADAPTER_SPECIFIC; }