From 94dca7073bf632fead2ffb5bc8e2eb12d110623c Mon Sep 17 00:00:00 2001 From: "Kanangot Balakrishnan, Bindhiya" Date: Tue, 21 Jan 2025 15:46:56 -0600 Subject: [PATCH] [SWDEV-481004] Fix for incorrect gfx_version number (#8) The target_graphics_version was not formatted properly and was showing incorrect Target Name. Corrected this by fomatting major, minor and revision numbers. Signed-off-by: Bindhiya Kanangot Balakrishnan --- CHANGELOG.md | 2 ++ python_smi_tools/rocm_smi.py | 5 +---- src/rocm_smi.cc | 2 +- src/rocm_smi_utils.cc | 10 ++++++---- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac8af3f..5e31a58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,8 @@ $ rocm-smi --showmetrics ### Resolved issues +- **Fixed `rsmi_dev_target_graphics_version_get`, `rocm-smi --showhw`, and `rocm-smi --showprod` not displaying graphics version properly for MI2x, MI1x or Navi 3x ASICs.** + ### Upcoming changes ## rocm_smi_lib for ROCm 6.3 diff --git a/python_smi_tools/rocm_smi.py b/python_smi_tools/rocm_smi.py index c9ca318..70809e6 100755 --- a/python_smi_tools/rocm_smi.py +++ b/python_smi_tools/rocm_smi.py @@ -397,11 +397,8 @@ def getTargetGfxVersion(device, silent=False): target_graphics_version = c_uint64() gfx_ver_ret = "N/A" ret = rocmsmi.rsmi_dev_target_graphics_version_get(device, byref(target_graphics_version)) - target_graphics_version = str(target_graphics_version.value) + target_graphics_version = hex(target_graphics_version.value)[2:] if rsmi_ret_ok(ret, device, 'get_target_gfx_version', silent=silent): - if target_graphics_version == "9010": - hex_part = str(hex(int(str(target_graphics_version)[2:]))).replace("0x", "") - target_graphics_version = str(target_graphics_version)[:2] + hex_part gfx_ver_ret = "gfx" + str(target_graphics_version) return gfx_ver_ret diff --git a/src/rocm_smi.cc b/src/rocm_smi.cc index 63c90d4..831b13c 100755 --- a/src/rocm_smi.cc +++ b/src/rocm_smi.cc @@ -5365,7 +5365,7 @@ rsmi_status_t rsmi_dev_target_graphics_version_get(uint32_t dv_ind, } if (ret == RSMI_STATUS_SUCCESS) { version = amd::smi::removeString(version, "gfx"); - *gfx_version = std::stoull(version); + *gfx_version = uint64_t(std::stoull(version, nullptr, 16)); } ss << __PRETTY_FUNCTION__ << " | ======= end ======= " diff --git a/src/rocm_smi_utils.cc b/src/rocm_smi_utils.cc index ae5887e..0f7b09d 100755 --- a/src/rocm_smi_utils.cc +++ b/src/rocm_smi_utils.cc @@ -1193,11 +1193,13 @@ rsmi_status_t rsmi_get_gfx_target_version(uint32_t dv_ind, std::string *gfx_vers // separate out parts -> put back into normal graphics version format major = static_cast((orig_target_version / 10000) * 100); minor = static_cast((orig_target_version % 10000 / 100) * 10); - if ((minor == 0) && (countDigit(major) < 4)) { - major *= 10; // 0 as a minor is correct, but bump up by 10 - } rev = static_cast(orig_target_version % 100); - *gfx_version = "gfx" + std::to_string(major + minor + rev); + + ss << std::hex << rev; + std::string revision = ss.str(); + *gfx_version = "gfx" + std::to_string((major + minor)/10) + revision; + + ss.str(""); ss << __PRETTY_FUNCTION__ << " | " << std::dec << "kfd_target_version = " << orig_target_version << "; major = " << major << "; minor = " << minor << "; rev = "