[SWDEV-531904] Added test_get_gpu_revision (#533)

* [SWDEV-531904] Added test_get_gpu_revision
New:
- amdsmi_get_gpu_revision() previously not implemented in amdsmi_interface.py
- test_get_gpu_revision() missing integration test.

Updated:
-changelog.md added new doc fields for ROCm 7.1
-amdsmi-py-api.md added field|description doc fields

Signed-off-by: Juan Castillo <juan.castillo@amd.com>
This commit is contained in:
Castillo, Juan
2025-07-15 19:35:54 -05:00
committed by GitHub
parent 03414e20ee
commit 3b1957e674
5 changed files with 107 additions and 0 deletions
+23
View File
@@ -4,6 +4,29 @@ Full documentation for amd_smi_lib is available at [https://rocm.docs.amd.com/pr
***All information listed below is for reference and subject to change.***
## amd_smi_lib for ROCm 7.1.0
### Added
- **Added `amdsmi_get_gpu_revision()` to Python API**
- This function retrieves the GPU revision ID. Available in `amdsmi_interface.py` as `amdsmi_get_gpu_revision()`.
### Changed
### Removed
### Optimized
### Resolved Issues
### Upcoming Changes
- N/A
### Known Issues
- N/A
## amd_smi_lib for ROCm 7.0.0
### Added
+36
View File
@@ -550,6 +550,42 @@ except AmdSmiException as e:
print(e)
```
### amdsmi_get_gpu_revision
Description: Returns the GPU revision for a given processor handle.
Input parameters:
* `processor_handle` device which to query
Output: string hex value
Field | Description
---|---
`revision` | 16 bit integer value returned as hex string.
Exceptions that can be thrown by `amdsmi_get_gpu_revision` function:
* `AmdSmiLibraryException` If the processor handle is invalid.
* `AmdSmiParameterException` If the underlying library call fails.
Example:
```python
try:
devices = amdsmi_get_processor_handles(handle)
if len(devices) == 0:
print("No GPUs on machine")
else:
for device in devices:
revision = amdsmi_get_gpu_revision(device)
print(revision)
except AmdSmiLibraryException as e:
print(e)
except AmdSmiParameterException as e:
print(e)
```
### amdsmi_get_gpu_cache_info
Description: Returns a list of dictionaries containing cache information for the given GPU.
+1
View File
@@ -117,6 +117,7 @@ from .amdsmi_interface import amdsmi_get_gpu_bad_page_info
from .amdsmi_interface import amdsmi_get_gpu_bad_page_threshold
from .amdsmi_interface import amdsmi_get_violation_status
from .amdsmi_interface import amdsmi_get_gpu_xgmi_link_status
from .amdsmi_interface import amdsmi_get_gpu_revision
# # Process Information
from .amdsmi_interface import amdsmi_get_gpu_process_list
+29
View File
@@ -5087,3 +5087,32 @@ def amdsmi_get_rocm_version()-> Tuple[bool, str]:
return False, "Could not find librocm-core.so"
except Exception as e:
return False, f"Unable to detect ROCm installation, Unknown Error: {e}"
def amdsmi_get_gpu_revision(processor_handle: processor_handle) -> str:
"""
Get the GPU revision for a given processor handle.
Parameters:
processor_handle (amdsmi_processor_handle): The processor handle for the GPU.
Returns:
str: The GPU revision as a string.
Raises:
AmdSmiParameterException: If the processor handle is invalid.
AmdSmiLibraryException: If the underlying library call fails.
"""
if not isinstance(processor_handle, amdsmi_wrapper.amdsmi_processor_handle):
raise AmdSmiParameterException(
processor_handle, amdsmi_wrapper.amdsmi_processor_handle
)
revision = ctypes.c_uint16()
_check_res(
amdsmi_wrapper.amdsmi_get_gpu_revision(
processor_handle, ctypes.byref(revision)
)
)
return _pad_hex_value(hex(revision.value), 2)
+18
View File
@@ -1244,6 +1244,24 @@ class TestAmdSmiPythonInterface(unittest.TestCase):
print()
self.tearDown()
def test_get_gpu_revision(self):
self.setUp()
processors = amdsmi.amdsmi_get_processor_handles()
self.assertGreaterEqual(len(processors), 1)
self.assertLessEqual(len(processors), self.max_num_physical_devices)
for i in range(0, len(processors)):
bdf = amdsmi.amdsmi_get_gpu_device_bdf(processors[i])
print(f"\n\n###Test Processor {i}, bdf: {bdf}")
try:
print("\n###Test amdsmi_get_gpu_revision \n")
revision = amdsmi.amdsmi_get_gpu_revision(processors[i])
except amdsmi.AmdSmiLibraryException as e:
self._check_exception(e)
continue
print(f" GPU revision is: {revision}")
print()
self.tearDown()
# Add test for amdsmi_get_gpu_pm_metrics_info
@handle_exceptions
def test_gpu_pm_metrics_info(self):