From 77a46001c2716dd3c8214b8b0b67b2f8e1b67f66 Mon Sep 17 00:00:00 2001 From: "Galantsev, Dmitrii" Date: Wed, 13 Sep 2023 19:29:44 -0500 Subject: [PATCH 01/11] README - Add documentation links Change-Id: I048c159394286545d518176d2751a43934b7fe9d Signed-off-by: Galantsev, Dmitrii [ROCm/amdsmi commit: fe0b6e5f4cfa0c54ed411dea56ff2cb2adc3ddf7] --- projects/amdsmi/README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/projects/amdsmi/README.md b/projects/amdsmi/README.md index 7e8f878d4d..dd277cb414 100755 --- a/projects/amdsmi/README.md +++ b/projects/amdsmi/README.md @@ -2,11 +2,15 @@ The AMD System Management Interface Library, or AMD SMI library, is a C library for Linux that provides a user space interface for applications to monitor and control AMD devices. +For additional information refer to [ROCm Documentation](https://rocm.docs.amd.com/projects/amdsmi/en/latest/) + +Note: This project is a successor to [rocm_smi_lib](https://github.com/RadeonOpenCompute/rocm_smi_lib) + ## Supported platforms At initial release, the AMD SMI library will support Linux bare metal and Linux virtual machine guest for AMD GPUs. In the future release, the library will be extended to support AMD EPYC™ CPUs. -AMD SMI library can run on AMD ROCm supported platforms, please refer to [List of Supported Operating Systems and GPUs](https://docs.amd.com/bundle/ROCm-Getting-Started-Guide-v5.3/page/Introduction_to_ROCm_Getting_Started_Guide_for_Linux.html) +AMD SMI library can run on AMD ROCm supported platforms, please refer to [List of Supported Operating Systems and GPUs](https://rocm.docs.amd.com/en/latest/release/gpu_os_support.html) To run the AMD SMI library, the amdgpu driver needs to be installed. Optionally, the libdrm can be installed to query firmware information and hardware IPs. From 806adfa83c5b647ab9ea61d896883ef204ab3c8a Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Wed, 13 Sep 2023 09:45:33 -0500 Subject: [PATCH 02/11] SWDEV-412847 - Changed junction to hotspot Change-Id: I7f6c1a0a77e6a09d2a3e831463cf03e35266bf40 Signed-off-by: Maisam Arif [ROCm/amdsmi commit: d2ef113457a0a7454a05f02ed86af22c776cf219] --- projects/amdsmi/amdsmi_cli/amdsmi_commands.py | 28 +++++++++---------- .../amdsmi/example/amd_smi_drm_example.cc | 8 +++--- .../amdsmi/example/amd_smi_nodrm_example.cc | 6 ++-- projects/amdsmi/include/amd_smi/amdsmi.h | 3 +- .../amdsmi/py-interface/amdsmi_interface.py | 1 + .../amdsmi/py-interface/amdsmi_wrapper.py | 3 ++ .../amd_smi_test/functional/temp_read.cc | 1 + 7 files changed, 28 insertions(+), 22 deletions(-) diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py index 12b3fb4cd8..44fa5e77c9 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py @@ -312,12 +312,12 @@ class AMDSMICommands(): temp_edge_limit = 'N/A' try: - temp_junction_limit_error = False - temp_junction_limit = amdsmi_interface.amdsmi_get_temp_metric(args.gpu, - amdsmi_interface.AmdSmiTemperatureType.JUNCTION, amdsmi_interface.AmdSmiTemperatureMetric.CRITICAL) + temp_hotspot_limit_error = False + temp_hotspot_limit = amdsmi_interface.amdsmi_get_temp_metric(args.gpu, + amdsmi_interface.AmdSmiTemperatureType.HOTSPOT, amdsmi_interface.AmdSmiTemperatureMetric.CRITICAL) except amdsmi_exception.AmdSmiLibraryException as e: - temp_junction_limit_error = True - temp_junction_limit = e.get_error_info() + temp_hotspot_limit_error = True + temp_hotspot_limit = e.get_error_info() if not self.all_arguments: raise e @@ -339,16 +339,16 @@ class AMDSMICommands(): unit = '\N{DEGREE SIGN}C' if not temp_edge_limit_error: temp_edge_limit = f"{temp_edge_limit} {unit}" - if not temp_junction_limit_error: - temp_junction_limit = f"{temp_junction_limit} {unit}" + if not temp_hotspot_limit_error: + temp_hotspot_limit = f"{temp_hotspot_limit} {unit}" if not temp_vram_limit_error: temp_vram_limit = f"{temp_vram_limit} {unit}" limit_info = {} limit_info['power'] = power_limit - limit_info['temperature_edge'] = temp_edge_limit - limit_info['temperature_junction'] = temp_junction_limit - limit_info['temperature_vram'] = temp_vram_limit + limit_info['edge_temperature'] = temp_edge_limit + limit_info['hotspot_temperature'] = temp_hotspot_limit + limit_info['vram_temperature'] = temp_vram_limit static_dict['limit'] = limit_info if args.driver: @@ -879,8 +879,8 @@ class AMDSMICommands(): args.gpu, amdsmi_interface.AmdSmiTemperatureType.EDGE, amdsmi_interface.AmdSmiTemperatureMetric.CURRENT) temperature_edge_limit = amdsmi_interface.amdsmi_get_temp_metric( args.gpu, amdsmi_interface.AmdSmiTemperatureType.EDGE, amdsmi_interface.AmdSmiTemperatureMetric.CRITICAL) - temperature_junction_current = amdsmi_interface.amdsmi_get_temp_metric( - args.gpu, amdsmi_interface.AmdSmiTemperatureType.JUNCTION, amdsmi_interface.AmdSmiTemperatureMetric.CURRENT) + temperature_hotspot_current = amdsmi_interface.amdsmi_get_temp_metric( + args.gpu, amdsmi_interface.AmdSmiTemperatureType.HOTSPOT, amdsmi_interface.AmdSmiTemperatureMetric.CURRENT) temperature_vram_current = amdsmi_interface.amdsmi_get_temp_metric( args.gpu, amdsmi_interface.AmdSmiTemperatureType.VRAM, amdsmi_interface.AmdSmiTemperatureMetric.CURRENT) @@ -889,12 +889,12 @@ class AMDSMICommands(): temperature_edge_current = 'N/A' temperatures = {'edge': temperature_edge_current, - 'junction': temperature_junction_current, + 'hotspot': temperature_hotspot_current, 'mem': temperature_vram_current} if self.logger.is_gpuvsmi_compatibility(): temperatures = {'edge_temperature': temperature_edge_current, - 'junction_temperature': temperature_junction_current, + 'hotspot_temperature': temperature_hotspot_current, 'mem_temperature': temperature_vram_current} if self.logger.is_human_readable_format(): diff --git a/projects/amdsmi/example/amd_smi_drm_example.cc b/projects/amdsmi/example/amd_smi_drm_example.cc index 09e4b72eb3..09ae1144ee 100644 --- a/projects/amdsmi/example/amd_smi_drm_example.cc +++ b/projects/amdsmi/example/amd_smi_drm_example.cc @@ -409,11 +409,11 @@ int main() { printf("\tGPU GFX temp limit: %ld\n\n", temperature); // Get temperature measurements - // amdsmi_temperature_t edge_temp, junction_temp, vram_temp, + // amdsmi_temperature_t edge_temp, hotspot_temp, vram_temp, // plx_temp; int64_t temp_measurements[TEMPERATURE_TYPE__MAX + 1]; amdsmi_temperature_type_t temp_types[4] = { - TEMPERATURE_TYPE_EDGE, TEMPERATURE_TYPE_JUNCTION, + TEMPERATURE_TYPE_EDGE, TEMPERATURE_TYPE_HOTSPOT, TEMPERATURE_TYPE_VRAM, TEMPERATURE_TYPE_PLX}; for (const auto &temp_type : temp_types) { ret = amdsmi_get_temp_metric( @@ -425,8 +425,8 @@ int main() { printf(" Output of amdsmi_get_temp_metric:\n"); printf("\tGPU Edge temp measurement: %ld\n", temp_measurements[TEMPERATURE_TYPE_EDGE]); - printf("\tGPU Junction temp measurement: %ld\n", - temp_measurements[TEMPERATURE_TYPE_JUNCTION]); + printf("\tGPU Hotspot temp measurement: %ld\n", + temp_measurements[TEMPERATURE_TYPE_HOTSPOT]); printf("\tGPU VRAM temp measurement: %ld\n", temp_measurements[TEMPERATURE_TYPE_VRAM]); printf("\tGPU PLX temp measurement: %ld\n\n", diff --git a/projects/amdsmi/example/amd_smi_nodrm_example.cc b/projects/amdsmi/example/amd_smi_nodrm_example.cc index 2650beed8f..eaf1b688dc 100644 --- a/projects/amdsmi/example/amd_smi_nodrm_example.cc +++ b/projects/amdsmi/example/amd_smi_nodrm_example.cc @@ -227,7 +227,7 @@ int main() { // Get temperature measurements int64_t temp_measurements[TEMPERATURE_TYPE__MAX + 1]; amdsmi_temperature_type_t temp_types[4] = { - TEMPERATURE_TYPE_EDGE, TEMPERATURE_TYPE_JUNCTION, + TEMPERATURE_TYPE_EDGE, TEMPERATURE_TYPE_HOTSPOT, TEMPERATURE_TYPE_VRAM, TEMPERATURE_TYPE_PLX}; for (const auto &temp_type : temp_types) { ret = amdsmi_get_temp_metric( @@ -239,8 +239,8 @@ int main() { printf(" Output of amdsmi_get_temp_metric:\n"); printf("\tGPU Edge temp measurement: %ld\n", temp_measurements[TEMPERATURE_TYPE_EDGE]); - printf("\tGPU Junction temp measurement: %ld\n", - temp_measurements[TEMPERATURE_TYPE_JUNCTION]); + printf("\tGPU Hotspot temp measurement: %ld\n", + temp_measurements[TEMPERATURE_TYPE_HOTSPOT]); printf("\tGPU VRAM temp measurement: %ld\n", temp_measurements[TEMPERATURE_TYPE_VRAM]); printf("\tGPU PLX temp measurement: %ld\n\n", diff --git a/projects/amdsmi/include/amd_smi/amdsmi.h b/projects/amdsmi/include/amd_smi/amdsmi.h index 86251a4b6f..7732454495 100644 --- a/projects/amdsmi/include/amd_smi/amdsmi.h +++ b/projects/amdsmi/include/amd_smi/amdsmi.h @@ -226,7 +226,8 @@ typedef enum { typedef enum { TEMPERATURE_TYPE_EDGE, TEMPERATURE_TYPE_FIRST = TEMPERATURE_TYPE_EDGE, - TEMPERATURE_TYPE_JUNCTION, + TEMPERATURE_TYPE_HOTSPOT, + TEMPERATURE_TYPE_JUNCTION = TEMPERATURE_TYPE_HOTSPOT, TEMPERATURE_TYPE_VRAM, TEMPERATURE_TYPE_HBM_0, TEMPERATURE_TYPE_HBM_1, diff --git a/projects/amdsmi/py-interface/amdsmi_interface.py b/projects/amdsmi/py-interface/amdsmi_interface.py index c0e10a3404..46b3307f4a 100644 --- a/projects/amdsmi/py-interface/amdsmi_interface.py +++ b/projects/amdsmi/py-interface/amdsmi_interface.py @@ -153,6 +153,7 @@ class AmdSmiClkType(IntEnum): class AmdSmiTemperatureType(IntEnum): EDGE = amdsmi_wrapper.TEMPERATURE_TYPE_EDGE + HOTSPOT = amdsmi_wrapper.TEMPERATURE_TYPE_HOTSPOT JUNCTION = amdsmi_wrapper.TEMPERATURE_TYPE_JUNCTION VRAM = amdsmi_wrapper.TEMPERATURE_TYPE_VRAM HBM_0 = amdsmi_wrapper.TEMPERATURE_TYPE_HBM_0 diff --git a/projects/amdsmi/py-interface/amdsmi_wrapper.py b/projects/amdsmi/py-interface/amdsmi_wrapper.py index d2f9eefa92..bfb3c395bd 100644 --- a/projects/amdsmi/py-interface/amdsmi_wrapper.py +++ b/projects/amdsmi/py-interface/amdsmi_wrapper.py @@ -370,6 +370,7 @@ amdsmi_clk_type_t = ctypes.c_uint32 # enum amdsmi_temperature_type_t__enumvalues = { 0: 'TEMPERATURE_TYPE_EDGE', 0: 'TEMPERATURE_TYPE_FIRST', + 1: 'TEMPERATURE_TYPE_HOTSPOT', 1: 'TEMPERATURE_TYPE_JUNCTION', 2: 'TEMPERATURE_TYPE_VRAM', 3: 'TEMPERATURE_TYPE_HBM_0', @@ -381,6 +382,7 @@ amdsmi_temperature_type_t__enumvalues = { } TEMPERATURE_TYPE_EDGE = 0 TEMPERATURE_TYPE_FIRST = 0 +TEMPERATURE_TYPE_HOTSPOT = 1 TEMPERATURE_TYPE_JUNCTION = 1 TEMPERATURE_TYPE_VRAM = 2 TEMPERATURE_TYPE_HBM_0 = 3 @@ -1781,6 +1783,7 @@ __all__ = \ 'TEMPERATURE_TYPE_EDGE', 'TEMPERATURE_TYPE_FIRST', 'TEMPERATURE_TYPE_HBM_0', 'TEMPERATURE_TYPE_HBM_1', 'TEMPERATURE_TYPE_HBM_2', 'TEMPERATURE_TYPE_HBM_3', + 'TEMPERATURE_TYPE_HOTSPOT', 'TEMPERATURE_TYPE_JUNCTION', 'TEMPERATURE_TYPE_PLX', 'TEMPERATURE_TYPE_VRAM', 'TEMPERATURE_TYPE__MAX', 'UNKNOWN', 'amd_metrics_table_header_t', 'amdsmi_asic_info_t', diff --git a/projects/amdsmi/tests/amd_smi_test/functional/temp_read.cc b/projects/amdsmi/tests/amd_smi_test/functional/temp_read.cc index e9c337ac1b..e6aa1d88ca 100755 --- a/projects/amdsmi/tests/amd_smi_test/functional/temp_read.cc +++ b/projects/amdsmi/tests/amd_smi_test/functional/temp_read.cc @@ -58,6 +58,7 @@ static const std::map kTempSensorNameMap = { {TEMPERATURE_TYPE_VRAM, "Memory"}, + {TEMPERATURE_TYPE_HOTSPOT, "Hotspot"}, {TEMPERATURE_TYPE_JUNCTION, "Junction"}, {TEMPERATURE_TYPE_EDGE, "Edge"}, {TEMPERATURE_TYPE_HBM_0, "HBM_0"}, From 35d20bcb8091b6f47b75da06d4bb5636d1c02b5b Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Wed, 13 Sep 2023 16:16:33 -0500 Subject: [PATCH 03/11] Spell check bandwith to bandwidth Change-Id: Icfb3b2398fe0590dbab6e531c8ec1cdceebe658d Signed-off-by: Maisam Arif [ROCm/amdsmi commit: 42b030def34614345770e2123fe4f1f7f3b666a7] --- projects/amdsmi/amdsmi_cli/amdsmi_commands.py | 4 ++-- projects/amdsmi/include/amd_smi/amdsmi.h | 2 +- projects/amdsmi/py-interface/README.md | 10 +++++----- projects/amdsmi/py-interface/__init__.py | 2 +- projects/amdsmi/py-interface/amdsmi_interface.py | 4 ++-- projects/amdsmi/py-interface/amdsmi_wrapper.py | 8 ++++---- projects/amdsmi/src/amd_smi/amd_smi.cc | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py index 44fa5e77c9..d1d36b8be7 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py @@ -1479,8 +1479,8 @@ class AMDSMICommands(): src_gpu_link_type[dest_gpu_key] = e.get_error_info() try: - min_bw = amdsmi_interface.amdsmi_get_minmax_bandwith_between_processors(src_gpu, dest_gpu)['min_bandwidth'] - max_bw = amdsmi_interface.amdsmi_get_minmax_bandwith_between_processors(src_gpu, dest_gpu)['max_bandwidth'] + min_bw = amdsmi_interface.amdsmi_get_minmax_bandwidth_between_processors(src_gpu, dest_gpu)['min_bandwidth'] + max_bw = amdsmi_interface.amdsmi_get_minmax_bandwidth_between_processors(src_gpu, dest_gpu)['max_bandwidth'] src_gpu_link_type[dest_gpu_key] = f'{min_bw}-{max_bw}' except amdsmi_exception.AmdSmiLibraryException as e: diff --git a/projects/amdsmi/include/amd_smi/amdsmi.h b/projects/amdsmi/include/amd_smi/amdsmi.h index 7732454495..78a240a2d5 100644 --- a/projects/amdsmi/include/amd_smi/amdsmi.h +++ b/projects/amdsmi/include/amd_smi/amdsmi.h @@ -3229,7 +3229,7 @@ amdsmi_topo_get_link_weight(amdsmi_processor_handle processor_handle_src, amdsmi * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail */ amdsmi_status_t - amdsmi_get_minmax_bandwith_between_processors(amdsmi_processor_handle processor_handle_src, amdsmi_processor_handle processor_handle_dst, + amdsmi_get_minmax_bandwidth_between_processors(amdsmi_processor_handle processor_handle_src, amdsmi_processor_handle processor_handle_dst, uint64_t *min_bandwidth, uint64_t *max_bandwidth); /** diff --git a/projects/amdsmi/py-interface/README.md b/projects/amdsmi/py-interface/README.md index a1c59339e0..608dc4fffb 100644 --- a/projects/amdsmi/py-interface/README.md +++ b/projects/amdsmi/py-interface/README.md @@ -3001,7 +3001,7 @@ except AmdSmiException as e: print(e) ``` -### amdsmi_get_minmax_bandwith_between_processors +### amdsmi_get_minmax_bandwidth_between_processors Description: Retreive minimal and maximal io link bandwidth between 2 GPUs. @@ -3017,7 +3017,7 @@ Field | Description `min_bandwidth` | minimal bandwidth for the connection `max_bandwidth` | maximal bandwidth for the connection -Exceptions that can be thrown by `amdsmi_get_minmax_bandwith_between_processors` function: +Exceptions that can be thrown by `amdsmi_get_minmax_bandwidth_between_processors` function: * `AmdSmiLibraryException` * `AmdSmiRetryException` @@ -3033,9 +3033,9 @@ try: else: processor_handle_src = devices[0] processor_handle_dest = devices[1] - bandwith = amdsmi_get_minmax_bandwith_between_processors(processor_handle_src, processor_handle_dest) - print(bandwith['min_bandwidth']) - print(bandwith['max_bandwidth']) + bandwidth = amdsmi_get_minmax_bandwidth_between_processors(processor_handle_src, processor_handle_dest) + print(bandwidth['min_bandwidth']) + print(bandwidth['max_bandwidth']) except AmdSmiException as e: print(e) ``` diff --git a/projects/amdsmi/py-interface/__init__.py b/projects/amdsmi/py-interface/__init__.py index 61243ab046..948ba45073 100644 --- a/projects/amdsmi/py-interface/__init__.py +++ b/projects/amdsmi/py-interface/__init__.py @@ -153,7 +153,7 @@ from .amdsmi_interface import amdsmi_get_lib_version # # Hardware topology query from .amdsmi_interface import amdsmi_topo_get_numa_node_number from .amdsmi_interface import amdsmi_topo_get_link_weight -from .amdsmi_interface import amdsmi_get_minmax_bandwith_between_processors +from .amdsmi_interface import amdsmi_get_minmax_bandwidth_between_processors from .amdsmi_interface import amdsmi_topo_get_link_type from .amdsmi_interface import amdsmi_is_P2P_accessible from .amdsmi_interface import amdsmi_get_xgmi_info diff --git a/projects/amdsmi/py-interface/amdsmi_interface.py b/projects/amdsmi/py-interface/amdsmi_interface.py index 46b3307f4a..80cde19c3a 100644 --- a/projects/amdsmi/py-interface/amdsmi_interface.py +++ b/projects/amdsmi/py-interface/amdsmi_interface.py @@ -1199,7 +1199,7 @@ def amdsmi_topo_get_link_weight( return weight.value -def amdsmi_get_minmax_bandwith_between_processors( +def amdsmi_get_minmax_bandwidth_between_processors( processor_handle_src: amdsmi_wrapper.amdsmi_processor_handle, processor_handle_dst: amdsmi_wrapper.amdsmi_processor_handle, ): @@ -1217,7 +1217,7 @@ def amdsmi_get_minmax_bandwith_between_processors( max_bandwidth = ctypes.c_uint64() _check_res( - amdsmi_wrapper.amdsmi_get_minmax_bandwith_between_processors( + amdsmi_wrapper.amdsmi_get_minmax_bandwidth_between_processors( processor_handle_src, processor_handle_dst, ctypes.byref(min_bandwidth), diff --git a/projects/amdsmi/py-interface/amdsmi_wrapper.py b/projects/amdsmi/py-interface/amdsmi_wrapper.py index bfb3c395bd..03a5ed6a3d 100644 --- a/projects/amdsmi/py-interface/amdsmi_wrapper.py +++ b/projects/amdsmi/py-interface/amdsmi_wrapper.py @@ -1580,9 +1580,9 @@ amdsmi_topo_get_numa_node_number.argtypes = [amdsmi_processor_handle, ctypes.POI amdsmi_topo_get_link_weight = _libraries['libamd_smi.so'].amdsmi_topo_get_link_weight amdsmi_topo_get_link_weight.restype = amdsmi_status_t amdsmi_topo_get_link_weight.argtypes = [amdsmi_processor_handle, amdsmi_processor_handle, ctypes.POINTER(ctypes.c_uint64)] -amdsmi_get_minmax_bandwith_between_processors = _libraries['libamd_smi.so'].amdsmi_get_minmax_bandwith_between_processors -amdsmi_get_minmax_bandwith_between_processors.restype = amdsmi_status_t -amdsmi_get_minmax_bandwith_between_processors.argtypes = [amdsmi_processor_handle, amdsmi_processor_handle, ctypes.POINTER(ctypes.c_uint64), ctypes.POINTER(ctypes.c_uint64)] +amdsmi_get_minmax_bandwidth_between_processors = _libraries['libamd_smi.so'].amdsmi_get_minmax_bandwidth_between_processors +amdsmi_get_minmax_bandwidth_between_processors.restype = amdsmi_status_t +amdsmi_get_minmax_bandwidth_between_processors.argtypes = [amdsmi_processor_handle, amdsmi_processor_handle, ctypes.POINTER(ctypes.c_uint64), ctypes.POINTER(ctypes.c_uint64)] amdsmi_topo_get_link_type = _libraries['libamd_smi.so'].amdsmi_topo_get_link_type amdsmi_topo_get_link_type.restype = amdsmi_status_t amdsmi_topo_get_link_type.argtypes = [amdsmi_processor_handle, amdsmi_processor_handle, ctypes.POINTER(ctypes.c_uint64), ctypes.POINTER(AMDSMI_IO_LINK_TYPE)] @@ -1830,7 +1830,7 @@ __all__ = \ 'amdsmi_get_gpu_vendor_name', 'amdsmi_get_gpu_volt_metric', 'amdsmi_get_gpu_vram_usage', 'amdsmi_get_gpu_vram_vendor', 'amdsmi_get_lib_version', - 'amdsmi_get_minmax_bandwith_between_processors', + 'amdsmi_get_minmax_bandwidth_between_processors', 'amdsmi_get_pcie_link_caps', 'amdsmi_get_pcie_link_status', 'amdsmi_get_power_cap_info', 'amdsmi_get_power_info', 'amdsmi_get_processor_handle_from_bdf', diff --git a/projects/amdsmi/src/amd_smi/amd_smi.cc b/projects/amdsmi/src/amd_smi/amd_smi.cc index fcfb91fb15..21f359c252 100644 --- a/projects/amdsmi/src/amd_smi/amd_smi.cc +++ b/projects/amdsmi/src/amd_smi/amd_smi.cc @@ -895,7 +895,7 @@ amdsmi_topo_get_link_weight(amdsmi_processor_handle processor_handle_src, amdsmi } amdsmi_status_t - amdsmi_get_minmax_bandwith_between_processors(amdsmi_processor_handle processor_handle_src, amdsmi_processor_handle processor_handle_dst, + amdsmi_get_minmax_bandwidth_between_processors(amdsmi_processor_handle processor_handle_src, amdsmi_processor_handle processor_handle_dst, uint64_t *min_bandwidth, uint64_t *max_bandwidth) { AMDSMI_CHECK_INIT(); From 0eaab523bf437e3efcc1b8d0fea0a349a6306474 Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Thu, 14 Sep 2023 15:13:53 -0500 Subject: [PATCH 04/11] Fixed metric temp try catch Fixed tabbing Fixed gpu is to gpu == Fixed metric temperature calls to do as much as possible and not error when one metric is not supported Signed-off-by: Maisam Arif Change-Id: I360c380ad18581ab2e0cc8f7d1109d3da2556907 [ROCm/amdsmi commit: 1394f74b925f46f5fdecb677fdfd60adb0ed401d] --- projects/amdsmi/amdsmi_cli/amdsmi_commands.py | 112 ++++++++++-------- 1 file changed, 62 insertions(+), 50 deletions(-) diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py index d1d36b8be7..fe5a0817ca 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py @@ -93,7 +93,7 @@ class AMDSMICommands(): args.gpu = gpu # Handle No GPU passed - if args.gpu is None: + if args.gpu == None: args.gpu = self.device_handles # Handle multiple GPUs @@ -178,7 +178,7 @@ class AMDSMICommands(): args.board = board # Handle No GPU passed - if args.gpu is None: + if args.gpu == None: args.gpu = self.device_handles # Handle multiple GPUs @@ -189,7 +189,7 @@ class AMDSMICommands(): # If all arguments are False, it means that no argument was passed and the entire static should be printed if self.helpers.is_linux() and self.helpers.is_baremetal(): - if not any([args.asic, args.bus, args.vbios, args.limit, args.driver, args.ras, args.board]): + if not any([args.asic, args.bus, args.vbios, args.limit, args.driver, args.ras, args.board, args.numa]): args.asic = args.bus = args.vbios = args.limit = args.driver = args.ras = args.board = args.numa = self.all_arguments = True if self.helpers.is_linux() and self.helpers.is_virtual_os(): if not any([args.asic, args.bus, args.vbios, args.driver]): @@ -442,7 +442,7 @@ class AMDSMICommands(): args.fw_list = fw_list # Handle No GPU passed - if args.gpu is None: + if args.gpu == None: args.gpu = self.device_handles # Handle multiple GPUs @@ -533,7 +533,7 @@ class AMDSMICommands(): args.un_res = un_res # Handle No GPU passed - if args.gpu is None: + if args.gpu == None: args.gpu = self.device_handles # Handle multiple GPUs @@ -601,23 +601,23 @@ class AMDSMICommands(): values_dict['pending'] = bad_page_info_output if args.un_res: - if bad_page_error: - bad_page_info_output = bad_page_err_output - else: - bad_page_info_output = [] - for bad_page in bad_page_info: - if bad_page["status"] == amdsmi_interface.AmdSmiMemoryPageStatus.UNRESERVABLE: - bad_page_info_entry = {} - bad_page_info_entry["page_address"] = bad_page["page_address"] - bad_page_info_entry["page_size"] = bad_page["page_size"] - bad_page_info_entry["status"] = bad_page["status"].name + if bad_page_error: + bad_page_info_output = bad_page_err_output + else: + bad_page_info_output = [] + for bad_page in bad_page_info: + if bad_page["status"] == amdsmi_interface.AmdSmiMemoryPageStatus.UNRESERVABLE: + bad_page_info_entry = {} + bad_page_info_entry["page_address"] = bad_page["page_address"] + bad_page_info_entry["page_size"] = bad_page["page_size"] + bad_page_info_entry["status"] = bad_page["status"].name - bad_page_info_output.append(bad_page_info_entry) - # Remove brackets if there is only one value - if len(bad_page_info_output) == 1: - bad_page_info_output = bad_page_info_output[0] + bad_page_info_output.append(bad_page_info_entry) + # Remove brackets if there is only one value + if len(bad_page_info_output) == 1: + bad_page_info_output = bad_page_info_output[0] - values_dict['un_res'] = bad_page_info_output + values_dict['un_res'] = bad_page_info_output # Store values in logger.output self.logger.store_output(args.gpu, 'values', values_dict) @@ -714,7 +714,7 @@ class AMDSMICommands(): args.energy = energy # Handle No GPU passed - if args.gpu is None: + if args.gpu == None: args.gpu = self.device_handles # Handle watch logic, will only enter this block once @@ -877,38 +877,50 @@ class AMDSMICommands(): try: temperature_edge_current = amdsmi_interface.amdsmi_get_temp_metric( args.gpu, amdsmi_interface.AmdSmiTemperatureType.EDGE, amdsmi_interface.AmdSmiTemperatureMetric.CURRENT) + except amdsmi_exception.AmdSmiLibraryException as e: + temperature_edge_current = e.get_error_info() + + try: temperature_edge_limit = amdsmi_interface.amdsmi_get_temp_metric( args.gpu, amdsmi_interface.AmdSmiTemperatureType.EDGE, amdsmi_interface.AmdSmiTemperatureMetric.CRITICAL) + except amdsmi_exception.AmdSmiLibraryException as e: + temperature_edge_limit = e.get_error_info() + + try: temperature_hotspot_current = amdsmi_interface.amdsmi_get_temp_metric( args.gpu, amdsmi_interface.AmdSmiTemperatureType.HOTSPOT, amdsmi_interface.AmdSmiTemperatureMetric.CURRENT) + except amdsmi_exception.AmdSmiLibraryException as e: + temperature_hotspot_current = e.get_error_info() + + try: temperature_vram_current = amdsmi_interface.amdsmi_get_temp_metric( args.gpu, amdsmi_interface.AmdSmiTemperatureType.VRAM, amdsmi_interface.AmdSmiTemperatureMetric.CURRENT) - - # If edge limit is reporting 0 then set the current edge temp to N/A - if temperature_edge_limit == 0: - temperature_edge_current = 'N/A' - - temperatures = {'edge': temperature_edge_current, - 'hotspot': temperature_hotspot_current, - 'mem': temperature_vram_current} - - if self.logger.is_gpuvsmi_compatibility(): - temperatures = {'edge_temperature': temperature_edge_current, - 'hotspot_temperature': temperature_hotspot_current, - 'mem_temperature': temperature_vram_current} - - if self.logger.is_human_readable_format(): - unit = '\N{DEGREE SIGN}C' - if self.logger.is_gpuvsmi_compatibility(): - unit = 'C' - for temperature_value in temperatures: - temperatures[temperature_value] = f"{temperatures[temperature_value]} {unit}" - - values_dict['temperature'] = temperatures except amdsmi_exception.AmdSmiLibraryException as e: - values_dict['temperature'] = e.get_error_info() - if not self.all_arguments: - raise e + temperature_vram_current = e.get_error_info() + + # If edge limit is reporting 0 then set the current edge temp to N/A + if temperature_edge_limit == 0: + temperature_edge_current = 'N/A' + + temperatures = {'edge': temperature_edge_current, + 'hotspot': temperature_hotspot_current, + 'mem': temperature_vram_current} + + if self.logger.is_gpuvsmi_compatibility(): + temperatures = {'edge_temperature': temperature_edge_current, + 'hotspot_temperature': temperature_hotspot_current, + 'mem_temperature': temperature_vram_current} + + if self.logger.is_human_readable_format(): + unit = '\N{DEGREE SIGN}C' + if self.logger.is_gpuvsmi_compatibility(): + unit = 'C' + for temperature_key, temperature_value in temperatures.items(): + if 'AMD_SMI_STATUS' not in str(temperature_value): + temperatures[temperature_key] = f"{temperature_value} {unit}" + + values_dict['temperature'] = temperatures + if args.ecc: ecc_count = {} try: @@ -1175,7 +1187,7 @@ class AMDSMICommands(): args.iterations = iterations # Handle No GPU passed - if args.gpu is None: + if args.gpu == None: args.gpu = self.device_handles # Handle watch logic, will only enter this block once @@ -1364,7 +1376,7 @@ class AMDSMICommands(): args.numa_bw = numa_bw # Handle No GPU passed - if args.gpu is None: + if args.gpu == None: args.gpu = self.device_handles if not isinstance(args.gpu, list): @@ -1532,7 +1544,7 @@ class AMDSMICommands(): args.perfdeterminism = perfdeterminism # Handle No GPU passed - if args.gpu is None: + if args.gpu == None: raise ValueError('No GPU provided, specific GPU target(s) are needed') # Handle multiple GPUs @@ -1631,7 +1643,7 @@ class AMDSMICommands(): args.perfdeterminism = perfdeterminism # Handle No GPU passed - if args.gpu is None: + if args.gpu == None: raise ValueError('No GPU provided, specific GPU target(s) are needed') # Handle multiple GPUs From 205e1577de16995ecf454292cc9fff7e1140b925 Mon Sep 17 00:00:00 2001 From: "Galantsev, Dmitrii" Date: Fri, 15 Sep 2023 03:04:50 -0500 Subject: [PATCH 05/11] PACKAGE - Remove __pycache__ on uninstall After running the amd-smi tool, the following directories get created: - /opt/rocm/libexec/amdsmi_cli/__pycache__ - /opt/rocm/share/amd_smi/amdsmi/__pycache__ Those need to be removed so rocm can be cleanly uninstalled. Change-Id: I1738aed444ef9427179e99f6e25ad1beab3d8fab Signed-off-by: Galantsev, Dmitrii [ROCm/amdsmi commit: daa2c4262721fcf4335e7f05868bacbbb36cbdf1] --- projects/amdsmi/DEBIAN/prerm.in | 5 +++-- projects/amdsmi/RPM/preun.in | 9 +++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/projects/amdsmi/DEBIAN/prerm.in b/projects/amdsmi/DEBIAN/prerm.in index e2d6e1443e..307ce4146d 100755 --- a/projects/amdsmi/DEBIAN/prerm.in +++ b/projects/amdsmi/DEBIAN/prerm.in @@ -34,8 +34,9 @@ rm_ldconfig() { } rm_pyc() { - # remove pyc file generated by python - rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/amd_smi/__pycache__ + # remove pyc files generated by python + rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/amdsmi_cli/__pycache__ + rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/amdsmi/__pycache__ } diff --git a/projects/amdsmi/RPM/preun.in b/projects/amdsmi/RPM/preun.in index 521c420be9..d813219a08 100755 --- a/projects/amdsmi/RPM/preun.in +++ b/projects/amdsmi/RPM/preun.in @@ -27,10 +27,15 @@ return_logrotateToOrigConfig() { fi } +rm_pyc() { + # remove pyc files generated by python + rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/amdsmi_cli/__pycache__ + rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/amdsmi/__pycache__ +} + if [ $1 -le 1 ]; then # perform the below actions for rpm remove($1=0) or upgrade($1=1) operations - # remove pyc file generated by python - rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/amd_smi/__pycache__ + rm_pyc rm_logFolder return_logrotateToOrigConfig fi From ba4506639b565eb4c4500e44dd66ec84363a68d8 Mon Sep 17 00:00:00 2001 From: "Bill(Shuzhou) Liu" Date: Wed, 13 Sep 2023 15:38:20 -0500 Subject: [PATCH 06/11] Return the driver loading status When init the library, it could return status whether the driver is loaded or not. Change-Id: Id26b8058e32881ebe2514067a639a2a871d1f252 [ROCm/amdsmi commit: f86f62b3f7d93b0be3424031dc99025d1242207c] --- projects/amdsmi/include/amd_smi/amdsmi.h | 1 + .../rocm_smi/include/rocm_smi/rocm_smi.h | 21 +++++++++++++++ projects/amdsmi/rocm_smi/src/rocm_smi.cc | 27 +++++++++++++++++++ projects/amdsmi/src/amd_smi/amd_smi_system.cc | 5 ++++ 4 files changed, 54 insertions(+) diff --git a/projects/amdsmi/include/amd_smi/amdsmi.h b/projects/amdsmi/include/amd_smi/amdsmi.h index 78a240a2d5..3405fddac7 100644 --- a/projects/amdsmi/include/amd_smi/amdsmi.h +++ b/projects/amdsmi/include/amd_smi/amdsmi.h @@ -178,6 +178,7 @@ typedef enum { AMDSMI_STATUS_NOT_FOUND = 31, //!< Device Not found AMDSMI_STATUS_NOT_INIT = 32, //!< Device not initialized AMDSMI_STATUS_NO_SLOT = 33, //!< No more free slot + AMDSMI_STATUS_DRIVER_NOT_LOADED = 34, //!< Processor driver not loaded // Data and size errors AMDSMI_STATUS_NO_DATA = 40, //!< No data was found for a given input AMDSMI_STATUS_INSUFFICIENT_SIZE = 41, //!< Not enough resources were available for the operation diff --git a/projects/amdsmi/rocm_smi/include/rocm_smi/rocm_smi.h b/projects/amdsmi/rocm_smi/include/rocm_smi/rocm_smi.h index 1d95ed00ac..37d1c6d013 100755 --- a/projects/amdsmi/rocm_smi/include/rocm_smi/rocm_smi.h +++ b/projects/amdsmi/rocm_smi/include/rocm_smi/rocm_smi.h @@ -150,6 +150,20 @@ typedef enum { RSMI_INIT_FLAG_RESRV_TEST1 = 0x800000000000000, //!< Reserved for test } rsmi_init_flags_t; +/** + * @brief Driver loading status + * + * The driver loading status from initState sysfs + */ + +typedef enum { + RSMI_DRIVER_NOT_FOUND = 0, //!< Cannot find the driver + RSMI_DRIVER_MODULE_STATE_LIVE, //!< Driver loaded and live + RSMI_DRIVER_MODULE_STATE_LOADING, //!< Driver is loading(coming) + RSMI_DRIVER_MODULE_STATE_UNLOADING, //!< Driver is unloading(going) + RSMI_DRIVER_MODULE_STATE_UNKNOWN, //!< Driver state unknown +} rsmi_driver_state_t; + /** * @brief PowerPlay performance levels */ @@ -1038,6 +1052,13 @@ rsmi_status_t rsmi_init(uint64_t init_flags); */ rsmi_status_t rsmi_shut_down(void); +/** + * @brief Get driver loading status + * + * @details The status could be not found, live, loading, unloading. + */ +rsmi_status_t rsmi_driver_status(rsmi_driver_state_t* state); + /** @} */ // end of InitShut /*****************************************************************************/ diff --git a/projects/amdsmi/rocm_smi/src/rocm_smi.cc b/projects/amdsmi/rocm_smi/src/rocm_smi.cc index 8a62ace6d1..e52851a10f 100755 --- a/projects/amdsmi/rocm_smi/src/rocm_smi.cc +++ b/projects/amdsmi/rocm_smi/src/rocm_smi.cc @@ -508,6 +508,33 @@ rsmi_shut_down(void) { CATCH } + +rsmi_status_t rsmi_driver_status(rsmi_driver_state_t* state) { + TRY + if (state == nullptr) { + return RSMI_STATUS_INVALID_ARGS; + } + + // live, coming, going + static const char *kDevInitStateID = "/sys/module/amdgpu/initstate"; + std::ifstream infile(kDevInitStateID); + if (!infile) { + *state = RSMI_DRIVER_NOT_FOUND; + return RSMI_STATUS_SUCCESS; + } + + std::string stat_str; + infile >> stat_str; + + *state = RSMI_DRIVER_MODULE_STATE_UNKNOWN; + if (stat_str == "live") *state = RSMI_DRIVER_MODULE_STATE_LIVE; + if (stat_str == "coming") *state = RSMI_DRIVER_MODULE_STATE_LOADING; + if (stat_str == "going") *state = RSMI_DRIVER_MODULE_STATE_UNLOADING; + + return RSMI_STATUS_SUCCESS; + CATCH +} + rsmi_status_t rsmi_num_monitor_devices(uint32_t *num_devices) { TRY diff --git a/projects/amdsmi/src/amd_smi/amd_smi_system.cc b/projects/amdsmi/src/amd_smi/amd_smi_system.cc index ff73d6b559..a0520fdddc 100644 --- a/projects/amdsmi/src/amd_smi/amd_smi_system.cc +++ b/projects/amdsmi/src/amd_smi/amd_smi_system.cc @@ -208,8 +208,13 @@ amdsmi_status_t AMDSmiSystem::get_cpu_model(uint32_t cpu_model) { amdsmi_status_t AMDSmiSystem::populate_amd_gpu_devices() { // init rsmi + rsmi_driver_state_t state; rsmi_status_t ret = rsmi_init(0); if (ret != RSMI_STATUS_SUCCESS) { + if (rsmi_driver_status(&state) == RSMI_STATUS_SUCCESS && + state != RSMI_DRIVER_MODULE_STATE_LIVE) { + return AMDSMI_STATUS_DRIVER_NOT_LOADED; + } return amd::smi::rsmi_to_amdsmi_status(ret); } From 0072e107bf041e3ff31a8cef24613d40d37da6b8 Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Mon, 18 Sep 2023 18:11:39 -0500 Subject: [PATCH 07/11] Adjusted power limits Signed-off-by: Maisam Arif Change-Id: I8586c4a6c9d0a6a05003013c702f88cc42d05114 [ROCm/amdsmi commit: df9e05a4b11592df5a6348bf8f37972d2c5a9aa9] --- projects/amdsmi/amdsmi_cli/amdsmi_commands.py | 18 +++++++++++------- projects/amdsmi/src/amd_smi/amd_smi.cc | 7 +++++++ projects/amdsmi/src/amd_smi/amd_smi_utils.cc | 2 +- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py index fe5a0817ca..9e217feab8 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py @@ -288,12 +288,16 @@ class AMDSMICommands(): if not self.all_arguments: raise e if args.limit: + # Power limits try: power_limit_error = False - power_limit = amdsmi_interface.amdsmi_get_power_info(args.gpu)['power_limit'] + power_info = amdsmi_interface.amdsmi_get_power_cap_info(args.gpu) + max_power_limit = power_info['max_power_cap'] + current_power_limit = power_info['power_cap'] except amdsmi_exception.AmdSmiLibraryException as e: power_limit_error = True - power_limit = e.get_error_info() + max_power_limit = e.get_error_info() + current_power_limit = e.get_error_info() if not self.all_arguments: raise e @@ -334,7 +338,8 @@ class AMDSMICommands(): if self.logger.is_human_readable_format(): unit = 'W' if not power_limit_error: - power_limit = f"{power_limit} {unit}" + max_power_limit = f"{max_power_limit} {unit}" + current_power_limit = f"{current_power_limit} {unit}" unit = '\N{DEGREE SIGN}C' if not temp_edge_limit_error: @@ -345,10 +350,9 @@ class AMDSMICommands(): temp_vram_limit = f"{temp_vram_limit} {unit}" limit_info = {} - limit_info['power'] = power_limit - limit_info['edge_temperature'] = temp_edge_limit - limit_info['hotspot_temperature'] = temp_hotspot_limit - limit_info['vram_temperature'] = temp_vram_limit + # Power limits + limit_info['max_power'] = max_power_limit + limit_info['current_power'] = current_power_limit static_dict['limit'] = limit_info if args.driver: diff --git a/projects/amdsmi/src/amd_smi/amd_smi.cc b/projects/amdsmi/src/amd_smi/amd_smi.cc index 21f359c252..d54264819a 100644 --- a/projects/amdsmi/src/amd_smi/amd_smi.cc +++ b/projects/amdsmi/src/amd_smi/amd_smi.cc @@ -1101,9 +1101,16 @@ amdsmi_get_power_cap_info(amdsmi_processor_handle processor_handle, if ((status == AMDSMI_STATUS_SUCCESS) && !set_ret_success) set_ret_success = true; + // Dividing by 1000000 to get measurement in Watts + (info->default_power_cap) /= 1000000; + status = rsmi_wrapper(rsmi_dev_power_cap_range_get, processor_handle, sensor_ind, &(info->max_power_cap), &(info->min_power_cap)); + // Dividing by 1000000 to get measurement in Watts + (info->max_power_cap) /= 1000000; + (info->min_power_cap) /= 1000000; + if ((status == AMDSMI_STATUS_SUCCESS) && !set_ret_success) set_ret_success = true; diff --git a/projects/amdsmi/src/amd_smi/amd_smi_utils.cc b/projects/amdsmi/src/amd_smi/amd_smi_utils.cc index 7863849dcc..190826c37b 100644 --- a/projects/amdsmi/src/amd_smi/amd_smi_utils.cc +++ b/projects/amdsmi/src/amd_smi/amd_smi_utils.cc @@ -163,7 +163,7 @@ amdsmi_status_t smi_amdgpu_get_power_cap(amd::smi::AMDSmiGPUDevice* device, int if (ret) return ret; - fullpath += "/power1_cap_max"; + fullpath += "/power1_cap"; std::ifstream file(fullpath.c_str(), std::ifstream::in); if (!file.is_open()) { return AMDSMI_STATUS_API_FAILED; From b3c1dd5a2a26611b38b8288a4524322a323beba7 Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Mon, 18 Sep 2023 18:11:55 -0500 Subject: [PATCH 08/11] Added slowdown temperature metrics Signed-off-by: Maisam Arif Change-Id: Ibeb7968c4fb352ff215a617908e0c0abc33a38a4 [ROCm/amdsmi commit: 93c54f52cd8f8b1f07eecdb5fc3be53ffa5c434e] --- projects/amdsmi/amdsmi_cli/amdsmi_cli.py | 9 +- projects/amdsmi/amdsmi_cli/amdsmi_commands.py | 92 ++++++++++++++----- 2 files changed, 76 insertions(+), 25 deletions(-) diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_cli.py b/projects/amdsmi/amdsmi_cli/amdsmi_cli.py index 1df9c12123..208262b630 100755 --- a/projects/amdsmi/amdsmi_cli/amdsmi_cli.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_cli.py @@ -76,10 +76,11 @@ if __name__ == "__main__": amd_smi_commands.logger.destination = args.file if args.loglevel: logging_dict = {'DEBUG' : logging.DEBUG, - 'INFO' : logging.INFO, - 'WARNING': logging.WARNING, - 'ERROR': logging.ERROR, - 'CRITICAL': logging.CRITICAL} + 'INFO' : logging.INFO, + 'WARNING': logging.WARNING, + 'ERROR': logging.ERROR, + 'CRITICAL': logging.CRITICAL} + # Enable debug logs on amdsmi library ie. RSMI_LOGGING = 1 in environment or otherwise logging.basicConfig(format='%(levelname)s: %(message)s', level=logging_dict[args.loglevel]) # Execute subcommands diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py index 9e217feab8..aff2dc6724 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py @@ -301,37 +301,74 @@ class AMDSMICommands(): if not self.all_arguments: raise e + # Edge temperature limits try: - temp_edge_limit_error = False - temp_edge_limit = amdsmi_interface.amdsmi_get_temp_metric(args.gpu, + slowdown_temp_edge_limit_error = False + slowdown_temp_edge_limit = amdsmi_interface.amdsmi_get_temp_metric(args.gpu, amdsmi_interface.AmdSmiTemperatureType.EDGE, amdsmi_interface.AmdSmiTemperatureMetric.CRITICAL) except amdsmi_exception.AmdSmiLibraryException as e: - temp_edge_limit_error = True - temp_edge_limit = e.get_error_info() + slowdown_temp_edge_limit_error = True + slowdown_temp_edge_limit = e.get_error_info() if not self.all_arguments: raise e - if temp_edge_limit == 0: - temp_edge_limit_error = True - temp_edge_limit = 'N/A' + if slowdown_temp_edge_limit == 0: + slowdown_temp_edge_limit_error = True + slowdown_temp_edge_limit = 'N/A' try: - temp_hotspot_limit_error = False - temp_hotspot_limit = amdsmi_interface.amdsmi_get_temp_metric(args.gpu, + shutdown_temp_edge_limit_error = False + shutdown_temp_edge_limit = amdsmi_interface.amdsmi_get_temp_metric(args.gpu, + amdsmi_interface.AmdSmiTemperatureType.EDGE, amdsmi_interface.AmdSmiTemperatureMetric.EMERGENCY) + except amdsmi_exception.AmdSmiLibraryException as e: + shutdown_temp_edge_limit_error = True + shutdown_temp_edge_limit = e.get_error_info() + if not self.all_arguments: + raise e + + if shutdown_temp_edge_limit == 0: + shutdown_temp_edge_limit_error = True + shutdown_temp_edge_limit = 'N/A' + + # Hotspot/Junction temperature limits + try: + slowdown_temp_hotspot_limit_error = False + slowdown_temp_hotspot_limit = amdsmi_interface.amdsmi_get_temp_metric(args.gpu, amdsmi_interface.AmdSmiTemperatureType.HOTSPOT, amdsmi_interface.AmdSmiTemperatureMetric.CRITICAL) except amdsmi_exception.AmdSmiLibraryException as e: - temp_hotspot_limit_error = True - temp_hotspot_limit = e.get_error_info() + slowdown_temp_hotspot_limit_error = True + slowdown_temp_hotspot_limit = e.get_error_info() if not self.all_arguments: raise e try: - temp_vram_limit_error = False - temp_vram_limit = amdsmi_interface.amdsmi_get_temp_metric(args.gpu, + shutdown_temp_hotspot_limit_error = False + shutdown_temp_hotspot_limit = amdsmi_interface.amdsmi_get_temp_metric(args.gpu, + amdsmi_interface.AmdSmiTemperatureType.HOTSPOT, amdsmi_interface.AmdSmiTemperatureMetric.EMERGENCY) + except amdsmi_exception.AmdSmiLibraryException as e: + shutdown_temp_hotspot_limit_error = True + shutdown_temp_hotspot_limit = e.get_error_info() + if not self.all_arguments: + raise e + + # VRAM temperature limits + try: + slowdown_temp_vram_limit_error = False + slowdown_temp_vram_limit = amdsmi_interface.amdsmi_get_temp_metric(args.gpu, amdsmi_interface.AmdSmiTemperatureType.VRAM, amdsmi_interface.AmdSmiTemperatureMetric.CRITICAL) except amdsmi_exception.AmdSmiLibraryException as e: - temp_vram_limit_error = True - temp_vram_limit = e.get_error_info() + slowdown_temp_vram_limit_error = True + slowdown_temp_vram_limit = e.get_error_info() + if not self.all_arguments: + raise e + + try: + shutdown_temp_vram_limit_error = False + shutdown_temp_vram_limit = amdsmi_interface.amdsmi_get_temp_metric(args.gpu, + amdsmi_interface.AmdSmiTemperatureType.VRAM, amdsmi_interface.AmdSmiTemperatureMetric.EMERGENCY) + except amdsmi_exception.AmdSmiLibraryException as e: + shutdown_temp_vram_limit_error = True + shutdown_temp_vram_limit = e.get_error_info() if not self.all_arguments: raise e @@ -342,18 +379,31 @@ class AMDSMICommands(): current_power_limit = f"{current_power_limit} {unit}" unit = '\N{DEGREE SIGN}C' - if not temp_edge_limit_error: - temp_edge_limit = f"{temp_edge_limit} {unit}" - if not temp_hotspot_limit_error: - temp_hotspot_limit = f"{temp_hotspot_limit} {unit}" - if not temp_vram_limit_error: - temp_vram_limit = f"{temp_vram_limit} {unit}" + if not slowdown_temp_edge_limit_error: + slowdown_temp_edge_limit = f"{slowdown_temp_edge_limit} {unit}" + if not slowdown_temp_hotspot_limit_error: + slowdown_temp_hotspot_limit = f"{slowdown_temp_hotspot_limit} {unit}" + if not slowdown_temp_vram_limit_error: + slowdown_temp_vram_limit = f"{slowdown_temp_vram_limit} {unit}" + if not shutdown_temp_edge_limit_error: + shutdown_temp_edge_limit = f"{shutdown_temp_edge_limit} {unit}" + if not shutdown_temp_hotspot_limit_error: + shutdown_temp_hotspot_limit = f"{shutdown_temp_hotspot_limit} {unit}" + if not shutdown_temp_vram_limit_error: + shutdown_temp_vram_limit = f"{shutdown_temp_vram_limit} {unit}" limit_info = {} # Power limits limit_info['max_power'] = max_power_limit limit_info['current_power'] = current_power_limit + # Shutdown limits + limit_info['slowdown_edge_temperature'] = slowdown_temp_edge_limit + limit_info['slowdown_hotspot_temperature'] = slowdown_temp_hotspot_limit + limit_info['slowdown_vram_temperature'] = slowdown_temp_vram_limit + limit_info['shutdown_edge_temperature'] = shutdown_temp_edge_limit + limit_info['shutdown_hotspot_temperature'] = shutdown_temp_hotspot_limit + limit_info['shutdown_vram_temperature'] = shutdown_temp_vram_limit static_dict['limit'] = limit_info if args.driver: try: From 23499c2e445ad4f7a28715631d91e5257cb08b18 Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Mon, 18 Sep 2023 03:39:03 -0500 Subject: [PATCH 09/11] Changed discovery to list Signed-off-by: Maisam Arif Change-Id: Ib712a182e839343472f4c6fd87a34d045b63f619 [ROCm/amdsmi commit: fab2184e7166452f318683727d273a052f1aafd8] --- projects/amdsmi/amdsmi_cli/README.md | 10 ++++---- projects/amdsmi/amdsmi_cli/amdsmi_cli.py | 2 +- projects/amdsmi/amdsmi_cli/amdsmi_commands.py | 6 ++--- projects/amdsmi/amdsmi_cli/amdsmi_parser.py | 24 +++++++++---------- 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/projects/amdsmi/amdsmi_cli/README.md b/projects/amdsmi/amdsmi_cli/README.md index 4b805fded2..e290c226a6 100644 --- a/projects/amdsmi/amdsmi_cli/README.md +++ b/projects/amdsmi/amdsmi_cli/README.md @@ -62,11 +62,9 @@ optional arguments: AMD-SMI Commands: Descriptions: version Display version information - discovery (list) - Display discovery information + list List GPU information static Gets static information about the specified GPU - firmware (ucode) - Gets firmware information about the specified GPU + firmware Gets ucode/firmware information about the specified GPU bad-pages Gets bad page information about the specified GPU metric Gets metric/performance information about the specified GPU process Lists general process information running on the specified GPU @@ -84,8 +82,8 @@ Each command will have detailed information via `amd-smi [command] --help` For convenience, here is the help output for each command ``` bash -amd-smi discovery --help -usage: amd-smi discovery [-h] [--json | --csv] [--file FILE] +amd-smi list --help +usage: amd-smi list [-h] [--json | --csv] [--file FILE] [--loglevel {DEBUG,INFO,WARNING,ERROR,CRITICAL}] [-g GPU [GPU ...]] diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_cli.py b/projects/amdsmi/amdsmi_cli/amdsmi_cli.py index 208262b630..e07db5457e 100755 --- a/projects/amdsmi/amdsmi_cli/amdsmi_cli.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_cli.py @@ -52,7 +52,7 @@ if __name__ == "__main__": amd_smi_commands = AMDSMICommands(compatibility=compatibility) amd_smi_parser = AMDSMIParser(amd_smi_commands.version, - amd_smi_commands.discovery, + amd_smi_commands.list, amd_smi_commands.static, amd_smi_commands.firmware, amd_smi_commands.bad_pages, diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py index aff2dc6724..8071b24cd7 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py @@ -74,8 +74,8 @@ class AMDSMICommands(): self.logger.print_output() - def discovery(self, args, multiple_devices=False, gpu=None): - """Get Discovery information for target gpu + def list(self, args, multiple_devices=False, gpu=None): + """List information for target gpu Args: args (Namespace): Namespace containing the parsed CLI args @@ -97,7 +97,7 @@ class AMDSMICommands(): args.gpu = self.device_handles # Handle multiple GPUs - handled_multiple_gpus, device_handle = self.helpers.handle_gpus(args, self.logger, self.discovery) + handled_multiple_gpus, device_handle = self.helpers.handle_gpus(args, self.logger, self.list) if handled_multiple_gpus: return # This function is recursive diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_parser.py b/projects/amdsmi/amdsmi_cli/amdsmi_parser.py index d0fd284681..32aa4a17b6 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_parser.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_parser.py @@ -41,7 +41,7 @@ class AMDSMIParser(argparse.ArgumentParser): Args: argparse (ArgumentParser): argparse.ArgumentParser """ - def __init__(self, version, discovery, static, firmware, bad_pages, metric, + def __init__(self, version, list, static, firmware, bad_pages, metric, process, profile, event, topology, set_value, reset, rocmsmi): # Helper variables @@ -74,7 +74,7 @@ class AMDSMIParser(argparse.ArgumentParser): # Add all subparsers self._add_version_parser(subparsers, version) - self._add_discovery_parser(subparsers, discovery) + self._add_list_parser(subparsers, list) self._add_static_parser(subparsers, static) self._add_firmware_parser(subparsers, firmware) self._add_bad_pages_parser(subparsers, bad_pages) @@ -269,25 +269,25 @@ class AMDSMIParser(argparse.ArgumentParser): self._add_command_modifiers(version_parser) - def _add_discovery_parser(self, subparsers, func): + def _add_list_parser(self, subparsers, func): # Subparser help text - discovery_help = "Display discovery information" - discovery_subcommand_help = "Lists all the devices on the system and the links between devices.\ + list_help = "List GPU information" + list_subcommand_help = "Lists all the devices on the system and the links between devices.\ \nLists all the sockets and for each socket, GPUs and/or CPUs associated to\ \nthat socket alongside some basic information for each device.\ \nIn virtualization environments, it can also list VFs associated to each\ \nGPU with some basic information for each VF." - # Create discovery subparser - discovery_parser = subparsers.add_parser('discovery', help=discovery_help, description=discovery_subcommand_help, aliases=['list']) - discovery_parser.formatter_class=lambda prog: argparse.RawTextHelpFormatter(prog, max_help_position=80, width=90) - discovery_parser.set_defaults(func=func) + # Create list subparser + list_parser = subparsers.add_parser('list', help=list_help, description=list_subcommand_help) + list_parser.formatter_class=lambda prog: argparse.RawTextHelpFormatter(prog, max_help_position=80, width=90) + list_parser.set_defaults(func=func) # Add Command Modifiers - self._add_command_modifiers(discovery_parser) + self._add_command_modifiers(list_parser) # Add Device args - self._add_device_arguments(discovery_parser, required=False) + self._add_device_arguments(list_parser, required=False) def _add_static_parser(self, subparsers, func): @@ -356,7 +356,7 @@ class AMDSMIParser(argparse.ArgumentParser): err_records_help = "All error records information" # Create firmware subparser - firmware_parser = subparsers.add_parser('firmware', help=firmware_help, description=firmware_subcommand_help, aliases=['ucode']) + firmware_parser = subparsers.add_parser('firmware', help=firmware_help, description=firmware_subcommand_help) firmware_parser._optionals.title = firmware_optionals_title firmware_parser.formatter_class=lambda prog: argparse.RawTextHelpFormatter(prog, max_help_position=80, width=90) firmware_parser.set_defaults(func=func) From 0966fdec42ae66af311ab45e9d99f198cb3dfa45 Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Mon, 18 Sep 2023 15:21:12 -0500 Subject: [PATCH 10/11] Added debug logging for amdsmi library calls Signed-off-by: Maisam Arif Change-Id: Ifb3692f50a2aaa7691b9c7afb89dd89799577e48 [ROCm/amdsmi commit: d8de6d337592c30202760aeb8d6895f8ee3d8fe4] --- projects/amdsmi/amdsmi_cli/amdsmi_commands.py | 297 +++++++++--------- 1 file changed, 143 insertions(+), 154 deletions(-) diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py index 8071b24cd7..8ba5513b53 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py @@ -20,6 +20,7 @@ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +import logging import threading import time @@ -208,9 +209,9 @@ class AMDSMICommands(): static_dict['asic'] = asic_info except amdsmi_exception.AmdSmiLibraryException as e: - static_dict['asic'] = e.get_error_info() - if not self.all_arguments: - raise e + static_dict['asic'] = "N/A" + logging.debug("Failed to get asic info for gpu %s | %s", args.gpu, e.get_error_info()) + if args.bus: bus_output_info = {} @@ -245,16 +246,14 @@ class AMDSMICommands(): bus_info['pcie_slot_type'] = "XGMI" except amdsmi_exception.AmdSmiLibraryException as e: - bus_info = e.get_error_info() - if not self.all_arguments: - raise e + bus_info = "N/A" + logging.debug("Failed to get bus info for gpu %s | %s", args.gpu, e.get_error_info()) try: bus_output_info['bdf'] = amdsmi_interface.amdsmi_get_gpu_device_bdf(args.gpu) except amdsmi_exception.AmdSmiLibraryException as e: - bus_output_info['bdf'] = e.get_error_info() - if not self.all_arguments: - raise e + bus_output_info['bdf'] = "N/A" + logging.debug("Failed to get bdf for gpu %s | %s", args.gpu, e.get_error_info()) bus_output_info.update(bus_info) static_dict['bus'] = bus_output_info @@ -268,9 +267,9 @@ class AMDSMICommands(): static_dict['vbios'] = vbios_info except amdsmi_exception.AmdSmiLibraryException as e: - static_dict['vbios'] = e.get_error_info() - if not self.all_arguments: - raise e + static_dict['vbios'] = "N/A" + logging.debug("Failed to get vbios info for gpu %s | %s", args.gpu, e.get_error_info()) + if self.helpers.is_linux() and self.helpers.is_baremetal(): if args.board: try: @@ -284,9 +283,9 @@ class AMDSMICommands(): static_dict['board'] = board_info except amdsmi_exception.AmdSmiLibraryException as e: - static_dict['board'] = e.get_error_info() - if not self.all_arguments: - raise e + static_dict['board'] = "N/A" + logging.debug("Failed to get board info for gpu %s | %s", args.gpu, e.get_error_info()) + if args.limit: # Power limits try: @@ -296,10 +295,9 @@ class AMDSMICommands(): current_power_limit = power_info['power_cap'] except amdsmi_exception.AmdSmiLibraryException as e: power_limit_error = True - max_power_limit = e.get_error_info() - current_power_limit = e.get_error_info() - if not self.all_arguments: - raise e + max_power_limit = "N/A" + current_power_limit = "N/A" + logging.debug("Failed to get power cap info for gpu %s | %s", args.gpu, e.get_error_info()) # Edge temperature limits try: @@ -308,13 +306,12 @@ class AMDSMICommands(): amdsmi_interface.AmdSmiTemperatureType.EDGE, amdsmi_interface.AmdSmiTemperatureMetric.CRITICAL) except amdsmi_exception.AmdSmiLibraryException as e: slowdown_temp_edge_limit_error = True - slowdown_temp_edge_limit = e.get_error_info() - if not self.all_arguments: - raise e + slowdown_temp_edge_limit = "N/A" + logging.debug("Failed to get edge temperature slowdown metric for gpu %s | %s", args.gpu, e.get_error_info()) if slowdown_temp_edge_limit == 0: slowdown_temp_edge_limit_error = True - slowdown_temp_edge_limit = 'N/A' + slowdown_temp_edge_limit = "N/A" try: shutdown_temp_edge_limit_error = False @@ -322,13 +319,12 @@ class AMDSMICommands(): amdsmi_interface.AmdSmiTemperatureType.EDGE, amdsmi_interface.AmdSmiTemperatureMetric.EMERGENCY) except amdsmi_exception.AmdSmiLibraryException as e: shutdown_temp_edge_limit_error = True - shutdown_temp_edge_limit = e.get_error_info() - if not self.all_arguments: - raise e + shutdown_temp_edge_limit = "N/A" + logging.debug("Failed to get edge temperature shutdown metrics for gpu %s | %s", args.gpu, e.get_error_info()) if shutdown_temp_edge_limit == 0: shutdown_temp_edge_limit_error = True - shutdown_temp_edge_limit = 'N/A' + shutdown_temp_edge_limit = "N/A" # Hotspot/Junction temperature limits try: @@ -337,9 +333,8 @@ class AMDSMICommands(): amdsmi_interface.AmdSmiTemperatureType.HOTSPOT, amdsmi_interface.AmdSmiTemperatureMetric.CRITICAL) except amdsmi_exception.AmdSmiLibraryException as e: slowdown_temp_hotspot_limit_error = True - slowdown_temp_hotspot_limit = e.get_error_info() - if not self.all_arguments: - raise e + slowdown_temp_hotspot_limit = "N/A" + logging.debug("Failed to get hotspot temperature slowdown metrics for gpu %s | %s", args.gpu, e.get_error_info()) try: shutdown_temp_hotspot_limit_error = False @@ -347,9 +342,9 @@ class AMDSMICommands(): amdsmi_interface.AmdSmiTemperatureType.HOTSPOT, amdsmi_interface.AmdSmiTemperatureMetric.EMERGENCY) except amdsmi_exception.AmdSmiLibraryException as e: shutdown_temp_hotspot_limit_error = True - shutdown_temp_hotspot_limit = e.get_error_info() - if not self.all_arguments: - raise e + shutdown_temp_hotspot_limit = "N/A" + logging.debug("Failed to get hotspot temperature shutdown metrics for gpu %s | %s", args.gpu, e.get_error_info()) + # VRAM temperature limits try: @@ -358,9 +353,8 @@ class AMDSMICommands(): amdsmi_interface.AmdSmiTemperatureType.VRAM, amdsmi_interface.AmdSmiTemperatureMetric.CRITICAL) except amdsmi_exception.AmdSmiLibraryException as e: slowdown_temp_vram_limit_error = True - slowdown_temp_vram_limit = e.get_error_info() - if not self.all_arguments: - raise e + slowdown_temp_vram_limit = "N/A" + logging.debug("Failed to get vram temperature slowdown metrics for gpu %s | %s", args.gpu, e.get_error_info()) try: shutdown_temp_vram_limit_error = False @@ -368,9 +362,8 @@ class AMDSMICommands(): amdsmi_interface.AmdSmiTemperatureType.VRAM, amdsmi_interface.AmdSmiTemperatureMetric.EMERGENCY) except amdsmi_exception.AmdSmiLibraryException as e: shutdown_temp_vram_limit_error = True - shutdown_temp_vram_limit = e.get_error_info() - if not self.all_arguments: - raise e + shutdown_temp_vram_limit = "N/A" + logging.debug("Failed to get vram temperature shutdown metrics for gpu %s | %s", args.gpu, e.get_error_info()) if self.logger.is_human_readable_format(): unit = 'W' @@ -409,38 +402,30 @@ class AMDSMICommands(): try: driver_info = {} driver_info = amdsmi_interface.amdsmi_get_gpu_driver_info(args.gpu) - static_dict['driver'] = driver_info except amdsmi_exception.AmdSmiLibraryException as e: - static_dict['driver'] = e.get_error_info() - if not self.all_arguments: - raise e + static_dict['driver'] = "N/A" + logging.debug("Failed to get driver info for gpu %s | %s", args.gpu, e.get_error_info()) + if self.helpers.is_linux() and self.helpers.is_baremetal(): if args.ras: try: static_dict['ras'] = amdsmi_interface.amdsmi_get_gpu_ras_block_features_enabled(args.gpu) except amdsmi_exception.AmdSmiLibraryException as e: - if e.get_error_code() == amdsmi_exception.AmdSmiRetCode.STATUS_NOT_SUPPORTED: - static_dict['ras'] = 'N/A' - else: - static_dict['ras'] = e.get_error_info() - if not self.all_arguments: - raise e - if (self.helpers.is_linux() and self.helpers.is_baremetal()): + static_dict['ras'] = "N/A" + logging.debug("Failed to get ras block features for gpu %s | %s", args.gpu, e.get_error_info()) if args.numa: try: numa_node_number = amdsmi_interface.amdsmi_topo_get_numa_node_number(args.gpu) except amdsmi_exception.AmdSmiLibraryException as e: - numa_node_number = e.get_error_info() - if not self.all_arguments: - raise e + numa_node_number = "N/A" + logging.debug("Failed to get numa node number for gpu %s | %s", args.gpu, e.get_error_info()) try: numa_affinity = amdsmi_interface.amdsmi_get_gpu_topo_numa_affinity(args.gpu) except amdsmi_exception.AmdSmiLibraryException as e: - numa_affinity = e.get_error_info() - if not self.all_arguments: - raise e + numa_affinity = "N/A" + logging.debug("Failed to get numa affinity for gpu %s | %s", args.gpu, e.get_error_info()) static_dict['numa'] = {'node' : numa_node_number, 'affinity' : numa_affinity} @@ -533,7 +518,8 @@ class AMDSMICommands(): fw_list.update(fw_info) except amdsmi_exception.AmdSmiLibraryException as e: - raise e + fw_list['fw_list'] = "N/A" + logging.debug("Failed to get firmware info for gpu %s | %s", args.gpu, e.get_error_info()) multiple_devices_csv_override = False # Convert and store output by pid for csv format @@ -608,9 +594,9 @@ class AMDSMICommands(): bad_page_info = amdsmi_interface.amdsmi_get_gpu_bad_page_info(args.gpu) bad_page_error = False except amdsmi_exception.AmdSmiLibraryException as e: - bad_page_err_output = e.get_error_info() bad_page_error = True - raise e + bad_page_err_output = "N/A" + logging.debug("Failed to get bad page info for gpu %s | %s", args.gpu, e.get_error_info()) if bad_page_info == "No bad pages found.": bad_page_error = True @@ -841,9 +827,8 @@ class AMDSMICommands(): values_dict['usage'] = engine_usage except amdsmi_exception.AmdSmiLibraryException as e: - values_dict['usage'] = e.get_error_info() - if not self.all_arguments: - raise e + values_dict['usage'] = "N/A" + logging.debug("Failed to get gpu activity for gpu %s | %s", args.gpu, e.get_error_info()) if args.fb_usage: try: @@ -860,9 +845,8 @@ class AMDSMICommands(): values_dict['fb_usage'] = vram_usage except amdsmi_exception.AmdSmiLibraryException as e: - values_dict['fb_usage'] = e.get_error_info() - if not self.all_arguments: - raise e + values_dict['fb_usage'] = "N/A" + logging.debug("Failed to get gpu vram usage for gpu %s | %s", args.gpu, e.get_error_info()) if self.helpers.is_linux() and self.helpers.is_baremetal(): if args.power: @@ -871,26 +855,24 @@ class AMDSMICommands(): power_measure = amdsmi_interface.amdsmi_get_power_info(args.gpu) power_dict = {'average_socket_power': power_measure['average_socket_power'], 'gfx_voltage': power_measure['gfx_voltage'], - 'soc_voltage': amdsmi_exception.AmdSmiLibraryException(amdsmi_exception.AmdSmiRetCode.STATUS_NOT_YET_IMPLEMENTED).err_info, - 'mem_voltage': amdsmi_exception.AmdSmiLibraryException(amdsmi_exception.AmdSmiRetCode.STATUS_NOT_YET_IMPLEMENTED).err_info, + 'soc_voltage': power_measure['soc_voltage'], + 'mem_voltage': power_measure['mem_voltage'], 'power_limit': power_measure['power_limit']} if self.logger.is_human_readable_format(): power_dict['average_socket_power'] = f"{power_dict['average_socket_power']} W" power_dict['gfx_voltage'] = f"{power_dict['gfx_voltage']} mV" - power_dict['soc_voltage'] = amdsmi_exception.AmdSmiLibraryException(amdsmi_exception.AmdSmiRetCode.STATUS_NOT_YET_IMPLEMENTED).err_info - power_dict['mem_voltage'] = amdsmi_exception.AmdSmiLibraryException(amdsmi_exception.AmdSmiRetCode.STATUS_NOT_YET_IMPLEMENTED).err_info + power_dict['soc_voltage'] = f"{power_dict['soc_voltage']} mV" + power_dict['mem_voltage'] = f"{power_dict['mem_voltage']} mV" power_dict['power_limit'] = f"{power_dict['power_limit']} W" except amdsmi_exception.AmdSmiLibraryException as e: - power_dict = {'average_socket_power': e.get_error_info(), - 'gfx_voltage': e.get_error_info(), - 'soc_voltage': e.get_error_info(), - 'mem_voltage': e.get_error_info(), - 'power_limit': e.get_error_info()} - - if not self.all_arguments: - raise e + power_dict = {'average_socket_power': "N/A", + 'gfx_voltage': "N/A", + 'soc_voltage': "N/A", + 'mem_voltage': "N/A", + 'power_limit': "N/A"} + logging.debug("Failed to get power info for gpu %s | %s", args.gpu, e.get_error_info()) if self.logger.is_gpuvsmi_compatibility(): power_dict['current_power'] = power_dict.pop('average_socket_power') @@ -903,9 +885,8 @@ class AMDSMICommands(): if self.logger.is_human_readable_format(): power_dict['current_fan_rpm'] = f"{power_dict['current_fan_rpm']} RPM" except amdsmi_exception.AmdSmiLibraryException as e: - power_dict['current_fan_rpm'] = e.get_error_info() - if not self.all_arguments: - raise e + power_dict['current_fan_rpm'] = "N/A" + logging.debug("Failed to get fan rpm for gpu %s | %s", args.gpu, e.get_error_info()) values_dict['power'] = power_dict if args.clock: @@ -924,37 +905,41 @@ class AMDSMICommands(): values_dict['clock'] = clocks except amdsmi_exception.AmdSmiLibraryException as e: - values_dict['clock'] = e.get_error_info() - if not self.all_arguments: - raise e + values_dict['clock'] = "N/A" + logging.debug("Failed to get gfx & mem clock info for gpu %s | %s", args.gpu, e.get_error_info()) + if args.temperature: try: temperature_edge_current = amdsmi_interface.amdsmi_get_temp_metric( args.gpu, amdsmi_interface.AmdSmiTemperatureType.EDGE, amdsmi_interface.AmdSmiTemperatureMetric.CURRENT) except amdsmi_exception.AmdSmiLibraryException as e: - temperature_edge_current = e.get_error_info() + temperature_edge_current = "N/A" + logging.debug("Failed to get current edge temperature for gpu %s | %s", args.gpu, e.get_error_info()) try: temperature_edge_limit = amdsmi_interface.amdsmi_get_temp_metric( args.gpu, amdsmi_interface.AmdSmiTemperatureType.EDGE, amdsmi_interface.AmdSmiTemperatureMetric.CRITICAL) except amdsmi_exception.AmdSmiLibraryException as e: - temperature_edge_limit = e.get_error_info() + temperature_edge_limit = "N/A" + logging.debug("Failed to get edge temperature limit for gpu %s | %s", args.gpu, e.get_error_info()) + + # If edge limit is reporting 0 then set the current edge temp to N/A + if temperature_edge_limit == 0: + temperature_edge_current = "N/A" try: temperature_hotspot_current = amdsmi_interface.amdsmi_get_temp_metric( args.gpu, amdsmi_interface.AmdSmiTemperatureType.HOTSPOT, amdsmi_interface.AmdSmiTemperatureMetric.CURRENT) except amdsmi_exception.AmdSmiLibraryException as e: - temperature_hotspot_current = e.get_error_info() + temperature_hotspot_current = "N/A" + logging.debug("Failed to get current hotspot temperature for gpu %s | %s", args.gpu, e.get_error_info()) try: temperature_vram_current = amdsmi_interface.amdsmi_get_temp_metric( args.gpu, amdsmi_interface.AmdSmiTemperatureType.VRAM, amdsmi_interface.AmdSmiTemperatureMetric.CURRENT) except amdsmi_exception.AmdSmiLibraryException as e: - temperature_vram_current = e.get_error_info() - - # If edge limit is reporting 0 then set the current edge temp to N/A - if temperature_edge_limit == 0: - temperature_edge_current = 'N/A' + temperature_vram_current = "N/A" + logging.debug("Failed to get current vram temperature for gpu %s | %s", args.gpu, e.get_error_info()) temperatures = {'edge': temperature_edge_current, 'hotspot': temperature_hotspot_current, @@ -981,17 +966,13 @@ class AMDSMICommands(): ecc_count = amdsmi_interface.amdsmi_get_gpu_total_ecc_count(args.gpu) ecc_count['correctable'] = ecc_count.pop('correctable_count') ecc_count['uncorrectable'] = ecc_count.pop('uncorrectable_count') - - values_dict['ecc'] = ecc_count except amdsmi_exception.AmdSmiLibraryException as e: - if e.get_error_code() == amdsmi_exception.AmdSmiRetCode.STATUS_NOT_SUPPORTED: - ecc_count['correctable'] = 'N/A' - ecc_count['uncorrectable'] = 'N/A' - values_dict['ecc'] = ecc_count - else: - values_dict['ecc'] = e.get_error_info() - if not self.all_arguments: - raise e + ecc_count['correctable'] = "N/A" + ecc_count['uncorrectable'] = "N/A" + logging.debug("Failed to get ecc count for gpu %s | %s", args.gpu, e.get_error_info()) + + values_dict['ecc'] = ecc_count + if args.ecc_block: ecc_dict = {} try: @@ -1004,7 +985,8 @@ class AMDSMICommands(): ecc_dict[state['block']] = {'correctable' : ecc_count['correctable_count'], 'uncorrectable': ecc_count['uncorrectable_count']} except amdsmi_exception.AmdSmiLibraryException as e: - ecc_count = e.get_error_info() + ecc_count = "N/A" + logging.debug("Failed to get ecc count for gpu %s at block %s | %s", args.gpu, gpu_block, e.get_error_info()) if self.logger.is_gpuvsmi_compatibility(): ecc_count = "N/A" @@ -1012,9 +994,8 @@ class AMDSMICommands(): 'uncorrectable': ecc_count} values_dict['ecc_block'] = ecc_dict except amdsmi_exception.AmdSmiLibraryException as e: - values_dict['ecc_block'] = e.get_error_info() - if not self.all_arguments: - raise e + values_dict['ecc_block'] = "N/A" + logging.debug("Failed to get ecc block features for gpu %s | %s", args.gpu, e.get_error_info()) if args.pcie: try: pcie_link_status = amdsmi_interface.amdsmi_get_pcie_link_status(args.gpu) @@ -1036,15 +1017,14 @@ class AMDSMICommands(): values_dict['pcie'] = pcie_link_status except amdsmi_exception.AmdSmiLibraryException as e: - values_dict['pcie'] = e.get_error_info() - if not self.all_arguments: - raise e + values_dict['pcie'] = "N/A" + logging.debug("Failed to get pcie link status for gpu %s | %s", args.gpu, e.get_error_info()) if args.fan: try: fan_speed = amdsmi_interface.amdsmi_get_gpu_fan_speed(args.gpu, 0) fan_speed_error = False except amdsmi_exception.AmdSmiLibraryException as e: - fan_speed = e.get_error_info() + fan_speed = "N/A" fan_speed_error = True try: @@ -1057,13 +1037,13 @@ class AMDSMICommands(): else: fan_percent = 'Unable to detect fan speed' except amdsmi_exception.AmdSmiLibraryException as e: - fan_max = e.get_error_info() + fan_max = "N/A" fan_percent = 'Unable to detect fan speed' try: fan_rpm = amdsmi_interface.amdsmi_get_gpu_fan_rpms(args.gpu, 0) except amdsmi_exception.AmdSmiLibraryException as e: - fan_rpm = e.get_error_info() + fan_rpm = "N/A" values_dict['fan'] = {'speed': fan_speed, 'max' : fan_max, @@ -1086,9 +1066,9 @@ class AMDSMICommands(): values_dict['voltage_curve'] = voltage_point_dict except amdsmi_exception.AmdSmiLibraryException as e: - values_dict['voltage_curve'] = e.get_error_info() - if not self.all_arguments: - raise e + values_dict['voltage_curve'] = "N/A" + logging.debug("Failed to get voltage curve for gpu %s | %s", args.gpu, e.get_error_info()) + if args.overdrive: try: overdrive_level = amdsmi_interface.amdsmi_get_gpu_overdrive_level(args.gpu) @@ -1099,17 +1079,16 @@ class AMDSMICommands(): values_dict['overdrive'] = overdrive_level except amdsmi_exception.AmdSmiLibraryException as e: - values_dict['overdrive'] = e.get_error_info() - if not self.all_arguments: - raise e + values_dict['overdrive'] = "N/A" + logging.debug("Failed to get overdrive level for gpu %s | %s", args.gpu, e.get_error_info()) + if args.perf_level: try: perf_level = amdsmi_interface.amdsmi_get_gpu_perf_level(args.gpu) values_dict['perf_level'] = perf_level except amdsmi_exception.AmdSmiLibraryException as e: - values_dict['perf_level'] = e.get_error_info() - if not self.all_arguments: - raise e + values_dict['perf_level'] = "N/A" + logging.debug("Failed to get perf level for gpu %s | %s", args.gpu, e.get_error_info()) if not self.helpers.is_virtual_os(): if args.replay_count: @@ -1117,19 +1096,16 @@ class AMDSMICommands(): pci_replay_counter = amdsmi_interface.amdsmi_get_gpu_pci_replay_counter(args.gpu) values_dict['replay_count'] = pci_replay_counter except amdsmi_exception.AmdSmiLibraryException as e: - values_dict['replay_count'] = e.get_error_info() - if not self.all_arguments: - raise e + values_dict['replay_count'] = "N/A" + logging.debug("Failed to get pci replay counter for gpu %s | %s", args.gpu, e.get_error_info()) if self.helpers.is_linux() and self.helpers.is_baremetal(): if args.xgmi_err: try: values_dict['xgmi_err'] = amdsmi_interface.amdsmi_gpu_xgmi_error_status(args.gpu) except amdsmi_interface.AmdSmiLibraryException as e: - if e.get_error_code() == amdsmi_exception.AmdSmiRetCode.STATUS_NOT_SUPPORTED: - values_dict['xgmi_err'] = 'N/A' - elif not self.all_arguments: - raise e + values_dict['xgmi_err'] = "N/A" + logging.debug("Failed to get xgmi error status for gpu %s | %s", args.gpu, e.get_error_info()) if args.energy: pass @@ -1153,11 +1129,10 @@ class AMDSMICommands(): memory_total['gtt'] = f"{memory_total['gtt']} {unit}" except amdsmi_exception.AmdSmiLibraryException as e: - memory_total['vram'] = e.get_error_info() - memory_total['vis_vram'] = e.get_error_info() - memory_total['gtt'] = e.get_error_info() - if not self.all_arguments: - raise e + memory_total['vram'] = "N/A" + memory_total['vis_vram'] = "N/A" + memory_total['gtt'] = "N/A" + logging.debug("Failed to get memory total info for gpu %s | %s", args.gpu, e.get_error_info()) try: total_used_vram = amdsmi_interface.amdsmi_get_gpu_memory_usage(args.gpu, amdsmi_interface.AmdSmiMemoryType.VRAM) @@ -1175,11 +1150,10 @@ class AMDSMICommands(): memory_total['used_gtt'] = f"{memory_total['used_gtt']} {unit}" except amdsmi_exception.AmdSmiLibraryException as e: - memory_total['used_vram'] = e.get_error_info() - memory_total['used_vis_vram'] = e.get_error_info() - memory_total['used_gtt'] = e.get_error_info() - if not self.all_arguments: - raise e + memory_total['used_vram'] = "N/A" + memory_total['used_vis_vram'] = "N/A" + memory_total['used_gtt'] = "N/A" + logging.debug("Failed to get memory usage info for gpu %s | %s", args.gpu, e.get_error_info()) values_dict['mem_usage'] = memory_total @@ -1284,6 +1258,7 @@ class AMDSMICommands(): try: process_list = amdsmi_interface.amdsmi_get_gpu_process_list(args.gpu) except amdsmi_exception.AmdSmiLibraryException as e: + logging.debug("Failed to get process list for gpu %s | %s", args.gpu, e.get_error_info()) raise e filtered_process_values = [] @@ -1291,7 +1266,8 @@ class AMDSMICommands(): try: process_info = amdsmi_interface.amdsmi_get_gpu_process_info(args.gpu, process_handle) except amdsmi_exception.AmdSmiLibraryException as e: - process_info = e.get_error_info() + process_info = "N/A" + logging.debug("Failed to get process info for gpu %s on process_handle %s | %s", args.gpu, process_handle, e.get_error_info()) filtered_process_values.append({'process_info': process_info}) continue @@ -1457,7 +1433,8 @@ class AMDSMICommands(): dest_gpu_link_status = amdsmi_interface.amdsmi_is_P2P_accessible(src_gpu, dest_gpu) src_gpu_links[dest_gpu_key] = bool(dest_gpu_link_status) except amdsmi_exception.AmdSmiLibraryException as e: - src_gpu_links[dest_gpu_key] = e.get_error_info() + src_gpu_links[dest_gpu_key] = "N/A" + logging.debug("Failed to get link status for %s to %s | %s", src_gpu, dest_gpu, e.get_error_info()) topo_values[src_gpu_index]['link_accessibility'] = src_gpu_links @@ -1476,7 +1453,8 @@ class AMDSMICommands(): dest_gpu_link_weight = amdsmi_interface.amdsmi_topo_get_link_weight(src_gpu, dest_gpu) src_gpu_weight[dest_gpu_key] = dest_gpu_link_weight except amdsmi_exception.AmdSmiLibraryException as e: - src_gpu_weight[dest_gpu_key] = e.get_error_info() + src_gpu_weight[dest_gpu_key] = "N/A" + logging.debug("Failed to get link weight for %s to %s | %s", src_gpu, dest_gpu, e.get_error_info()) topo_values[src_gpu_index]['weight'] = src_gpu_weight @@ -1495,7 +1473,8 @@ class AMDSMICommands(): dest_gpu_hops = amdsmi_interface.amdsmi_topo_get_link_type(src_gpu, dest_gpu)['hops'] src_gpu_hops[dest_gpu_key] = dest_gpu_hops except amdsmi_exception.AmdSmiLibraryException as e: - src_gpu_hops[dest_gpu_key] = e.get_error_info() + src_gpu_hops[dest_gpu_key] = "N/A" + logging.debug("Failed to get link hops for %s to %s | %s", src_gpu, dest_gpu, e.get_error_info()) topo_values[src_gpu_index]['hops'] = src_gpu_hops @@ -1519,7 +1498,8 @@ class AMDSMICommands(): elif link_type == amdsmi_interface.amdsmi_wrapper.AMDSMI_IOLINK_TYPE_XGMI: src_gpu_link_type[dest_gpu_key] = "XGMI" except amdsmi_exception.AmdSmiLibraryException as e: - src_gpu_link_type[dest_gpu_key] = e.get_error_info() + src_gpu_link_type[dest_gpu_key] = "N/A" + logging.debug("Failed to get link type for %s to %s | %s", src_gpu, dest_gpu, e.get_error_info()) topo_values[src_gpu_index]['link_type'] = src_gpu_link_type @@ -1531,7 +1511,7 @@ class AMDSMICommands(): dest_gpu_key = f'gpu_{dest_gpu_id}' if src_gpu == dest_gpu: - src_gpu_link_type[dest_gpu_key] = 'N/A' + src_gpu_link_type[dest_gpu_key] = "N/A" continue try: @@ -1539,10 +1519,11 @@ class AMDSMICommands(): if isinstance(link_type, int): if link_type != 2: non_xgmi = True - src_gpu_link_type[dest_gpu_key] = 'N/A' + src_gpu_link_type[dest_gpu_key] = "N/A" continue except amdsmi_exception.AmdSmiLibraryException as e: - src_gpu_link_type[dest_gpu_key] = e.get_error_info() + src_gpu_link_type[dest_gpu_key] = "N/A" + logging.debug("Failed to get link type for %s to %s | %s", src_gpu, dest_gpu, e.get_error_info()) try: min_bw = amdsmi_interface.amdsmi_get_minmax_bandwidth_between_processors(src_gpu, dest_gpu)['min_bandwidth'] @@ -1715,7 +1696,7 @@ class AMDSMICommands(): except amdsmi_exception.AmdSmiLibraryException as e: if e.get_error_code() == amdsmi_exception.AmdSmiRetCode.STATUS_NO_PERM: raise PermissionError('Command requires elevation') from e - result = e.get_error_info() + result = "Failed to reset GPU" else: result = 'Unable to reset non-amd GPU' @@ -1730,7 +1711,8 @@ class AMDSMICommands(): except amdsmi_exception.AmdSmiLibraryException as e: if e.get_error_code() == amdsmi_exception.AmdSmiRetCode.STATUS_NO_PERM: raise PermissionError('Command requires elevation') from e - reset_clocks_results['overdrive'] = e.get_error_info() + reset_clocks_results['overdrive'] = "N/A" + logging.debug("Failed to reset overdrive on gpu %s | %s", args.gpu, e.get_error_info()) try: level_auto = amdsmi_interface.AmdSmiDevPerfLevel.AUTO @@ -1739,7 +1721,8 @@ class AMDSMICommands(): except amdsmi_exception.AmdSmiLibraryException as e: if e.get_error_code() == amdsmi_exception.AmdSmiRetCode.STATUS_NO_PERM: raise PermissionError('Command requires elevation') from e - reset_clocks_results['clocks'] = e.get_error_info() + reset_clocks_results['clocks'] = "N/A" + logging.debug("Failed to reset perf level on gpu %s | %s", args.gpu, e.get_error_info()) try: level_auto = amdsmi_interface.AmdSmiDevPerfLevel.AUTO @@ -1748,7 +1731,8 @@ class AMDSMICommands(): except amdsmi_exception.AmdSmiLibraryException as e: if e.get_error_code() == amdsmi_exception.AmdSmiRetCode.STATUS_NO_PERM: raise PermissionError('Command requires elevation') from e - reset_clocks_results['performance'] = e.get_error_info() + reset_clocks_results['performance'] = "N/A" + logging.debug("Failed to reset perf level on gpu %s | %s", args.gpu, e.get_error_info()) self.logger.store_output(args.gpu, 'reset_clocks', reset_clocks_results) if args.fans: @@ -1758,7 +1742,8 @@ class AMDSMICommands(): except amdsmi_exception.AmdSmiLibraryException as e: if e.get_error_code() == amdsmi_exception.AmdSmiRetCode.STATUS_NO_PERM: raise PermissionError('Command requires elevation') from e - result = e.get_error_info() + result = "N/A" + logging.debug("Failed to reset fans on gpu %s | %s", args.gpu, e.get_error_info()) self.logger.store_output(args.gpu, 'reset_fans', result) if args.profile: @@ -1771,7 +1756,8 @@ class AMDSMICommands(): except amdsmi_exception.AmdSmiLibraryException as e: if e.get_error_code() == amdsmi_exception.AmdSmiRetCode.STATUS_NO_PERM: raise PermissionError('Command requires elevation') from e - reset_profile_results['power_profile'] = e.get_error_info() + reset_profile_results['power_profile'] = "N/A" + logging.debug("Failed to reset power profile on gpu %s | %s", args.gpu, e.get_error_info()) try: level_auto = amdsmi_interface.AmdSmiDevPerfLevel.AUTO @@ -1780,7 +1766,8 @@ class AMDSMICommands(): except amdsmi_exception.AmdSmiLibraryException as e: if e.get_error_code() == amdsmi_exception.AmdSmiRetCode.STATUS_NO_PERM: raise PermissionError('Command requires elevation') from e - reset_profile_results['performance_level'] = e.get_error_info() + reset_profile_results['performance_level'] = "N/A" + logging.debug("Failed to reset perf level on gpu %s | %s", args.gpu, e.get_error_info()) self.logger.store_output(args.gpu, 'reset_profile', reset_profile_results) if args.xgmierr: @@ -1790,7 +1777,8 @@ class AMDSMICommands(): except amdsmi_exception.AmdSmiLibraryException as e: if e.get_error_code() == amdsmi_exception.AmdSmiRetCode.STATUS_NO_PERM: raise PermissionError('Command requires elevation') from e - result = e.get_error_info() + result = "N/A" + logging.debug("Failed to reset xgmi error count on gpu %s | %s", args.gpu, e.get_error_info()) self.logger.store_output(args.gpu, 'reset_xgmi_err', result) if args.perfdeterminism: try: @@ -1800,7 +1788,8 @@ class AMDSMICommands(): except amdsmi_exception.AmdSmiLibraryException as e: if e.get_error_code() == amdsmi_exception.AmdSmiRetCode.STATUS_NO_PERM: raise PermissionError('Command requires elevation') from e - result = e.get_error_info() + result = "N/A" + logging.debug("Failed to set perf level on gpu %s | %s", args.gpu, e.get_error_info()) self.logger.store_output(args.gpu, 'reset_perf_determinism', result) From 8fb00bd478b36059766a6980c41bf36e0a71d74f Mon Sep 17 00:00:00 2001 From: "Galantsev, Dmitrii" Date: Mon, 18 Sep 2023 14:14:56 -0500 Subject: [PATCH 11/11] Update amdsmi_wrapper.py Change-Id: Ia523ba6ac629c02b6d6ba3db6d57507f2003f817 Signed-off-by: Galantsev, Dmitrii [ROCm/amdsmi commit: a6af1769b93421fa1b52e0e46ee18695251d9012] --- .../amdsmi/py-interface/amdsmi_wrapper.py | 153 ++++++++++++++---- 1 file changed, 123 insertions(+), 30 deletions(-) diff --git a/projects/amdsmi/py-interface/amdsmi_wrapper.py b/projects/amdsmi/py-interface/amdsmi_wrapper.py index 03a5ed6a3d..f2e13fd2b4 100644 --- a/projects/amdsmi/py-interface/amdsmi_wrapper.py +++ b/projects/amdsmi/py-interface/amdsmi_wrapper.py @@ -555,6 +555,70 @@ FW_ID_SMC = 76 FW_ID_DMCU = 77 FW_ID__MAX = 78 amdsmi_fw_block_t = ctypes.c_uint32 # enum + +# values for enumeration 'amdsmi_vram_type_t' +amdsmi_vram_type_t__enumvalues = { + 0: 'VRAM_TYPE_UNKNOWN', + 1: 'VRAM_TYPE_GDDR1', + 2: 'VRAM_TYPE_DDR2', + 3: 'VRAM_TYPE_GDDR3', + 4: 'VRAM_TYPE_GDDR4', + 5: 'VRAM_TYPE_GDDR5', + 6: 'VRAM_TYPE_HBM', + 7: 'VRAM_TYPE_DDR3', + 8: 'VRAM_TYPE_DDR4', + 9: 'VRAM_TYPE_GDDR6', + 9: 'VRAM_TYPE__MAX', +} +VRAM_TYPE_UNKNOWN = 0 +VRAM_TYPE_GDDR1 = 1 +VRAM_TYPE_DDR2 = 2 +VRAM_TYPE_GDDR3 = 3 +VRAM_TYPE_GDDR4 = 4 +VRAM_TYPE_GDDR5 = 5 +VRAM_TYPE_HBM = 6 +VRAM_TYPE_DDR3 = 7 +VRAM_TYPE_DDR4 = 8 +VRAM_TYPE_GDDR6 = 9 +VRAM_TYPE__MAX = 9 +amdsmi_vram_type_t = ctypes.c_uint32 # enum + +# values for enumeration 'amdsmi_vram_vendor_type_t' +amdsmi_vram_vendor_type_t__enumvalues = { + 0: 'AMDSMI_VRAM_VENDOR__PLACEHOLDER0', + 1: 'AMDSMI_VRAM_VENDOR__SAMSUNG', + 2: 'AMDSMI_VRAM_VENDOR__INFINEON', + 3: 'AMDSMI_VRAM_VENDOR__ELPIDA', + 4: 'AMDSMI_VRAM_VENDOR__ETRON', + 5: 'AMDSMI_VRAM_VENDOR__NANYA', + 6: 'AMDSMI_VRAM_VENDOR__HYNIX', + 7: 'AMDSMI_VRAM_VENDOR__MOSEL', + 8: 'AMDSMI_VRAM_VENDOR__WINBOND', + 9: 'AMDSMI_VRAM_VENDOR__ESMT', + 10: 'AMDSMI_VRAM_VENDOR__PLACEHOLDER1', + 11: 'AMDSMI_VRAM_VENDOR__PLACEHOLDER2', + 12: 'AMDSMI_VRAM_VENDOR__PLACEHOLDER3', + 13: 'AMDSMI_VRAM_VENDOR__PLACEHOLDER4', + 14: 'AMDSMI_VRAM_VENDOR__PLACEHOLDER5', + 15: 'AMDSMI_VRAM_VENDOR__MICRON', +} +AMDSMI_VRAM_VENDOR__PLACEHOLDER0 = 0 +AMDSMI_VRAM_VENDOR__SAMSUNG = 1 +AMDSMI_VRAM_VENDOR__INFINEON = 2 +AMDSMI_VRAM_VENDOR__ELPIDA = 3 +AMDSMI_VRAM_VENDOR__ETRON = 4 +AMDSMI_VRAM_VENDOR__NANYA = 5 +AMDSMI_VRAM_VENDOR__HYNIX = 6 +AMDSMI_VRAM_VENDOR__MOSEL = 7 +AMDSMI_VRAM_VENDOR__WINBOND = 8 +AMDSMI_VRAM_VENDOR__ESMT = 9 +AMDSMI_VRAM_VENDOR__PLACEHOLDER1 = 10 +AMDSMI_VRAM_VENDOR__PLACEHOLDER2 = 11 +AMDSMI_VRAM_VENDOR__PLACEHOLDER3 = 12 +AMDSMI_VRAM_VENDOR__PLACEHOLDER4 = 13 +AMDSMI_VRAM_VENDOR__PLACEHOLDER5 = 14 +AMDSMI_VRAM_VENDOR__MICRON = 15 +amdsmi_vram_vendor_type_t = ctypes.c_uint32 # enum class struct_amdsmi_range_t(Structure): pass @@ -690,6 +754,17 @@ struct_amdsmi_asic_info_t._fields_ = [ ] amdsmi_asic_info_t = struct_amdsmi_asic_info_t +class struct_amdsmi_vram_info_t(Structure): + pass + +struct_amdsmi_vram_info_t._pack_ = 1 # source:False +struct_amdsmi_vram_info_t._fields_ = [ + ('vram_type', amdsmi_vram_type_t), + ('vram_vendor', amdsmi_vram_vendor_type_t), + ('vram_size_mb', ctypes.c_uint64), +] + +amdsmi_vram_info_t = struct_amdsmi_vram_info_t class struct_amdsmi_driver_info_t(Structure): pass @@ -758,6 +833,16 @@ amdsmi_process_handle_t = ctypes.c_uint32 class struct_amdsmi_proc_info_t(Structure): pass +class struct_engine_usage_(Structure): + pass + +struct_engine_usage_._pack_ = 1 # source:False +struct_engine_usage_._fields_ = [ + ('gfx', ctypes.c_uint64), + ('enc', ctypes.c_uint64), + ('reserved', ctypes.c_uint32 * 12), +] + class struct_memory_usage_(Structure): pass @@ -769,16 +854,6 @@ struct_memory_usage_._fields_ = [ ('reserved', ctypes.c_uint32 * 10), ] -class struct_engine_usage_(Structure): - pass - -struct_engine_usage_._pack_ = 1 # source:False -struct_engine_usage_._fields_ = [ - ('gfx', ctypes.c_uint64), - ('enc', ctypes.c_uint64), - ('reserved', ctypes.c_uint32 * 12), -] - struct_amdsmi_proc_info_t._pack_ = 1 # source:False struct_amdsmi_proc_info_t._fields_ = [ ('name', ctypes.c_char * 32), @@ -1613,6 +1688,9 @@ amdsmi_get_gpu_driver_info.argtypes = [amdsmi_processor_handle, ctypes.POINTER(s amdsmi_get_gpu_asic_info = _libraries['libamd_smi.so'].amdsmi_get_gpu_asic_info amdsmi_get_gpu_asic_info.restype = amdsmi_status_t amdsmi_get_gpu_asic_info.argtypes = [amdsmi_processor_handle, ctypes.POINTER(struct_amdsmi_asic_info_t)] +amdsmi_get_gpu_vram_info = _libraries['libamd_smi.so'].amdsmi_get_gpu_vram_info +amdsmi_get_gpu_vram_info.restype = amdsmi_status_t +amdsmi_get_gpu_vram_info.argtypes = [amdsmi_processor_handle, ctypes.POINTER(struct_amdsmi_vram_info_t)] amdsmi_get_gpu_board_info = _libraries['libamd_smi.so'].amdsmi_get_gpu_board_info amdsmi_get_gpu_board_info.restype = amdsmi_status_t amdsmi_get_gpu_board_info.argtypes = [amdsmi_processor_handle, ctypes.POINTER(struct_amdsmi_board_info_t)] @@ -1746,7 +1824,18 @@ __all__ = \ 'AMDSMI_VOLT_MAX_CRIT', 'AMDSMI_VOLT_MIN', 'AMDSMI_VOLT_MIN_CRIT', 'AMDSMI_VOLT_TYPE_FIRST', 'AMDSMI_VOLT_TYPE_INVALID', 'AMDSMI_VOLT_TYPE_LAST', 'AMDSMI_VOLT_TYPE_VDDGFX', - 'AMDSMI_XGMI_STATUS_ERROR', 'AMDSMI_XGMI_STATUS_MULTIPLE_ERRORS', + 'AMDSMI_VRAM_VENDOR__ELPIDA', 'AMDSMI_VRAM_VENDOR__ESMT', + 'AMDSMI_VRAM_VENDOR__ETRON', 'AMDSMI_VRAM_VENDOR__HYNIX', + 'AMDSMI_VRAM_VENDOR__INFINEON', 'AMDSMI_VRAM_VENDOR__MICRON', + 'AMDSMI_VRAM_VENDOR__MOSEL', 'AMDSMI_VRAM_VENDOR__NANYA', + 'AMDSMI_VRAM_VENDOR__PLACEHOLDER0', + 'AMDSMI_VRAM_VENDOR__PLACEHOLDER1', + 'AMDSMI_VRAM_VENDOR__PLACEHOLDER2', + 'AMDSMI_VRAM_VENDOR__PLACEHOLDER3', + 'AMDSMI_VRAM_VENDOR__PLACEHOLDER4', + 'AMDSMI_VRAM_VENDOR__PLACEHOLDER5', 'AMDSMI_VRAM_VENDOR__SAMSUNG', + 'AMDSMI_VRAM_VENDOR__WINBOND', 'AMDSMI_XGMI_STATUS_ERROR', + 'AMDSMI_XGMI_STATUS_MULTIPLE_ERRORS', 'AMDSMI_XGMI_STATUS_NO_ERRORS', 'AMD_APU', 'AMD_CPU', 'AMD_CPU_CORE', 'AMD_GPU', 'CLK_TYPE_DCEF', 'CLK_TYPE_DCLK0', 'CLK_TYPE_DCLK1', 'CLK_TYPE_DF', 'CLK_TYPE_FIRST', 'CLK_TYPE_GFX', @@ -1783,12 +1872,15 @@ __all__ = \ 'TEMPERATURE_TYPE_EDGE', 'TEMPERATURE_TYPE_FIRST', 'TEMPERATURE_TYPE_HBM_0', 'TEMPERATURE_TYPE_HBM_1', 'TEMPERATURE_TYPE_HBM_2', 'TEMPERATURE_TYPE_HBM_3', - 'TEMPERATURE_TYPE_HOTSPOT', - 'TEMPERATURE_TYPE_JUNCTION', 'TEMPERATURE_TYPE_PLX', - 'TEMPERATURE_TYPE_VRAM', 'TEMPERATURE_TYPE__MAX', 'UNKNOWN', - 'amd_metrics_table_header_t', 'amdsmi_asic_info_t', - 'amdsmi_bdf_t', 'amdsmi_bit_field_t', 'amdsmi_board_info_t', - 'amdsmi_clk_info_t', 'amdsmi_clk_type_t', + 'TEMPERATURE_TYPE_HOTSPOT', 'TEMPERATURE_TYPE_JUNCTION', + 'TEMPERATURE_TYPE_PLX', 'TEMPERATURE_TYPE_VRAM', + 'TEMPERATURE_TYPE__MAX', 'UNKNOWN', 'VRAM_TYPE_DDR2', + 'VRAM_TYPE_DDR3', 'VRAM_TYPE_DDR4', 'VRAM_TYPE_GDDR1', + 'VRAM_TYPE_GDDR3', 'VRAM_TYPE_GDDR4', 'VRAM_TYPE_GDDR5', + 'VRAM_TYPE_GDDR6', 'VRAM_TYPE_HBM', 'VRAM_TYPE_UNKNOWN', + 'VRAM_TYPE__MAX', 'amd_metrics_table_header_t', + 'amdsmi_asic_info_t', 'amdsmi_bdf_t', 'amdsmi_bit_field_t', + 'amdsmi_board_info_t', 'amdsmi_clk_info_t', 'amdsmi_clk_type_t', 'amdsmi_container_types_t', 'amdsmi_counter_command_t', 'amdsmi_counter_value_t', 'amdsmi_dev_perf_level_t', 'amdsmi_driver_info_t', 'amdsmi_engine_usage_t', @@ -1828,8 +1920,8 @@ __all__ = \ 'amdsmi_get_gpu_topo_numa_affinity', 'amdsmi_get_gpu_total_ecc_count', 'amdsmi_get_gpu_vbios_info', 'amdsmi_get_gpu_vendor_name', 'amdsmi_get_gpu_volt_metric', - 'amdsmi_get_gpu_vram_usage', 'amdsmi_get_gpu_vram_vendor', - 'amdsmi_get_lib_version', + 'amdsmi_get_gpu_vram_info', 'amdsmi_get_gpu_vram_usage', + 'amdsmi_get_gpu_vram_vendor', 'amdsmi_get_lib_version', 'amdsmi_get_minmax_bandwidth_between_processors', 'amdsmi_get_pcie_link_caps', 'amdsmi_get_pcie_link_status', 'amdsmi_get_power_cap_info', 'amdsmi_get_power_info', @@ -1871,13 +1963,14 @@ __all__ = \ 'amdsmi_topo_get_numa_node_number', 'amdsmi_utilization_counter_t', 'amdsmi_vbios_info_t', 'amdsmi_version_t', 'amdsmi_voltage_metric_t', - 'amdsmi_voltage_type_t', 'amdsmi_vram_usage_t', - 'amdsmi_xgmi_info_t', 'amdsmi_xgmi_status_t', 'processor_type_t', - 'size_t', 'struct_amd_metrics_table_header_t', - 'struct_amdsmi_asic_info_t', 'struct_amdsmi_board_info_t', - 'struct_amdsmi_clk_info_t', 'struct_amdsmi_counter_value_t', - 'struct_amdsmi_driver_info_t', 'struct_amdsmi_engine_usage_t', - 'struct_amdsmi_error_count_t', + 'amdsmi_voltage_type_t', 'amdsmi_vram_info_t', + 'amdsmi_vram_type_t', 'amdsmi_vram_usage_t', + 'amdsmi_vram_vendor_type_t', 'amdsmi_xgmi_info_t', + 'amdsmi_xgmi_status_t', 'processor_type_t', 'size_t', + 'struct_amd_metrics_table_header_t', 'struct_amdsmi_asic_info_t', + 'struct_amdsmi_board_info_t', 'struct_amdsmi_clk_info_t', + 'struct_amdsmi_counter_value_t', 'struct_amdsmi_driver_info_t', + 'struct_amdsmi_engine_usage_t', 'struct_amdsmi_error_count_t', 'struct_amdsmi_evt_notification_data_t', 'struct_amdsmi_freq_volt_region_t', 'struct_amdsmi_frequencies_t', 'struct_amdsmi_frequency_range_t', 'struct_amdsmi_fw_info_t', @@ -1891,7 +1984,7 @@ __all__ = \ 'struct_amdsmi_range_t', 'struct_amdsmi_retired_page_record_t', 'struct_amdsmi_utilization_counter_t', 'struct_amdsmi_vbios_info_t', 'struct_amdsmi_version_t', - 'struct_amdsmi_vram_usage_t', 'struct_amdsmi_xgmi_info_t', - 'struct_engine_usage_', 'struct_fields_', 'struct_fw_info_list_', - 'struct_memory_usage_', 'uint32_t', 'uint64_t', - 'union_amdsmi_bdf_t'] + 'struct_amdsmi_vram_info_t', 'struct_amdsmi_vram_usage_t', + 'struct_amdsmi_xgmi_info_t', 'struct_engine_usage_', + 'struct_fields_', 'struct_fw_info_list_', 'struct_memory_usage_', + 'uint32_t', 'uint64_t', 'union_amdsmi_bdf_t']