From 0e2b60114e00ed0acb01e5959c2f24c945bb6778 Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Tue, 23 Jan 2024 15:50:17 +0000 Subject: [PATCH] [CL] Implement UR_DEVICE_INFO_UUID query Check if the OpenCL device supports the `cl_khr_device_uuid` extension. If it is supported, use it to implement the `UR_DEVICE_INFO_UUID` query. Otherwise, continue to return `UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION`. --- source/adapters/opencl/device.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/source/adapters/opencl/device.cpp b/source/adapters/opencl/device.cpp index 115b9b2e09..04df54179a 100644 --- a/source/adapters/opencl/device.cpp +++ b/source/adapters/opencl/device.cpp @@ -10,6 +10,7 @@ #include "common.hpp" #include "platform.hpp" +#include #include ur_result_t cl_adapter::getDeviceVersion(cl_device_id Dev, @@ -923,6 +924,24 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, } return ReturnValue(SupportedExtensions.c_str()); } + + case UR_DEVICE_INFO_UUID: { + // Use the cl_khr_device_uuid extension, if available. + bool isKhrDeviceUuidSupported = false; + if (cl_adapter::checkDeviceExtensions( + cl_adapter::cast(hDevice), {"cl_khr_device_uuid"}, + isKhrDeviceUuidSupported) != UR_RESULT_SUCCESS || + !isKhrDeviceUuidSupported) { + return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION; + } + static_assert(CL_UUID_SIZE_KHR == 16); + std::array UUID{}; + CL_RETURN_ON_FAILURE( + clGetDeviceInfo(cl_adapter::cast(hDevice), + CL_DEVICE_UUID_KHR, UUID.size(), UUID.data(), nullptr)); + return ReturnValue(UUID); + } + case UR_DEVICE_INFO_COMPONENT_DEVICES: case UR_DEVICE_INFO_COMPOSITE_DEVICE: // These two are exclusive of L0. @@ -939,10 +958,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, case UR_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE: case UR_DEVICE_INFO_GPU_HW_THREADS_PER_EU: case UR_DEVICE_INFO_MAX_MEMORY_BANDWIDTH: - /* TODO: Check if device UUID extension is enabled in OpenCL. For details - * about Intel UUID extension, see - * sycl/doc/extensions/supported/sycl_ext_intel_device_info.md */ - case UR_DEVICE_INFO_UUID: /* This enums have no equivalent in OpenCL */ case UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP: case UR_DEVICE_INFO_GLOBAL_MEM_FREE: