diff --git a/include/ur_api.h b/include/ur_api.h index 082890e73d..a707d40a3f 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -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 diff --git a/scripts/core/device.yml b/scripts/core/device.yml index 23c0233ef7..c063466b22 100644 --- a/scripts/core/device.yml +++ b/scripts/core/device.yml @@ -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" - name: USM_HOST_SUPPORT desc: "[$x_device_usm_access_capability_flags_t] support USM host memory access" - name: USM_DEVICE_SUPPORT diff --git a/source/adapters/opencl/device.cpp b/source/adapters/opencl/device.cpp index a31d6580a0..071a3a7c5a 100644 --- a/source/adapters/opencl/device.cpp +++ b/source/adapters/opencl/device.cpp @@ -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) */ @@ -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(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(hDevice), + {"cl_intel_unified_shared_memory"}, Supported)); + if (Supported) { + cl_bitfield CLValue = 0; + CL_RETURN_ON_FAILURE( + clGetDeviceInfo(cl_adapter::cast(hDevice), CLPropName, + sizeof(cl_bitfield), &CLValue, nullptr)); + return ReturnValue(static_cast(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: @@ -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 | @@ -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(hDevice), + {"cl_intel_device_attribute_query"}, Supported)); + if (!Supported) { + return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION; + } + CL_RETURN_ON_FAILURE( + clGetDeviceInfo(cl_adapter::cast(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(hDevice), + {"cl_intel_required_subgroup_size"}, + isExtensionSupported) != UR_RESULT_SUCCESS || + !isExtensionSupported) { + std::vector aThreadIsItsOwnSubGroup({1}); + return ReturnValue(aThreadIsItsOwnSubGroup.data(), + aThreadIsItsOwnSubGroup.size()); + } + // Have to convert size_t to uint32_t size_t SubGroupSizesSize = 0; CL_RETURN_ON_FAILURE(