Skip to content

Commit

Permalink
[CL] Implement UR_DEVICE_INFO_UUID query
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
kbenzie committed Mar 13, 2024
1 parent 2e4089a commit 0e2b601
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions source/adapters/opencl/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "common.hpp"
#include "platform.hpp"

#include <array>
#include <cassert>

ur_result_t cl_adapter::getDeviceVersion(cl_device_id Dev,
Expand Down Expand Up @@ -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<cl_device_id>(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<uint8_t, CL_UUID_SIZE_KHR> UUID{};
CL_RETURN_ON_FAILURE(
clGetDeviceInfo(cl_adapter::cast<cl_device_id>(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.
Expand All @@ -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:
Expand Down

0 comments on commit 0e2b601

Please sign in to comment.