Skip to content

Commit

Permalink
{UR][L0] Return device version based on DeviceIpVersion
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ph0b committed Apr 4, 2024
1 parent b915354 commit 4a56e06
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions source/adapters/level_zero/device.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -338,8 +338,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) {
Expand Down

0 comments on commit 4a56e06

Please sign in to comment.