diff --git a/projects/amdsmi/python_smi_tools/rocm_smi.py b/projects/amdsmi/python_smi_tools/rocm_smi.py index 4df63c24b5..43309ef639 100755 --- a/projects/amdsmi/python_smi_tools/rocm_smi.py +++ b/projects/amdsmi/python_smi_tools/rocm_smi.py @@ -1897,7 +1897,8 @@ def showProductName(deviceList): ret = rocmsmi.rsmi_dev_subsystem_name_get(device, model, 256) if rsmi_ret_ok(ret, device) and model.value.decode(): device_model = model.value.decode() - printLog(device, 'Card model', '\t\t' + device_model) + # padHexValue is used for applications that expect 4-digit card models + printLog(device, 'Card model', '\t\t' + padHexValue(device_model, 4)) printLog(device, 'Card vendor', '\t\t' + device_vendor) # TODO: Retrieve the SKU using 'rsmi_dev_sku_get' from the LIB # ret = rocmsmi.rsmi_dev_sku_get(device, sku, 256) @@ -2543,6 +2544,20 @@ def load(savefilepath, autoRespond): printLogSpacer() +def padHexValue(value, length): + """ Pad a hexadecimal value with a given length of zeros + + @param value: A hexadecimal value to be padded with zeros + @param length: Number of zeros to pad the hexadecimal value + """ + # Ensure value entered meets the minimum length and is hexadecimal + if len(value) > 2 and length > 1 and value[:2].lower() == '0x' \ + and all(c in '0123456789abcdefABCDEF' for c in value[2:]): + # Pad with zeros after '0x' prefix + return '0x' + value[2:].zfill(length) + return value + + def profileString(profile): dictionary = {1: 'CUSTOM', 2:'VIDEO', 4:'POWER SAVING', 8:'COMPUTE', 16:'VR', 32:'3D FULL SCREEN', 64:'BOOTUP DEFAULT'} # TODO: We should dynamically generate this to avoid hardcoding