From 00edaab959c0386798a1963298b34bf31eaccf2c Mon Sep 17 00:00:00 2001 From: Xavier Hallade Date: Thu, 29 Feb 2024 20:38:50 +0100 Subject: [PATCH] {UR][L0] Return device version based on DeviceIpVersion When being queried a device version: - CUDA adapter returns the compute capability version of the device, - HIP adapter returns the architecture name. Both of these are what define a GPU architecture to compile binaries for and can be used with GPU compilers, this is useful information for applications and developers. On L0/Intel side, prior to this change, it returns the L0 API version. This information is already returned in BACKEND_RUNTIME_VERSION and DRIVER_VERSION queries. With this change, we align the adapters behavior with CUDA and HIP, and return the Intel device architecture version that can be used with ocloc compiler. --- source/adapters/level_zero/device.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/source/adapters/level_zero/device.cpp b/source/adapters/level_zero/device.cpp index 9ed752d46c..7f832f30f2 100644 --- a/source/adapters/level_zero/device.cpp +++ b/source/adapters/level_zero/device.cpp @@ -1,6 +1,6 @@ //===--------- device.cpp - Level Zero Adapter ----------------------------===// // -// Copyright (C) 2023 Intel Corporation +// Copyright (C) 2023-2024 Intel Corporation // // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM // Exceptions. See LICENSE.TXT @@ -337,8 +337,27 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( case UR_DEVICE_INFO_DRIVER_VERSION: case UR_DEVICE_INFO_BACKEND_RUNTIME_VERSION: return ReturnValue(Device->Platform->ZeDriverVersion.c_str()); - case UR_DEVICE_INFO_VERSION: - return ReturnValue(Device->Platform->ZeDriverApiVersion.c_str()); + case UR_DEVICE_INFO_VERSION: { + // from compute-runtime/shared/source/helpers/hw_ip_version.h + typedef struct { + uint32_t revision : 6; + uint32_t reserved : 8; + uint32_t release : 8; + uint32_t architecture : 10; + } version_components_t; + typedef struct { + union { + uint32_t value; + version_components_t components; + }; + } ipVersion_t; + ipVersion_t IpVersion; + IpVersion.value = Device->ZeDeviceIpVersionExt->ipVersion; + std::stringstream S; + S << IpVersion.components.architecture << "." + << IpVersion.components.release << "." << IpVersion.components.revision; + return ReturnValue(S.str().c_str()); + } case UR_DEVICE_INFO_PARTITION_MAX_SUB_DEVICES: { auto Res = Device->Platform->populateDeviceCacheIfNeeded(); if (Res != UR_RESULT_SUCCESS) {