Skip to content

Commit

Permalink
[SWDEV-481004] Fix for incorrect gfx_version number (#52)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
bkanango authored Jan 21, 2025
1 parent 9cc5c30 commit 6fa991c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,8 @@ GPU2 0000:46:00.0 32 Gb/s 512 Gb/s XGMI
### Resolved issues
- **Fixed `amdsmi_get_gpu_asic_info` and `amd-smi static --asic` not displaying graphics version properly for MI2x, MI1x or Navi 3x ASICs.**
### Upcoming changes
### Known issues
Expand Down
5 changes: 1 addition & 4 deletions py-interface/amdsmi_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -1674,10 +1674,7 @@ def amdsmi_get_gpu_asic_info(
)

market_name = _pad_hex_value(asic_info_struct.market_name.decode("utf-8"), 4)
target_graphics_version = str(asic_info_struct.target_graphics_version)
if target_graphics_version == "9010":
hex_part = str(hex(int(str(asic_info_struct.target_graphics_version)[2:]))).replace("0x", "")
target_graphics_version = str(asic_info_struct.target_graphics_version)[:2] + hex_part
target_graphics_version = hex(asic_info_struct.target_graphics_version)[2:]
asic_info = {
"market_name": market_name,
"vendor_id": asic_info_struct.vendor_id,
Expand Down
5 changes: 1 addition & 4 deletions rocm_smi/python_smi_tools/rocm_smi.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,11 +398,8 @@ def getTargetGfxVersion(device, silent=False):
market_name = str(getDeviceName(device, True))
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 len(target_graphics_version) == 4 and ("Instinct MI2" in market_name):
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

Expand Down
2 changes: 1 addition & 1 deletion rocm_smi/src/rocm_smi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6627,7 +6627,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 ======= "
Expand Down
10 changes: 6 additions & 4 deletions rocm_smi/src/rocm_smi_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1209,11 +1209,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<uint64_t>((orig_target_version / 10000) * 100);
minor = static_cast<uint64_t>((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<uint64_t>(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 = "
Expand Down

0 comments on commit 6fa991c

Please sign in to comment.