From 5337da25734a2b32da58c28bcb8fcaa9560cdf92 Mon Sep 17 00:00:00 2001 From: gabrpham Date: Mon, 11 Nov 2024 18:34:19 -0600 Subject: [PATCH] Documented and adjusted python apis for pm metrics and reg table info * amdsmi_get_gpu_pm_metrics_info and amdsmi_get_gpu_reg_table_info were added to python api documentation * AmdSmiRegType added as enum * amdsmi_get_gpu_reg_table_info reg_type changed to AmdSmiRegType Signed-off-by: gabrpham Change-Id: I57239ecf048e82226151db071e8d9299e9182647 [ROCm/amdsmi commit: 4d26db84ca16dc57828444fc9d119e14185f6713] --- .../amdsmi/docs/reference/amdsmi-py-api.md | 72 +++++++++++++++++++ .../amdsmi/py-interface/amdsmi_interface.py | 10 ++- 2 files changed, 81 insertions(+), 1 deletion(-) diff --git a/projects/amdsmi/docs/reference/amdsmi-py-api.md b/projects/amdsmi/docs/reference/amdsmi-py-api.md index 80f5068714..f30b2e5bb0 100644 --- a/projects/amdsmi/docs/reference/amdsmi-py-api.md +++ b/projects/amdsmi/docs/reference/amdsmi-py-api.md @@ -2344,6 +2344,78 @@ except AmdSmiException as e: print(e) ``` +### amdsmi_get_gpu_pm_metrics_info + +Description: This function will retreive the name and value for each +item in the pm metrics table with the given processor handle. + +Input parameters: + +* `processor_handle` handle for the given device + +Output: List containing dictionaries of pm metrics and their values + +Field | Description +---|--- +`name` | name of PM metric +`value` | value of pm metric + +Exceptions that can be thrown by `amdsmi_get_gpu_pm_metrics_info` function: + +* `AmdSmiLibraryException` +* `AmdSmiRetryException` +* `AmdSmiParameterException` + +Example: + +```python +try: + devices = amdsmi_get_processor_handles() + if len(devices) == 0: + print("No GPUs on machine") + else: + for device in devices: + print(amdsmi_get_gpu_pm_metrics_info(device)) +except AmdSmiException as e: + print(e) +``` + +### amdsmi_get_gpu_reg_table_info + +Description: This function will retrieve register metrics table with provided device index and register type. + +Input parameters: + +* `processor_handle` handle for the given device +* `reg_type` register type + +Output: List containing dictionaries of register metrics and their values + +Field | Description +---|--- +`name` | name of register metric +`value` | value of register metric + +Exceptions that can be thrown by `amdsmi_get_gpu_reg_table_info` function: + +* `AmdSmiLibraryException` +* `AmdSmiRetryException` +* `AmdSmiParameterException` + +Example: + +```python +try: + devices = amdsmi_get_processor_handles() + if len(devices) == 0: + print("No GPUs on machine") + else: + for device in devices: + print(amdsmi_get_gpu_reg_table_info(device, AmdSmiRegType.USR1)) +except AmdSmiException as e: + print(e) +``` + ### amdsmi_get_gpu_od_volt_curve_regions Description: This function will retrieve the current valid regions in the diff --git a/projects/amdsmi/py-interface/amdsmi_interface.py b/projects/amdsmi/py-interface/amdsmi_interface.py index 04fed27bdf..0e37faee0c 100644 --- a/projects/amdsmi/py-interface/amdsmi_interface.py +++ b/projects/amdsmi/py-interface/amdsmi_interface.py @@ -412,6 +412,14 @@ class AmdSmiProcessorType(IntEnum): AMDSMI_PROCESSOR_TYPE_NON_AMD_CPU = amdsmi_wrapper.AMDSMI_PROCESSOR_TYPE_NON_AMD_CPU +class AmdSmiRegType(IntEnum): + XGMI = amdsmi_wrapper.AMDSMI_REG_XGMI + WAFL = amdsmi_wrapper.AMDSMI_REG_WAFL + PCIE = amdsmi_wrapper.AMDSMI_REG_PCIE + USR = amdsmi_wrapper.AMDSMI_REG_USR + USR1 = amdsmi_wrapper.AMDSMI_REG_USR1 + + class AmdSmiEventReader: def __init__( self, processor_handle: amdsmi_wrapper.amdsmi_processor_handle, @@ -1767,7 +1775,7 @@ def amdsmi_get_gpu_pm_metrics_info( def amdsmi_get_gpu_reg_table_info( processor_handle: amdsmi_wrapper.amdsmi_processor_handle, - reg_type: amdsmi_wrapper.amdsmi_reg_type_t, + reg_type: AmdSmiRegType, ) -> Dict[str, Any]: if not isinstance(processor_handle, amdsmi_wrapper.amdsmi_processor_handle): raise AmdSmiParameterException(