Skip to content

Commit fa8cc8e

Browse files
authored
Merge pull request #1833 from ayylol/old-opencl-check
[OpenCL] Add OpenCL version check for independent forward progress query
2 parents 3d58884 + 1984ceb commit fa8cc8e

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

source/adapters/opencl/device.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -887,8 +887,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
887887
case UR_DEVICE_INFO_AVAILABLE:
888888
case UR_DEVICE_INFO_COMPILER_AVAILABLE:
889889
case UR_DEVICE_INFO_LINKER_AVAILABLE:
890-
case UR_DEVICE_INFO_PREFERRED_INTEROP_USER_SYNC:
891-
case UR_DEVICE_INFO_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS: {
890+
case UR_DEVICE_INFO_PREFERRED_INTEROP_USER_SYNC: {
892891
/* CL type: cl_bool
893892
* UR type: ur_bool_t */
894893

@@ -900,6 +899,27 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
900899
/* cl_bool is uint32_t and ur_bool_t is bool */
901900
return ReturnValue(static_cast<ur_bool_t>(CLValue));
902901
}
902+
case UR_DEVICE_INFO_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS: {
903+
/* CL type: cl_bool
904+
* UR type: ur_bool_t */
905+
906+
oclv::OpenCLVersion DevVer;
907+
CL_RETURN_ON_FAILURE(cl_adapter::getDeviceVersion(
908+
cl_adapter::cast<cl_device_id>(hDevice), DevVer));
909+
/* Independent forward progress query is only supported as of OpenCL 2.1
910+
* if version is older we return a default false. */
911+
if (DevVer >= oclv::V2_1) {
912+
cl_bool CLValue;
913+
CL_RETURN_ON_FAILURE(
914+
clGetDeviceInfo(cl_adapter::cast<cl_device_id>(hDevice), CLPropName,
915+
sizeof(cl_bool), &CLValue, nullptr));
916+
917+
/* cl_bool is uint32_t and ur_bool_t is bool */
918+
return ReturnValue(static_cast<ur_bool_t>(CLValue));
919+
} else {
920+
return ReturnValue(false);
921+
}
922+
}
903923
case UR_DEVICE_INFO_VENDOR_ID:
904924
case UR_DEVICE_INFO_MAX_COMPUTE_UNITS:
905925
case UR_DEVICE_INFO_MAX_WORK_ITEM_DIMENSIONS:

0 commit comments

Comments
 (0)