Skip to content

Commit 5e51373

Browse files
committed
[CL] Handle INTERMEDIATE binary type
If an OpenCL driver returns `CL_PROGRAM_BINARY_TYPE_INTERMEDIATE` (defined in the `cl_khr_spir` extension to enable SPIR 1.2 not SPIR-V) when querying `CL_PROGRAM_BINARY_TYPE` we should handle this gracefully. This patch maps the `CL_PROGRAM_BINARY_TYPE_INTERMEDIATE` to `UR_PROGRAM_BINARY_TYPE_NONE`. From the users perspective these are semantically equivalent as they both require compilation before the program can be used to create a kernel.
1 parent 8a81c82 commit 5e51373

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

source/adapters/opencl/program.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,15 @@ static cl_int mapURProgramBuildInfoToCL(ur_program_build_info_t URPropName) {
259259
static ur_program_binary_type_t
260260
mapCLBinaryTypeToUR(cl_program_binary_type binaryType) {
261261
switch (binaryType) {
262+
default:
263+
// If we don't understand what OpenCL gave us, return NONE.
264+
// TODO: Emit a warning to the user.
265+
[[fallthrough]];
266+
case CL_PROGRAM_BINARY_TYPE_INTERMEDIATE:
267+
// The INTERMEDIATE binary type is defined by the cl_khr_spir extension
268+
// which we shouldn't encounter but do. Semantically this binary type is
269+
// equivelent to NONE as they both require compilation.
270+
[[fallthrough]];
262271
case CL_PROGRAM_BINARY_TYPE_NONE:
263272
return UR_PROGRAM_BINARY_TYPE_NONE;
264273
case CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT:
@@ -267,8 +276,6 @@ mapCLBinaryTypeToUR(cl_program_binary_type binaryType) {
267276
return UR_PROGRAM_BINARY_TYPE_LIBRARY;
268277
case CL_PROGRAM_BINARY_TYPE_EXECUTABLE:
269278
return UR_PROGRAM_BINARY_TYPE_EXECUTABLE;
270-
default:
271-
return UR_PROGRAM_BINARY_TYPE_FORCE_UINT32;
272279
}
273280
}
274281

0 commit comments

Comments
 (0)