Skip to content

Commit

Permalink
Merge pull request #2143 from aarongreig/aaron/fixClCreateWithILReturns
Browse files Browse the repository at this point in the history
Return more accurate errors from CL's ProgramCreateWithIL
  • Loading branch information
aarongreig authored Oct 24, 2024
2 parents 809e853 + 2bbc4e8 commit a96fdde
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
19 changes: 18 additions & 1 deletion source/adapters/opencl/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramCreateWithIL(

*phProgram = cl_adapter::cast<ur_program_handle_t>(clCreateProgramWithIL(
cl_adapter::cast<cl_context>(hContext), pIL, length, &Err));
CL_RETURN_ON_FAILURE(Err);
} else {

/* If none of the devices conform with CL 2.1 or newer make sure they all
Expand Down Expand Up @@ -109,6 +108,24 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramCreateWithIL(

*phProgram = cl_adapter::cast<ur_program_handle_t>(
FuncPtr(cl_adapter::cast<cl_context>(hContext), pIL, length, &Err));
}

// INVALID_VALUE is only returned in three circumstances according to the cl
// spec:
// * pIL == NULL
// * length == 0
// * pIL is not a well-formed binary
// UR has a unique error code for each of these, so here we figure out which
// to return
if (Err == CL_INVALID_VALUE) {
if (pIL == nullptr) {
return UR_RESULT_ERROR_INVALID_NULL_POINTER;
}
if (length == 0) {
return UR_RESULT_ERROR_INVALID_SIZE;
}
return UR_RESULT_ERROR_INVALID_BINARY;
} else {
CL_RETURN_ON_FAILURE(Err);
}

Expand Down
2 changes: 0 additions & 2 deletions test/conformance/program/program_adapter_opencl.match

This file was deleted.

0 comments on commit a96fdde

Please sign in to comment.