Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CL] Make device queries more robust #2032

Merged
merged 2 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions include/ur_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -1569,8 +1569,7 @@ typedef enum ur_device_info_t {
///< ::urDevicePartition
UR_DEVICE_INFO_MAX_NUM_SUB_GROUPS = 80, ///< [uint32_t] max number of sub groups
UR_DEVICE_INFO_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS = 81, ///< [::ur_bool_t] support sub group independent forward progress
UR_DEVICE_INFO_SUB_GROUP_SIZES_INTEL = 82, ///< [uint32_t[]] return an array of sub group sizes supported on Intel
///< device
UR_DEVICE_INFO_SUB_GROUP_SIZES_INTEL = 82, ///< [uint32_t[]] return an array of supported sub group sizes
UR_DEVICE_INFO_USM_HOST_SUPPORT = 83, ///< [::ur_device_usm_access_capability_flags_t] support USM host memory
///< access
UR_DEVICE_INFO_USM_DEVICE_SUPPORT = 84, ///< [::ur_device_usm_access_capability_flags_t] support USM device memory
Expand Down
2 changes: 1 addition & 1 deletion scripts/core/device.yml
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ etors:
- name: SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS
desc: "[$x_bool_t] support sub group independent forward progress"
- name: SUB_GROUP_SIZES_INTEL
desc: "[uint32_t[]] return an array of sub group sizes supported on Intel device"
desc: "[uint32_t[]] return an array of supported sub group sizes"
kbenzie marked this conversation as resolved.
Show resolved Hide resolved
- name: USM_HOST_SUPPORT
desc: "[$x_device_usm_access_capability_flags_t] support USM host memory access"
- name: USM_DEVICE_SUPPORT
Expand Down
57 changes: 49 additions & 8 deletions source/adapters/opencl/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -825,12 +825,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
case UR_DEVICE_INFO_GLOBAL_MEM_CACHE_TYPE:
case UR_DEVICE_INFO_LOCAL_MEM_TYPE:
case UR_DEVICE_INFO_EXECUTION_CAPABILITIES:
case UR_DEVICE_INFO_PARTITION_AFFINITY_DOMAIN:
case UR_DEVICE_INFO_USM_HOST_SUPPORT:
case UR_DEVICE_INFO_USM_DEVICE_SUPPORT:
case UR_DEVICE_INFO_USM_SINGLE_SHARED_SUPPORT:
case UR_DEVICE_INFO_USM_CROSS_SHARED_SUPPORT:
case UR_DEVICE_INFO_USM_SYSTEM_SHARED_SUPPORT: {
case UR_DEVICE_INFO_PARTITION_AFFINITY_DOMAIN: {
/* CL type: cl_bitfield / enum
* UR type: ur_flags_t (uint32_t) */

Expand All @@ -844,6 +839,27 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
* types are uint32_t */
return ReturnValue(static_cast<uint32_t>(CLValue));
}
case UR_DEVICE_INFO_USM_HOST_SUPPORT:
case UR_DEVICE_INFO_USM_DEVICE_SUPPORT:
case UR_DEVICE_INFO_USM_SINGLE_SHARED_SUPPORT:
case UR_DEVICE_INFO_USM_CROSS_SHARED_SUPPORT:
case UR_DEVICE_INFO_USM_SYSTEM_SHARED_SUPPORT: {
/* CL type: cl_bitfield / enum
* UR type: ur_flags_t (uint32_t) */
bool Supported = false;
UR_RETURN_ON_FAILURE(cl_adapter::checkDeviceExtensions(
cl_adapter::cast<cl_device_id>(hDevice),
{"cl_intel_unified_shared_memory"}, Supported));
if (Supported) {
cl_bitfield CLValue = 0;
CL_RETURN_ON_FAILURE(
clGetDeviceInfo(cl_adapter::cast<cl_device_id>(hDevice), CLPropName,
sizeof(cl_bitfield), &CLValue, nullptr));
return ReturnValue(static_cast<uint32_t>(CLValue));
} else {
return ReturnValue(0);
}
}
case UR_DEVICE_INFO_IMAGE_SUPPORTED:
case UR_DEVICE_INFO_ERROR_CORRECTION_SUPPORT:
case UR_DEVICE_INFO_HOST_UNIFIED_MEMORY:
Expand Down Expand Up @@ -918,8 +934,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
case UR_DEVICE_INFO_VERSION:
case UR_EXT_DEVICE_INFO_OPENCL_C_VERSION:
case UR_DEVICE_INFO_BUILT_IN_KERNELS:
case UR_DEVICE_INFO_MAX_WORK_ITEM_SIZES:
case UR_DEVICE_INFO_IP_VERSION: {
case UR_DEVICE_INFO_MAX_WORK_ITEM_SIZES: {
/* We can just use the OpenCL outputs because the sizes of OpenCL types
* are the same as UR.
* | CL | UR | Size |
Expand All @@ -937,7 +952,33 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,

return UR_RESULT_SUCCESS;
}
case UR_DEVICE_INFO_IP_VERSION: {
bool Supported;
UR_RETURN_ON_FAILURE(cl_adapter::checkDeviceExtensions(
cl_adapter::cast<cl_device_id>(hDevice),
{"cl_intel_device_attribute_query"}, Supported));
if (!Supported) {
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
}
CL_RETURN_ON_FAILURE(
clGetDeviceInfo(cl_adapter::cast<cl_device_id>(hDevice), CLPropName,
propSize, pPropValue, pPropSizeRet));

return UR_RESULT_SUCCESS;
}

case UR_DEVICE_INFO_SUB_GROUP_SIZES_INTEL: {
bool isExtensionSupported;
if (cl_adapter::checkDeviceExtensions(
cl_adapter::cast<cl_device_id>(hDevice),
{"cl_intel_required_subgroup_size"},
isExtensionSupported) != UR_RESULT_SUCCESS ||
!isExtensionSupported) {
std::vector<uint32_t> aThreadIsItsOwnSubGroup({1});
return ReturnValue(aThreadIsItsOwnSubGroup.data(),
aThreadIsItsOwnSubGroup.size());
}

// Have to convert size_t to uint32_t
size_t SubGroupSizesSize = 0;
CL_RETURN_ON_FAILURE(
Expand Down
Loading