From 19cc4718c06d9022a34ea5cfcd0730aa02de5fdf Mon Sep 17 00:00:00 2001 From: gabrpham Date: Mon, 11 Nov 2024 19:17:28 -0600 Subject: [PATCH] Documented and adjusted APIs for asic info, vram info, and P2P topology Signed-off-by: gabrpham Change-Id: I7ac9a868148e29c92299b21540e057f64cb4123e --- docs/reference/amdsmi-py-api.md | 43 +++++++++++++++++++++++++++++++- py-interface/amdsmi_interface.py | 10 ++++---- 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/docs/reference/amdsmi-py-api.md b/docs/reference/amdsmi-py-api.md index f30b2e5bb0..e1e2bfa9ec 100644 --- a/docs/reference/amdsmi-py-api.md +++ b/docs/reference/amdsmi-py-api.md @@ -444,6 +444,7 @@ Field | Description `vram_type` | vram type `vram_vendor` | vram vendor `vram_size` | vram size in mb +`vram_bit_width` | vram bit width Exceptions that can be thrown by `amdsmi_get_gpu_vram_info` function: @@ -464,6 +465,7 @@ try: print(vram_info['vram_type']) print(vram_info['vram_vendor']) print(vram_info['vram_size']) + print(vram_info['vram_bit_width']) except AmdSmiException as e: print(e) ``` @@ -2411,7 +2413,7 @@ try: print("No GPUs on machine") else: for device in devices: - print(amdsmi_get_gpu_reg_table_info(device, AmdSmiRegType.USR1)) + print(amdsmi_get_gpu_reg_table_info(device, AmdSmiRegType.PCIE)) except AmdSmiException as e: print(e) ``` @@ -3627,6 +3629,45 @@ except AmdSmiException as e: print(e) ``` +### amdsmi_get_P2P_status + +Description: Retrieve the connection type and P2P capabilities between 2 GPUs + +Input parameters: + +* `processor_handle_src` the source device handle +* `processor_handle_dest` the destination device handle + +Output: Dictionary with fields: + +Fields | Description +---|--- +`type` | AmdSmiIoLinkType +`cap` |
Subfield Description
`is_iolink_coherent`1 == True; 0 == False; Uint_max = Undefined
`is_iolink_atomics_32bit`Supports 32bit atomics
`is_iolink_atomics_64bit`Supports 64bit atomics
`is_iolink_dma`Supports DMA
`is_iolink_bi_directional`Is the IOLink Bidirectional
+ +Exceptions that can be thrown by `amdsmi_get_P2P_status` function: + +* `AmdSmiLibraryException` +* `AmdSmiRetryException` +* `AmdSmiParameterException` + +Example: + +```python +try: + devices = amdsmi_get_processor_handles() + if len(devices) == 0: + print("No GPUs on machine") + else: + processor_handle_src = devices[0] + processor_handle_dest = devices[1] + link_type = amdsmi_get_P2P_status(processor_handle_src, processor_handle_dest) + print(link_type['type']) + print(link_type['caps']) +except AmdSmiException as e: + print(e) +``` + ### amdsmi_is_P2P_accessible Description: Return P2P availability status between 2 GPUs diff --git a/py-interface/amdsmi_interface.py b/py-interface/amdsmi_interface.py index 0e37faee0c..ec967ed426 100644 --- a/py-interface/amdsmi_interface.py +++ b/py-interface/amdsmi_interface.py @@ -1753,8 +1753,8 @@ def amdsmi_get_gpu_pm_metrics_info( processor_handle, amdsmi_wrapper.amdsmi_processor_handle ) - pm_metrics = ctypes.POINTER(struct_amdsmi_name_value_t); - num_mets = ctypes.c_uint32; + pm_metrics = ctypes.POINTER(amdsmi_wrapper.amdsmi_name_value_t) + num_mets = ctypes.c_uint32 _check_res( amdsmi_wrapper.amdsmi_get_gpu_pm_metrics_info( @@ -1782,8 +1782,8 @@ def amdsmi_get_gpu_reg_table_info( processor_handle, amdsmi_wrapper.amdsmi_processor_handle ) - reg_metrics = ctypes.POINTER(struct_amdsmi_name_value_t); - num_regs = ctypes.c_uint32; + reg_metrics = ctypes.POINTER(amdsmi_wrapper.amdsmi_name_value_t) + num_regs = ctypes.c_uint32 _check_res( amdsmi_wrapper.amdsmi_get_gpu_reg_table_info( @@ -1798,7 +1798,7 @@ def amdsmi_get_gpu_reg_table_info( 'value': reg_metrics[i].value } results.append(item) - amdsmi_wrapper.amdsmi_free_name_value_pairs(pm_metrics) + amdsmi_wrapper.amdsmi_free_name_value_pairs(reg_metrics) return results