Skip to content

Commit a96fdde

Browse files
authored
Merge pull request #2143 from aarongreig/aaron/fixClCreateWithILReturns
Return more accurate errors from CL's ProgramCreateWithIL
2 parents 809e853 + 2bbc4e8 commit a96fdde

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

source/adapters/opencl/program.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramCreateWithIL(
8181

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

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

110109
*phProgram = cl_adapter::cast<ur_program_handle_t>(
111110
FuncPtr(cl_adapter::cast<cl_context>(hContext), pIL, length, &Err));
111+
}
112+
113+
// INVALID_VALUE is only returned in three circumstances according to the cl
114+
// spec:
115+
// * pIL == NULL
116+
// * length == 0
117+
// * pIL is not a well-formed binary
118+
// UR has a unique error code for each of these, so here we figure out which
119+
// to return
120+
if (Err == CL_INVALID_VALUE) {
121+
if (pIL == nullptr) {
122+
return UR_RESULT_ERROR_INVALID_NULL_POINTER;
123+
}
124+
if (length == 0) {
125+
return UR_RESULT_ERROR_INVALID_SIZE;
126+
}
127+
return UR_RESULT_ERROR_INVALID_BINARY;
128+
} else {
112129
CL_RETURN_ON_FAILURE(Err);
113130
}
114131

test/conformance/program/program_adapter_opencl.match

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)