From d2bf77401eea5ad13a8aedc96df3bb0751b486a2 Mon Sep 17 00:00:00 2001 From: "Narlo, Joseph" Date: Wed, 28 May 2025 18:26:58 -0500 Subject: [PATCH] [SWDEV-532129] Update amdsmi asic info (#369) * Added `subsystem_id` to `amdsmi_get_gpu_asic_info` --------- Signed-off-by: Narlo, Joseph [ROCm/amdsmi commit: 9862db63dd57f045c156b6eb3da1ee62d8d23cdd] --- projects/amdsmi/CHANGELOG.md | 2 ++ projects/amdsmi/amdsmi_cli/amdsmi_commands.py | 6 ------ projects/amdsmi/docs/reference/amdsmi-py-api.md | 1 + projects/amdsmi/example/amd_smi_drm_example.cc | 1 + projects/amdsmi/example/amd_smi_nodrm_example.cc | 1 + projects/amdsmi/include/amd_smi/amdsmi.h | 9 +++++---- projects/amdsmi/py-interface/amdsmi_interface.py | 5 +++-- projects/amdsmi/py-interface/amdsmi_wrapper.py | 3 ++- projects/amdsmi/rust-interface/src/amdsmi_wrapper.rs | 7 +++++-- projects/amdsmi/src/amd_smi/amd_smi.cc | 5 +++++ projects/amdsmi/tests/python_unittest/README.md | 1 + .../amdsmi/tests/python_unittest/integration_test.py | 2 ++ 12 files changed, 28 insertions(+), 15 deletions(-) diff --git a/projects/amdsmi/CHANGELOG.md b/projects/amdsmi/CHANGELOG.md index 6a7861ed7c..abd9e577bd 100644 --- a/projects/amdsmi/CHANGELOG.md +++ b/projects/amdsmi/CHANGELOG.md @@ -12,6 +12,8 @@ Full documentation for amd_smi_lib is available at [https://rocm.docs.amd.com/pr ### Changed +- **Updated `amdsmi_get_gpu_asic_info` in `amdsmi.h`.** + - Added `subsystem_id` structure member. - **Removed `amdsmi_io_link_type_t` and replaced with amdsmi_link_type_t**. - The IO Link type is no longer needed as the link type is sufficient. diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py index 1a3538ef1a..a3f13721ce 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py @@ -483,12 +483,6 @@ class AMDSMICommands(): except amdsmi_exception.AmdSmiLibraryException as e: logging.debug("Failed to get asic info for gpu %s | %s", gpu_id, e.get_error_info()) - try: - subsystem_id = amdsmi_interface.amdsmi_get_gpu_subsystem_id(args.gpu) - asic_dict["subsystem_id"] = subsystem_id - except amdsmi_exception.AmdSmiLibraryException as e: - logging.debug("Failed to get asic info for gpu %s | %s", gpu_id, e.get_error_info()) - static_dict['asic'] = asic_dict if args.bus: bus_info = { diff --git a/projects/amdsmi/docs/reference/amdsmi-py-api.md b/projects/amdsmi/docs/reference/amdsmi-py-api.md index 8051616fd2..d9ced5144f 100644 --- a/projects/amdsmi/docs/reference/amdsmi-py-api.md +++ b/projects/amdsmi/docs/reference/amdsmi-py-api.md @@ -366,6 +366,7 @@ Field | Content `oam_id` | oam id `num_of_compute_units` | number of compute units on asic `target_graphics_version` | hardware graphics version +`subsystem_id` | subsystem id Exceptions that can be thrown by `amdsmi_get_gpu_asic_info` function: diff --git a/projects/amdsmi/example/amd_smi_drm_example.cc b/projects/amdsmi/example/amd_smi_drm_example.cc index 9ad936fcb9..6698e6c799 100644 --- a/projects/amdsmi/example/amd_smi_drm_example.cc +++ b/projects/amdsmi/example/amd_smi_drm_example.cc @@ -380,6 +380,7 @@ int main() { printf("\tDeviceID: 0x%lx\n", asic_info.device_id); printf("\tVendorID: 0x%x\n", asic_info.vendor_id); printf("\tRevisionID: 0x%x\n", asic_info.rev_id); + printf("\tSubSystemID: 0x%x\n", asic_info.subsystem_id); printf("\tAsic serial: 0x%s\n", asic_info.asic_serial); printf("\tNum of Computes: %d\n\n", asic_info.num_of_compute_units); diff --git a/projects/amdsmi/example/amd_smi_nodrm_example.cc b/projects/amdsmi/example/amd_smi_nodrm_example.cc index b42c8fd94c..f952f78d09 100644 --- a/projects/amdsmi/example/amd_smi_nodrm_example.cc +++ b/projects/amdsmi/example/amd_smi_nodrm_example.cc @@ -129,6 +129,7 @@ int main() { printf("\tDeviceID: 0x%lx\n", asic_info.device_id); printf("\tVendorID: 0x%x\n", asic_info.vendor_id); printf("\tRevisionID: 0x%x\n", asic_info.rev_id); + printf("\tSubSystemID: 0x%x\n", asic_info.subsystem_id); printf("\tAsic serial: 0x%s\n", asic_info.asic_serial); printf("\tOAM id: 0x%x\n", asic_info.oam_id); printf("\tNum of Computes: %d\n\n", asic_info.num_of_compute_units); diff --git a/projects/amdsmi/include/amd_smi/amdsmi.h b/projects/amdsmi/include/amd_smi/amdsmi.h index 829fd1cc5f..94b363d42e 100644 --- a/projects/amdsmi/include/amd_smi/amdsmi.h +++ b/projects/amdsmi/include/amd_smi/amdsmi.h @@ -814,14 +814,15 @@ typedef struct { char market_name[AMDSMI_MAX_STRING_LENGTH]; uint32_t vendor_id; //!< Use 32 bit to be compatible with other platform. char vendor_name[AMDSMI_MAX_STRING_LENGTH]; - uint32_t subvendor_id; //!< The subsystem vendor id - uint64_t device_id; //!< The device id of a GPU - uint32_t rev_id; + uint32_t subvendor_id; //!< The subsystem vendor ID + uint64_t device_id; //!< The device ID of a GPU + uint32_t rev_id; //!< The revision ID of a GPU char asic_serial[AMDSMI_MAX_STRING_LENGTH]; uint32_t oam_id; //!< 0xFFFF if not supported uint32_t num_of_compute_units; //!< 0xFFFFFFFF if not supported uint64_t target_graphics_version; //!< 0xFFFFFFFFFFFFFFFF if not supported - uint32_t reserved[22]; + uint32_t subsystem_id; //!> The subsystem ID + uint32_t reserved[21]; } amdsmi_asic_info_t; diff --git a/projects/amdsmi/py-interface/amdsmi_interface.py b/projects/amdsmi/py-interface/amdsmi_interface.py index db7375ad5b..207ca2e3dd 100644 --- a/projects/amdsmi/py-interface/amdsmi_interface.py +++ b/projects/amdsmi/py-interface/amdsmi_interface.py @@ -1895,7 +1895,8 @@ def amdsmi_get_gpu_asic_info( "asic_serial": asic_info_struct.asic_serial.decode("utf-8"), "oam_id": asic_info_struct.oam_id, "num_compute_units": asic_info_struct.num_of_compute_units, - "target_graphics_version": "gfx" + target_graphics_version + "target_graphics_version": "gfx" + target_graphics_version, + "subsystem_id": asic_info_struct.subsystem_id } string_values = ["market_name", "vendor_name"] @@ -1903,7 +1904,7 @@ def amdsmi_get_gpu_asic_info( if not asic_info[value]: asic_info[value] = "N/A" - hex_values = ["vendor_id", "subvendor_id", "device_id"] + hex_values = ["vendor_id", "subvendor_id", "device_id", "subsystem_id"] for value in hex_values: if asic_info[value]: asic_info[value] = hex(asic_info[value]) diff --git a/projects/amdsmi/py-interface/amdsmi_wrapper.py b/projects/amdsmi/py-interface/amdsmi_wrapper.py index a71a0ae290..1fa4238d72 100644 --- a/projects/amdsmi/py-interface/amdsmi_wrapper.py +++ b/projects/amdsmi/py-interface/amdsmi_wrapper.py @@ -994,7 +994,8 @@ struct_amdsmi_asic_info_t._fields_ = [ ('num_of_compute_units', ctypes.c_uint32), ('PADDING_0', ctypes.c_ubyte * 4), ('target_graphics_version', ctypes.c_uint64), - ('reserved', ctypes.c_uint32 * 22), + ('subsystem_id', ctypes.c_uint32), + ('reserved', ctypes.c_uint32 * 21), ] amdsmi_asic_info_t = struct_amdsmi_asic_info_t diff --git a/projects/amdsmi/rust-interface/src/amdsmi_wrapper.rs b/projects/amdsmi/rust-interface/src/amdsmi_wrapper.rs index 095f76c950..64ad2f4b5f 100644 --- a/projects/amdsmi/rust-interface/src/amdsmi_wrapper.rs +++ b/projects/amdsmi/rust-interface/src/amdsmi_wrapper.rs @@ -919,7 +919,8 @@ pub struct AmdsmiAsicInfoT { pub oam_id: u32, pub num_of_compute_units: u32, pub target_graphics_version: u64, - pub reserved: [u32; 22usize], + pub subsystem_id: u32, + pub reserved: [u32; 21usize], } #[allow(clippy::unnecessary_operation, clippy::identity_op)] const _: () = { @@ -945,8 +946,10 @@ const _: () = { [::std::mem::offset_of!(AmdsmiAsicInfoT, num_of_compute_units) - 792usize]; ["Offset of field: AmdsmiAsicInfoT::target_graphics_version"] [::std::mem::offset_of!(AmdsmiAsicInfoT, target_graphics_version) - 800usize]; + ["Offset of field: AmdsmiAsicInfoT::subsystem_id"] + [::std::mem::offset_of!(AmdsmiAsicInfoT, subsystem_id) - 808usize]; ["Offset of field: AmdsmiAsicInfoT::reserved"] - [::std::mem::offset_of!(AmdsmiAsicInfoT, reserved) - 808usize]; + [::std::mem::offset_of!(AmdsmiAsicInfoT, reserved) - 812usize]; }; #[repr(C)] #[derive(Debug, Copy, Clone)] diff --git a/projects/amdsmi/src/amd_smi/amd_smi.cc b/projects/amdsmi/src/amd_smi/amd_smi.cc index 1b618a8217..f70d06a6ff 100644 --- a/projects/amdsmi/src/amd_smi/amd_smi.cc +++ b/projects/amdsmi/src/amd_smi/amd_smi.cc @@ -1431,6 +1431,7 @@ amdsmi_get_gpu_asic_info(amdsmi_processor_handle processor_handle, amdsmi_asic_i uint16_t vendor_id = 0; uint16_t subvendor_id = 0; uint16_t device_id = 0; + uint16_t subsystem_id = 0; std::ostringstream ss; amd::smi::AMDSmiGPUDevice* gpu_device = nullptr; @@ -1543,6 +1544,10 @@ amdsmi_get_gpu_asic_info(amdsmi_processor_handle processor_handle, amdsmi_asic_i &subvendor_id); if (status == AMDSMI_STATUS_SUCCESS) info->subvendor_id = subvendor_id; + status = rsmi_wrapper(rsmi_dev_subsystem_id_get, processor_handle, 0, + &subsystem_id); + if (status == AMDSMI_STATUS_SUCCESS) info->subsystem_id = subsystem_id; + status = rsmi_wrapper(rsmi_dev_pcie_vendor_name_get, processor_handle, 0, info->vendor_name, AMDSMI_MAX_STRING_LENGTH); diff --git a/projects/amdsmi/tests/python_unittest/README.md b/projects/amdsmi/tests/python_unittest/README.md index c3095101ba..948426323e 100644 --- a/projects/amdsmi/tests/python_unittest/README.md +++ b/projects/amdsmi/tests/python_unittest/README.md @@ -501,6 +501,7 @@ test_walkthrough (__main__.TestAmdSmiPythonInterface) ... asic_info['vendor_name'] is: Advanced Micro Devices Inc. [AMD/ATI] asic_info['device_id'] is: 0x73bf asic_info['rev_id'] is: 0xc1 + asic_info['subsystem_id'] is: 0xc34 asic_info['asic_serial'] is: 0xF8FFEB47A027DE4D asic_info['oam_id'] is: N/A asic_info['target_graphics_version'] is: gfx1030 diff --git a/projects/amdsmi/tests/python_unittest/integration_test.py b/projects/amdsmi/tests/python_unittest/integration_test.py index df76239b59..e34cc1247b 100755 --- a/projects/amdsmi/tests/python_unittest/integration_test.py +++ b/projects/amdsmi/tests/python_unittest/integration_test.py @@ -102,6 +102,8 @@ class TestAmdSmiPythonInterface(unittest.TestCase): asic_info['device_id'])) print(" asic_info['rev_id'] is: {}".format( asic_info['rev_id'])) + print(" asic_info['subsystem_id'] is: {}".format( + asic_info['subsystem_id'])) print(" asic_info['asic_serial'] is: {}".format( asic_info['asic_serial'])) print(" asic_info['oam_id'] is: {}".format(