Skip to content

Commit

Permalink
Merge pull request #1833 from ayylol/old-opencl-check
Browse files Browse the repository at this point in the history
[OpenCL] Add OpenCL version check for independent forward progress query
  • Loading branch information
aarongreig authored Nov 1, 2024
2 parents 3d58884 + 1984ceb commit fa8cc8e
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions source/adapters/opencl/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -887,8 +887,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
case UR_DEVICE_INFO_AVAILABLE:
case UR_DEVICE_INFO_COMPILER_AVAILABLE:
case UR_DEVICE_INFO_LINKER_AVAILABLE:
case UR_DEVICE_INFO_PREFERRED_INTEROP_USER_SYNC:
case UR_DEVICE_INFO_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS: {
case UR_DEVICE_INFO_PREFERRED_INTEROP_USER_SYNC: {
/* CL type: cl_bool
* UR type: ur_bool_t */

Expand All @@ -900,6 +899,27 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
/* cl_bool is uint32_t and ur_bool_t is bool */
return ReturnValue(static_cast<ur_bool_t>(CLValue));
}
case UR_DEVICE_INFO_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS: {
/* CL type: cl_bool
* UR type: ur_bool_t */

oclv::OpenCLVersion DevVer;
CL_RETURN_ON_FAILURE(cl_adapter::getDeviceVersion(
cl_adapter::cast<cl_device_id>(hDevice), DevVer));
/* Independent forward progress query is only supported as of OpenCL 2.1
* if version is older we return a default false. */
if (DevVer >= oclv::V2_1) {
cl_bool CLValue;
CL_RETURN_ON_FAILURE(
clGetDeviceInfo(cl_adapter::cast<cl_device_id>(hDevice), CLPropName,
sizeof(cl_bool), &CLValue, nullptr));

/* cl_bool is uint32_t and ur_bool_t is bool */
return ReturnValue(static_cast<ur_bool_t>(CLValue));
} else {
return ReturnValue(false);
}
}
case UR_DEVICE_INFO_VENDOR_ID:
case UR_DEVICE_INFO_MAX_COMPUTE_UNITS:
case UR_DEVICE_INFO_MAX_WORK_ITEM_DIMENSIONS:
Expand Down

0 comments on commit fa8cc8e

Please sign in to comment.