From a60f5d2d4c58255b3c998fcf0b9aeec28d53741c Mon Sep 17 00:00:00 2001 From: "Galantsev, Dmitrii" Date: Thu, 11 Jan 2024 01:38:15 -0600 Subject: [PATCH 01/22] SWDEV-409184 - Exclude some tests in VM Change-Id: Ic196a113426fc63a0b2aadfa04ab4b10ed6434e3 Signed-off-by: Galantsev, Dmitrii --- tests/amd_smi_test/CMakeLists.txt | 2 +- tests/amd_smi_test/main.cc | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/amd_smi_test/CMakeLists.txt b/tests/amd_smi_test/CMakeLists.txt index 865042b89b..6433986a9a 100644 --- a/tests/amd_smi_test/CMakeLists.txt +++ b/tests/amd_smi_test/CMakeLists.txt @@ -50,7 +50,7 @@ set(TEST "amdsmitst") aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} tstSources) # Header file include path -include_directories(${TEST} ${CMAKE_CURRENT_SOURCE_DIR}/..) +include_directories(${TEST} ${CMAKE_CURRENT_SOURCE_DIR}/.. ${ROCM_INC_DIR}/..) # Build rules add_executable(${TEST} ${tstSources} ${functionalSources}) diff --git a/tests/amd_smi_test/main.cc b/tests/amd_smi_test/main.cc index d38c148f31..cd13497a92 100644 --- a/tests/amd_smi_test/main.cc +++ b/tests/amd_smi_test/main.cc @@ -49,6 +49,7 @@ #include #include "amd_smi/amdsmi.h" +#include "rocm_smi/rocm_smi_utils.h" #include #include "test_common.h" #include "test_base.h" @@ -159,10 +160,12 @@ TEST(amdsmitstReadOnly, TestVoltCurvRead) { RunGenericTest(&tst); } TEST(amdsmitstReadOnly, TestPerfLevelRead) { + if (amd::smi::is_vm_guest()) GTEST_SKIP(); TestPerfLevelRead tst; RunGenericTest(&tst); } TEST(amdsmitstReadWrite, TestPerfLevelReadWrite) { + if (amd::smi::is_vm_guest()) GTEST_SKIP(); TestPerfLevelReadWrite tst; RunGenericTest(&tst); } @@ -183,10 +186,12 @@ TEST(amdsmitstReadWrite, TestFrequenciesReadWrite) { RunGenericTest(&tst); } TEST(amdsmitstReadWrite, TestPciReadWrite) { + if (amd::smi::is_vm_guest()) GTEST_SKIP(); TestPciReadWrite tst; RunGenericTest(&tst); } TEST(amdsmitstReadOnly, TestSysInfoRead) { + if (amd::smi::is_vm_guest()) GTEST_SKIP(); TestSysInfoRead tst; RunGenericTest(&tst); } @@ -195,14 +200,17 @@ TEST(amdsmitstReadOnly, TestGPUBusyRead) { RunGenericTest(&tst); } TEST(amdsmitstReadOnly, TestPowerRead) { + if (amd::smi::is_vm_guest()) GTEST_SKIP(); TestPowerRead tst; RunGenericTest(&tst); } TEST(amdsmitstReadWrite, TestPowerReadWrite) { + if (amd::smi::is_vm_guest()) GTEST_SKIP(); TestPowerReadWrite tst; RunGenericTest(&tst); } TEST(amdsmitstReadWrite, TestPowerCapReadWrite) { + if (amd::smi::is_vm_guest()) GTEST_SKIP(); TestPowerCapReadWrite tst; RunGenericTest(&tst); } @@ -215,6 +223,7 @@ TEST(amdsmitstReadOnly, TestMemUtilRead) { RunGenericTest(&tst); } TEST(amdsmitstReadOnly, TestIdInfoRead) { + if (amd::smi::is_vm_guest()) GTEST_SKIP(); TestIdInfoRead tst; RunGenericTest(&tst); } From d74be3120e09b5b4c456b311b37aa5c86438115f Mon Sep 17 00:00:00 2001 From: Charis Poag Date: Sun, 14 Jan 2024 19:22:31 -0600 Subject: [PATCH 02/22] Fix AMD-SMI test segmentation fault TestGpuMetricsRead Issue: need to return on any failure. The nullptr check test would segfault without- all values in struct are not initialized. Signed-off-by: Charis Poag Change-Id: I4987fb73ba9bcb182de7a439a4286333a41bf7eb --- src/amd_smi/amd_smi.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/amd_smi/amd_smi.cc b/src/amd_smi/amd_smi.cc index ae4b5af69b..aff25228b2 100644 --- a/src/amd_smi/amd_smi.cc +++ b/src/amd_smi/amd_smi.cc @@ -1084,6 +1084,9 @@ amdsmi_status_t amdsmi_get_gpu_metrics_info( amdsmi_status_t ret = rsmi_wrapper(rsmi_dev_gpu_metrics_info_get, processor_handle, reinterpret_cast(pgpu_metrics)); + if (ret != AMDSMI_STATUS_SUCCESS) { + return ret; + } // WARNING: TEMPORARY - awaiting 1.5 update from amdgpu driver/firmware // intended to be removed later // START: REMOVE WHATS BELOW ME From 5a6b5d2a0a4e120e6d5174086342af030fa52cce Mon Sep 17 00:00:00 2001 From: "Bill(Shuzhou) Liu" Date: Thu, 11 Jan 2024 08:35:04 -0600 Subject: [PATCH 03/22] Use the same mutex as rocm-smi Share the same mutex as rocm-smi implementation. Handle the crash when a user is not in render group. Change-Id: I486b26569f9b523b41bbdaf95d51f4a730978cfd --- include/amd_smi/impl/amd_smi_gpu_device.h | 2 -- src/amd_smi/amd_smi_drm.cc | 10 +++++++++- src/amd_smi/amd_smi_gpu_device.cc | 8 ++------ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/include/amd_smi/impl/amd_smi_gpu_device.h b/include/amd_smi/impl/amd_smi_gpu_device.h index b512ce3e76..527d52774f 100644 --- a/include/amd_smi/impl/amd_smi_gpu_device.h +++ b/include/amd_smi/impl/amd_smi_gpu_device.h @@ -63,7 +63,6 @@ class AMDSmiGPUDevice: public AMDSmiProcessor { if (check_if_drm_is_supported()) this->get_drm_data(); } ~AMDSmiGPUDevice() { - if (check_if_drm_is_supported()) shared_mutex_close(mutex_); } amdsmi_status_t get_drm_data(); @@ -91,7 +90,6 @@ class AMDSmiGPUDevice: public AMDSmiProcessor { amdsmi_bdf_t bdf_; uint32_t vendor_id_; AMDSmiDrm& drm_; - shared_mutex_t mutex_; }; diff --git a/src/amd_smi/amd_smi_drm.cc b/src/amd_smi/amd_smi_drm.cc index a3b2fbc79e..3d0f4558c3 100644 --- a/src/amd_smi/amd_smi_drm.cc +++ b/src/amd_smi/amd_smi_drm.cc @@ -131,6 +131,7 @@ amdsmi_status_t AMDSmiDrm::init() { amd::smi::RocmSMI& smi = amd::smi::RocmSMI::getInstance(); auto devices = smi.devices(); + bool has_valid_fds = false; for (uint32_t i=0; i < devices.size(); i++) { auto rocm_smi_device = devices[i]; std::string render_file_name; @@ -171,6 +172,7 @@ amdsmi_status_t AMDSmiDrm::init() { continue; } + has_valid_fds = true; bdf.fields.function_number = device->businfo.pci->func; bdf.fields.device_number = device->businfo.pci->dev; bdf.fields.bus_number = device->businfo.pci->bus; @@ -182,6 +184,12 @@ amdsmi_status_t AMDSmiDrm::init() { drm_free_device(&device); } + // cannot find any valid fds. + if (!has_valid_fds) { + drm_bdfs_.clear(); + return AMDSMI_STATUS_INIT_ERROR; + } + return AMDSMI_STATUS_SUCCESS; } @@ -315,7 +323,7 @@ std::vector& AMDSmiDrm::get_drm_paths() { } bool AMDSmiDrm::check_if_drm_is_supported() { - return drm_cmd_write_ != NULL ? true : false; + return (drm_cmd_write_ != NULL && drm_bdfs_.size() >0) ? true : false; } std::vector AMDSmiDrm::get_bdfs() { diff --git a/src/amd_smi/amd_smi_gpu_device.cc b/src/amd_smi/amd_smi_gpu_device.cc index b303e82ea3..45d419f2e8 100644 --- a/src/amd_smi/amd_smi_gpu_device.cc +++ b/src/amd_smi/amd_smi_gpu_device.cc @@ -43,6 +43,7 @@ #include #include "amd_smi/impl/amd_smi_gpu_device.h" +#include "rocm_smi/rocm_smi_utils.h" namespace amd { @@ -80,11 +81,6 @@ amdsmi_status_t AMDSmiGPUDevice::get_drm_data() { ret = drm_.get_bdf_by_index(gpu_id_, &bdf); if (ret != AMDSMI_STATUS_SUCCESS) return AMDSMI_STATUS_NOT_SUPPORTED; - mutex_ = shared_mutex_init(path.c_str(), 0777); - if (mutex_.ptr == nullptr) { - printf("Failed to create shared mem. mutex."); - return AMDSMI_STATUS_INIT_ERROR; - } bdf_ = bdf, path_ = path, fd_ = fd; vendor_id_ = drm_.get_vendor_id(); @@ -92,7 +88,7 @@ amdsmi_status_t AMDSmiGPUDevice::get_drm_data() { } pthread_mutex_t* AMDSmiGPUDevice::get_mutex() { - return mutex_.ptr; + return amd::smi::GetMutex(gpu_id_); } amdsmi_status_t AMDSmiGPUDevice::amdgpu_query_info(unsigned info_id, From 4575990ae77dbd4f23dc6057deaac5d9d9f8f32f Mon Sep 17 00:00:00 2001 From: Charis Poag Date: Mon, 15 Jan 2024 23:14:44 -0600 Subject: [PATCH 04/22] GPU Usage/activity update CLI: Every usage field is notated by "activity" gfx_usage -> gfx_activity umc_usage -> umc_activity vcn_activities -> vcn_activity jpeg_activities[AID#] -> jpeg_activity Wrapper: fixed metric output, misalignment with generator update_wrapper.sh: DOCKER_BUILDKIT to 0 (if unset) API: amdsmi_get_gpu_metrics_info: 1.3: Removed commenting out avg socket power Signed-off-by: Charis Poag Change-Id: Id3fcc20aef420c7b7a90ba22fa3bc643b2716333 --- amdsmi_cli/amdsmi_commands.py | 13 +++++-------- py-interface/README.md | 6 +++--- py-interface/amdsmi_interface.py | 5 +---- py-interface/amdsmi_wrapper.py | 24 ++++++++++++------------ rocm_smi/src/rocm_smi_gpu_metrics.cc | 2 +- update_wrapper.sh | 2 +- 6 files changed, 23 insertions(+), 29 deletions(-) diff --git a/amdsmi_cli/amdsmi_commands.py b/amdsmi_cli/amdsmi_commands.py index 26ff1602c7..487531b6cb 100644 --- a/amdsmi_cli/amdsmi_commands.py +++ b/amdsmi_cli/amdsmi_commands.py @@ -1122,14 +1122,11 @@ class AMDSMICommands(): if args.usage: try: engine_usage = amdsmi_interface.amdsmi_get_gpu_activity(args.gpu) - engine_usage['gfx_usage'] = engine_usage.pop('gfx_activity') - engine_usage['mem_usage'] = engine_usage.pop('umc_activity') - engine_usage['mm_ip_usage'] = engine_usage.pop('mm_activity') - engine_usage['vcn_activities'] = gpu_metric_output.pop('vcn_activity') - engine_usage['jpeg_activities[AID0]'] = gpu_metric_output.pop('jpeg_activities[AID0]') - engine_usage['jpeg_activities[AID1]'] = gpu_metric_output.pop('jpeg_activities[AID1]') - engine_usage['jpeg_activities[AID2]'] = gpu_metric_output.pop('jpeg_activities[AID2]') - engine_usage['jpeg_activities[AID3]'] = gpu_metric_output.pop('jpeg_activities[AID3]') + engine_usage['gfx_activity'] = engine_usage.pop('gfx_activity') + engine_usage['umc_activity'] = engine_usage.pop('umc_activity') + engine_usage['mm_activity'] = engine_usage.pop('mm_activity') + engine_usage['vcn_activity'] = gpu_metric_output.pop('vcn_activity') + engine_usage['jpeg_activity'] = gpu_metric_output.pop('jpeg_activity') for key, value in engine_usage.items(): if not isinstance(value, list) and value > 100: engine_usage[key] = "N/A" diff --git a/py-interface/README.md b/py-interface/README.md index f10852cb9c..de5fbbb7cf 100644 --- a/py-interface/README.md +++ b/py-interface/README.md @@ -2126,8 +2126,8 @@ Output: Dictionary with fields `temperature_vrsoc` | vrsoc temperature value | Celsius (C) `temperature_vrmem` | vrmem temperature value | Celsius (C) `average_gfx_activity` | Average gfx activity | % -`average_umc_activity` | Average umc activity | % -`average_mm_activity` | Average mm activity | % +`average_umc_activity` | Average umc (Universal Memory Controller) activity | % +`average_mm_activity` | Average mm (multimedia) engine activity | % `average_socket_power` | Average socket power | W `energy_accumulator` | Energy accumulated with a 15.3 uJ resolution over 1ns | uJ `system_clock_counter` | System clock counter | ns @@ -2178,7 +2178,7 @@ Output: Dictionary with fields `mem_max_bandwidth` | Maximum memory bandwidth usage accumulated | GB/s `pcie_nak_sent_count_acc` | PCIe NAC sent count accumulated | `pcie_nak_rcvd_count_acc` | PCIe NAC received count accumulated | -`jpeg_activitys[AID]` | List of JPEG engine activity for each AID (X=0-3) | % +`jpeg_activity` | List of JPEG engine activity | % Exceptions that can be thrown by `amdsmi_get_gpu_metrics_info` function: diff --git a/py-interface/amdsmi_interface.py b/py-interface/amdsmi_interface.py index 1709ab795a..01743641ed 100644 --- a/py-interface/amdsmi_interface.py +++ b/py-interface/amdsmi_interface.py @@ -3242,10 +3242,7 @@ def amdsmi_get_gpu_metrics_info( "mem_max_bandwidth": gpu_metrics.mem_max_bandwidth, "pcie_nak_sent_count_acc": gpu_metrics.pcie_nak_sent_count_acc, "pcie_nak_rcvd_count_acc": gpu_metrics.pcie_nak_rcvd_count_acc, - "jpeg_activities[AID0]": list(gpu_metrics.jpeg_activities)[:8], - "jpeg_activities[AID1]": list(gpu_metrics.jpeg_activities)[8:16], - "jpeg_activities[AID2]": list(gpu_metrics.jpeg_activities)[16:24], - "jpeg_activities[AID3]": list(gpu_metrics.jpeg_activities)[24:32], + "jpeg_activity": list(gpu_metrics.jpeg_activity), } diff --git a/py-interface/amdsmi_wrapper.py b/py-interface/amdsmi_wrapper.py index c0047ff1be..d7836d1316 100644 --- a/py-interface/amdsmi_wrapper.py +++ b/py-interface/amdsmi_wrapper.py @@ -906,7 +906,6 @@ amdsmi_clk_info_t = struct_amdsmi_clk_info_t class struct_amdsmi_engine_usage_t(Structure): pass - struct_amdsmi_engine_usage_t._pack_ = 1 # source:False struct_amdsmi_engine_usage_t._fields_ = [ ('gfx_activity', ctypes.c_uint32), @@ -920,6 +919,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 @@ -931,16 +940,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), @@ -1527,11 +1526,12 @@ struct_amdsmi_gpu_metrics_t._fields_ = [ ('current_socclks', ctypes.c_uint16 * 4), ('current_vclk0s', ctypes.c_uint16 * 4), ('current_dclk0s', ctypes.c_uint16 * 4), + ('jpeg_activity', ctypes.c_uint16 * 32), ('mem_bandwidth_acc', ctypes.c_uint64), ('mem_max_bandwidth', ctypes.c_uint32), ('pcie_nak_sent_count_acc', ctypes.c_uint32), ('pcie_nak_rcvd_count_acc', ctypes.c_uint32), - ('jpeg_activities', ctypes.c_uint16 * 32), + ('PADDING_4', ctypes.c_ubyte * 4), ] amdsmi_gpu_metrics_t = struct_amdsmi_gpu_metrics_t diff --git a/rocm_smi/src/rocm_smi_gpu_metrics.cc b/rocm_smi/src/rocm_smi_gpu_metrics.cc index 2887d3021f..b92b8d542b 100755 --- a/rocm_smi/src/rocm_smi_gpu_metrics.cc +++ b/rocm_smi/src/rocm_smi_gpu_metrics.cc @@ -1413,7 +1413,7 @@ AMGpuMetricsPublicLatestTupl_t GpuMetricsBase_v13_t::copy_internal_to_external_m metrics_public_init.average_mm_activity = m_gpu_metrics_tbl.m_average_mm_activity; // Power/Energy - // metrics_public_init.average_socket_power = m_gpu_metrics_tbl.m_average_socket_power; // 1.3 and 1.4 have the same value + metrics_public_init.average_socket_power = m_gpu_metrics_tbl.m_average_socket_power; // 1.3 and 1.4 have the same value metrics_public_init.energy_accumulator = m_gpu_metrics_tbl.m_energy_accumulator; // Driver attached timestamp (in ns) diff --git a/update_wrapper.sh b/update_wrapper.sh index d6557d92c0..918158dec4 100755 --- a/update_wrapper.sh +++ b/update_wrapper.sh @@ -27,7 +27,7 @@ if ! does_image_exist; then # docker pull dmitriigalantsev/amdsmi_wrapper_updater echo "No docker image found! Generating one" # set to 0 because it's compatible with more systems - DOCKER_BUILDKIT="${DOCKER_BUILDKIT:0}" docker build "$DIR/py-interface" -t "$DOCKER_NAME":latest + DOCKER_BUILDKIT="${DOCKER_BUILDKIT:=0}" docker build "$DIR/py-interface" -t "$DOCKER_NAME":latest fi ENABLE_ESMI_LIB="" From 9f3a6dbd29740a3ec5e1fd78f767ec6b90bfc934 Mon Sep 17 00:00:00 2001 From: Deepak Mewar Date: Wed, 27 Dec 2023 10:13:35 -0500 Subject: [PATCH 05/22] amdsmi library and sample code updated for amdsmi_get_metrics_table Change-Id: Ie03c556f5c38fe4a0365743d3a94220e3aa62b23 --- example/amdsmi_esmi_intg_example.cc | 124 ++++++++++++++++++---------- include/amd_smi/amdsmi.h | 84 ++++++++++++++++++- src/amd_smi/amd_smi.cc | 6 +- 3 files changed, 168 insertions(+), 46 deletions(-) diff --git a/example/amdsmi_esmi_intg_example.cc b/example/amdsmi_esmi_intg_example.cc index da83dd868d..376d8ababb 100644 --- a/example/amdsmi_esmi_intg_example.cc +++ b/example/amdsmi_esmi_intg_example.cc @@ -86,51 +86,57 @@ int main(int argc, char **argv) { // Get all sockets uint32_t socket_count = 0; - /*ret = amdsmi_get_cpusocket_handles(&socket_count, nullptr); - CHK_AMDSMI_RET(ret) - - // Allocate the memory for the sockets - vector sockets(socket_count); - - // Get the sockets of the system - ret = amdsmi_get_cpusocket_handles(&socket_count, &sockets[0]); - CHK_AMDSMI_RET(ret)*/ ret = amdsmi_get_socket_handles(&socket_count, nullptr); CHK_AMDSMI_RET(ret) + // Allocate the memory for the sockets vector sockets(socket_count); + // Get the sockets of the system ret = amdsmi_get_socket_handles(&socket_count, &sockets[0]); CHK_AMDSMI_RET(ret) + cout << "Total Socket: " << socket_count << endl; - // For each socket, get identifier and cores - for (uint8_t i = 0; i < socket_count; i++) { + + // For each socket, get cpus and cores + for (uint32_t i = 0; i < socket_count; i++) { + cout << endl << "Socket " << i << endl; uint32_t cpu_count = 0; uint32_t core_count = 0; + + // Set processor type as AMD_CPU processor_type_t processor_type = AMD_CPU; ret = amdsmi_get_processor_handles_by_type(sockets[i], processor_type, nullptr, &cpu_count); CHK_AMDSMI_RET(ret) + + // Allocate the memory for the cpus vector plist(cpu_count); + + // Get the cpus for each socket ret = amdsmi_get_processor_handles_by_type(sockets[i], processor_type, &plist[0], &cpu_count); CHK_AMDSMI_RET(ret) - cout << endl; - // Read core count for each sockets + + // Set processor type as AMD_CPU_CORE processor_type = AMD_CPU_CORE; ret = amdsmi_get_processor_handles_by_type(sockets[i], processor_type, nullptr, &core_count); CHK_AMDSMI_RET(ret) + + // Allocate the memory for the cpu cores vector core_list(core_count); + + // Get the cpu cores for each socket ret = amdsmi_get_processor_handles_by_type(sockets[i], processor_type, &core_list[0], &core_count); CHK_AMDSMI_RET(ret) - for (int index = 0; index < plist.size(); index++) { - socket_count = plist.size(); - ret = amdsmi_get_cpu_hsmp_proto_ver(plist[i], &proto_ver); + + for (uint32_t index = 0; index < plist.size(); index++) { + ret = amdsmi_get_cpu_hsmp_proto_ver(plist[index], &proto_ver); CHK_AMDSMI_RET(ret) cout<<"\n------------------------------------------"; cout<<"\n| HSMP Proto Version | "<< proto_ver <<"\t\t |"<< endl; cout<<"------------------------------------------\n"; - ret = amdsmi_get_cpu_smu_fw_version(plist[i], &smu_fw); + ret = amdsmi_get_cpu_smu_fw_version(plist[index], &smu_fw); CHK_AMDSMI_RET(ret) cout<<"\n------------------------------------------"; @@ -144,14 +150,10 @@ int main(int argc, char **argv) { uint32_t err_bits = 0; uint32_t prochot; - cout<<"\n-------------------------------------------------"; - cout<<"\n| Sensor Name\t\t\t |"; - for (uint32_t i = 0; i < socket_count; i++) { - cout<>input_power; - ret = amdsmi_get_cpu_socket_power_cap_max(plist[i], &power_max); + ret = amdsmi_get_cpu_socket_power_cap_max(plist[index], &power_max); CHK_AMDSMI_RET(ret) if ((ret == AMDSMI_STATUS_SUCCESS) && (input_power > power_max)) { cout<<"Input power is more than max power limit," " limiting to "<(power_max)/1000<<"Watts\n"; input_power = power_max; } - ret = amdsmi_set_cpu_socket_power_cap(plist[i], input_power); + ret = amdsmi_set_cpu_socket_power_cap(plist[index], input_power); CHK_AMDSMI_RET(ret) if (!ret) { - cout<<"Socket["<(input_power)/1000<<" Watts successfully\n"; } + + power_limit = 0; + cout<<"\n| PowerLimit (Watts) \t\t | "; + ret = amdsmi_get_cpu_socket_power_cap(plist[index], &power_limit); + CHK_AMDSMI_RET(ret) + + if (!ret) { + cout<(power_limit)/1000<<"\t|"; + } else { + err_bits |= 1 << ret; + cout<<" NA (Err:" <(esmi_metrics_table_get(sock_ind, &metrics_tbl)); - *metrics_table = metrics_tbl; - if (status != AMDSMI_STATUS_SUCCESS) return status; + std::memcpy(metrics_table, &metrics_tbl, sizeof(amdsmi_hsmp_metric_table_t)); + return AMDSMI_STATUS_SUCCESS; } From 4ecf25e8826c7192326ada7d7e2c749986c024f7 Mon Sep 17 00:00:00 2001 From: Deepak Mewar Date: Wed, 27 Dec 2023 10:27:09 -0500 Subject: [PATCH 06/22] amdsmi wrapper generated for updated amdsmi_get_metrics_table Change-Id: Id55a5647064998d8f546c806f857a8745afe52ea --- py-interface/amdsmi_wrapper.py | 86 ++++++++++++++++++++++++++++++---- 1 file changed, 77 insertions(+), 9 deletions(-) diff --git a/py-interface/amdsmi_wrapper.py b/py-interface/amdsmi_wrapper.py index d7836d1316..7e6c421905 100644 --- a/py-interface/amdsmi_wrapper.py +++ b/py-interface/amdsmi_wrapper.py @@ -1717,6 +1717,75 @@ struct_amdsmi_dpm_level_t._fields_ = [ ] amdsmi_dpm_level_t = struct_amdsmi_dpm_level_t +class struct_amdsmi_hsmp_metric_table_t(Structure): + pass + +struct_amdsmi_hsmp_metric_table_t._pack_ = 1 # source:False +struct_amdsmi_hsmp_metric_table_t._fields_ = [ + ('accumulation_counter', ctypes.c_uint32), + ('max_socket_temperature', ctypes.c_uint32), + ('max_vr_temperature', ctypes.c_uint32), + ('max_hbm_temperature', ctypes.c_uint32), + ('max_socket_temperature_acc', ctypes.c_uint64), + ('max_vr_temperature_acc', ctypes.c_uint64), + ('max_hbm_temperature_acc', ctypes.c_uint64), + ('socket_power_limit', ctypes.c_uint32), + ('max_socket_power_limit', ctypes.c_uint32), + ('socket_power', ctypes.c_uint32), + ('PADDING_0', ctypes.c_ubyte * 4), + ('timestamp', ctypes.c_uint64), + ('socket_energy_acc', ctypes.c_uint64), + ('ccd_energy_acc', ctypes.c_uint64), + ('xcd_energy_acc', ctypes.c_uint64), + ('aid_energy_acc', ctypes.c_uint64), + ('hbm_energy_acc', ctypes.c_uint64), + ('cclk_frequency_limit', ctypes.c_uint32), + ('gfxclk_frequency_limit', ctypes.c_uint32), + ('fclk_frequency', ctypes.c_uint32), + ('uclk_frequency', ctypes.c_uint32), + ('socclk_frequency', ctypes.c_uint32 * 4), + ('vclk_frequency', ctypes.c_uint32 * 4), + ('dclk_frequency', ctypes.c_uint32 * 4), + ('lclk_frequency', ctypes.c_uint32 * 4), + ('gfxclk_frequency_acc', ctypes.c_uint64 * 8), + ('cclk_frequency_acc', ctypes.c_uint64 * 96), + ('max_cclk_frequency', ctypes.c_uint32), + ('min_cclk_frequency', ctypes.c_uint32), + ('max_gfxclk_frequency', ctypes.c_uint32), + ('min_gfxclk_frequency', ctypes.c_uint32), + ('fclk_frequency_table', ctypes.c_uint32 * 4), + ('uclk_frequency_table', ctypes.c_uint32 * 4), + ('socclk_frequency_table', ctypes.c_uint32 * 4), + ('vclk_frequency_table', ctypes.c_uint32 * 4), + ('dclk_frequency_table', ctypes.c_uint32 * 4), + ('lclk_frequency_table', ctypes.c_uint32 * 4), + ('max_lclk_dpm_range', ctypes.c_uint32), + ('min_lclk_dpm_range', ctypes.c_uint32), + ('xgmi_width', ctypes.c_uint32), + ('xgmi_bitrate', ctypes.c_uint32), + ('xgmi_read_bandwidth_acc', ctypes.c_uint64 * 8), + ('xgmi_write_bandwidth_acc', ctypes.c_uint64 * 8), + ('socket_c0_residency', ctypes.c_uint32), + ('socket_gfx_busy', ctypes.c_uint32), + ('dram_bandwidth_utilization', ctypes.c_uint32), + ('PADDING_1', ctypes.c_ubyte * 4), + ('socket_c0_residency_acc', ctypes.c_uint64), + ('socket_gfx_busy_acc', ctypes.c_uint64), + ('dram_bandwidth_acc', ctypes.c_uint64), + ('max_dram_bandwidth', ctypes.c_uint32), + ('PADDING_2', ctypes.c_ubyte * 4), + ('dram_bandwidth_utilization_acc', ctypes.c_uint64), + ('pcie_bandwidth_acc', ctypes.c_uint64 * 4), + ('prochot_residency_acc', ctypes.c_uint32), + ('ppt_residency_acc', ctypes.c_uint32), + ('socket_thm_residency_acc', ctypes.c_uint32), + ('vr_thm_residency_acc', ctypes.c_uint32), + ('hbm_thm_residency_acc', ctypes.c_uint32), + ('spare', ctypes.c_uint32), + ('gfxclk_frequency', ctypes.c_uint32 * 8), +] + +amdsmi_hsmp_metric_table_t = struct_amdsmi_hsmp_metric_table_t uint64_t = ctypes.c_uint64 amdsmi_init = _libraries['libamd_smi.so'].amdsmi_init amdsmi_init.restype = amdsmi_status_t @@ -2326,12 +2395,9 @@ amdsmi_get_cpu_current_xgmi_bw.argtypes = [amdsmi_processor_handle, amdsmi_link_ amdsmi_get_metrics_table_version = _libraries['libamd_smi.so'].amdsmi_get_metrics_table_version amdsmi_get_metrics_table_version.restype = amdsmi_status_t amdsmi_get_metrics_table_version.argtypes = [amdsmi_processor_handle, ctypes.POINTER(ctypes.c_uint32)] -class struct_hsmp_metric_table(Structure): - pass - amdsmi_get_metrics_table = _libraries['libamd_smi.so'].amdsmi_get_metrics_table amdsmi_get_metrics_table.restype = amdsmi_status_t -amdsmi_get_metrics_table.argtypes = [amdsmi_processor_handle, ctypes.POINTER(struct_hsmp_metric_table)] +amdsmi_get_metrics_table.argtypes = [amdsmi_processor_handle, ctypes.POINTER(struct_amdsmi_hsmp_metric_table_t)] amdsmi_first_online_core_on_cpu_socket = _libraries['libamd_smi.so'].amdsmi_first_online_core_on_cpu_socket amdsmi_first_online_core_on_cpu_socket.restype = amdsmi_status_t amdsmi_first_online_core_on_cpu_socket.argtypes = [amdsmi_processor_handle, ctypes.POINTER(ctypes.c_uint32)] @@ -2646,9 +2712,10 @@ __all__ = \ 'amdsmi_gpu_counter_group_supported', 'amdsmi_gpu_create_counter', 'amdsmi_gpu_destroy_counter', 'amdsmi_gpu_metrics_t', 'amdsmi_gpu_read_counter', 'amdsmi_gpu_xgmi_error_status', - 'amdsmi_init', 'amdsmi_init_flags_t', - 'amdsmi_init_gpu_event_notification', 'amdsmi_io_bw_encoding_t', - 'amdsmi_io_link_type_t', 'amdsmi_is_P2P_accessible', + 'amdsmi_hsmp_metric_table_t', 'amdsmi_init', + 'amdsmi_init_flags_t', 'amdsmi_init_gpu_event_notification', + 'amdsmi_io_bw_encoding_t', 'amdsmi_io_link_type_t', + 'amdsmi_is_P2P_accessible', 'amdsmi_is_gpu_power_management_enabled', 'amdsmi_link_id_bw_type_t', 'amdsmi_memory_page_status_t', 'amdsmi_memory_partition_type_t', 'amdsmi_memory_type_t', @@ -2708,6 +2775,7 @@ __all__ = \ 'struct_amdsmi_freq_volt_region_t', 'struct_amdsmi_frequencies_t', 'struct_amdsmi_frequency_range_t', 'struct_amdsmi_fw_info_t', 'struct_amdsmi_gpu_cache_info_t', 'struct_amdsmi_gpu_metrics_t', + 'struct_amdsmi_hsmp_metric_table_t', 'struct_amdsmi_link_id_bw_type_t', 'struct_amdsmi_name_value_t', 'struct_amdsmi_od_vddc_point_t', 'struct_amdsmi_od_volt_curve_t', 'struct_amdsmi_od_volt_freq_data_t', @@ -2724,5 +2792,5 @@ __all__ = \ 'struct_amdsmi_vram_info_t', 'struct_amdsmi_vram_usage_t', 'struct_amdsmi_xgmi_info_t', 'struct_cache_', 'struct_engine_usage_', 'struct_fields_', 'struct_fw_info_list_', - 'struct_hsmp_metric_table', 'struct_memory_usage_', 'uint32_t', - 'uint64_t', 'uint8_t', 'union_amdsmi_bdf_t'] + 'struct_memory_usage_', 'uint32_t', 'uint64_t', 'uint8_t', + 'union_amdsmi_bdf_t'] From 31dc8d0ee81ded4e1852d15a8890db26f0e733c0 Mon Sep 17 00:00:00 2001 From: Deepak Mewar Date: Thu, 28 Dec 2023 01:46:33 -0500 Subject: [PATCH 07/22] amdsmi interface updated for amdsmi_get_metrics_table Change-Id: I0618dd411caf6d30f74793e937984273f9c5b70e --- py-interface/amdsmi_interface.py | 34 ++++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/py-interface/amdsmi_interface.py b/py-interface/amdsmi_interface.py index 01743641ed..6552b95e05 100644 --- a/py-interface/amdsmi_interface.py +++ b/py-interface/amdsmi_interface.py @@ -1356,7 +1356,7 @@ def amdsmi_get_metrics_table( processor_handle, amdsmi_wrapper.amdsmi_processor_handle ) - mtbl = amdsmi_wrapper.struct_hsmp_metric_table() + mtbl = amdsmi_wrapper.amdsmi_hsmp_metric_table_t() _check_res(amdsmi_wrapper.amdsmi_get_metrics_table(processor_handle, mtbl)) @@ -1381,19 +1381,19 @@ def amdsmi_get_metrics_table( "mtbl_gfxclk_frequency_limit": mtbl.gfxclk_frequency_limit, "mtbl_fclk_frequency": mtbl.fclk_frequency, "mtbl_uclk_frequency": mtbl.uclk_frequency, - "mtbl_socclk_frequency": mtbl.socclk_frequency, - "mtbl_vclk_frequency": mtbl.vclk_frequency, - "mtbl_dclk_frequency": mtbl.dclk_frequency, - "mtbl_lclk_frequency": mtbl.lclk_frequency, - "mtbl_fclk_frequency_table": mtbl.fclk_frequency_table, - "mtbl_uclk_frequency_table": mtbl.uclk_frequency_table, - "mtbl_socclk_frequency_table": mtbl.socclk_frequency_table, - "mtbl_vclk_frequency_table": mtbl.vclk_frequency_table, - "mtbl_dclk_frequency_table": mtbl.dclk_frequency_table, - "mtbl_lclk_frequency_table": mtbl.lclk_frequency_table, - "mtbl_cclk_frequency_acc": mtbl.cclk_frequency_acc, - "mtbl_gfxclk_frequency_acc": mtbl.gfxclk_frequency_acc, - "mtbl_gfxclk_frequency": mtbl.gfxclk_frequency, + "mtbl_socclk_frequency": list(mtbl.socclk_frequency), + "mtbl_vclk_frequency": list(mtbl.vclk_frequency), + "mtbl_dclk_frequency": list(mtbl.dclk_frequency), + "mtbl_lclk_frequency": list(mtbl.lclk_frequency), + "mtbl_fclk_frequency_table": list(mtbl.fclk_frequency_table), + "mtbl_uclk_frequency_table": list(mtbl.uclk_frequency_table), + "mtbl_socclk_frequency_table": list(mtbl.socclk_frequency_table), + "mtbl_vclk_frequency_table": list(mtbl.vclk_frequency_table), + "mtbl_dclk_frequency_table": list(mtbl.dclk_frequency_table), + "mtbl_lclk_frequency_table": list(mtbl.lclk_frequency_table), + "mtbl_cclk_frequency_acc": list(mtbl.cclk_frequency_acc), + "mtbl_gfxclk_frequency_acc": list(mtbl.gfxclk_frequency_acc), + "mtbl_gfxclk_frequency": list(mtbl.gfxclk_frequency), "mtbl_max_cclk_frequency": mtbl.max_cclk_frequency, "mtbl_min_cclk_frequency": mtbl.min_cclk_frequency, "mtbl_max_gfxclk_frequency": mtbl.max_gfxclk_frequency, @@ -1402,8 +1402,8 @@ def amdsmi_get_metrics_table( "mtbl_min_lclk_dpm_range": mtbl.min_lclk_dpm_range, "mtbl_xgmi_width": mtbl.xgmi_width, "mtbl_xgmi_bitrate": mtbl.xgmi_bitrate, - "mtbl_xgmi_read_bandwidth_acc": mtbl.xgmi_read_bandwidth_acc, - "mtbl_xgmi_write_bandwidth_acc": mtbl.xgmi_write_bandwidth_acc, + "mtbl_xgmi_read_bandwidth_acc": list(mtbl.xgmi_read_bandwidth_acc), + "mtbl_xgmi_write_bandwidth_acc": list(mtbl.xgmi_write_bandwidth_acc), "mtbl_socket_c0_residency": mtbl.socket_c0_residency, "mtbl_socket_gfx_busy": mtbl.socket_gfx_busy, "mtbl_dram_bandwidth_utilization": mtbl.dram_bandwidth_utilization, @@ -1412,7 +1412,7 @@ def amdsmi_get_metrics_table( "mtbl_dram_bandwidth_acc": mtbl.dram_bandwidth_acc, "mtbl_max_dram_bandwidth": mtbl.max_dram_bandwidth, "mtbl_dram_bandwidth_utilization_acc": mtbl.dram_bandwidth_utilization_acc, - "mtbl_pcie_bandwidth_acc": mtbl.pcie_bandwidth_acc, + "mtbl_pcie_bandwidth_acc": list(mtbl.pcie_bandwidth_acc), "mtbl_prochot_residency_acc": mtbl.prochot_residency_acc, "mtbl_ppt_residency_acc": mtbl.ppt_residency_acc, "mtbl_socket_thm_residency_acc": mtbl.socket_thm_residency_acc, From 087a0d3ead21d62831bef76baaaead76c537e59c Mon Sep 17 00:00:00 2001 From: khashaik Date: Mon, 1 Jan 2024 02:46:16 -0500 Subject: [PATCH 08/22] amdsmi_cli: Fix issues in "cpu_enable_apb" API Change-Id: I8237fb4641f1a6aecec815fdc020abbf9a3195ba --- amdsmi_cli/amdsmi_commands.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/amdsmi_cli/amdsmi_commands.py b/amdsmi_cli/amdsmi_commands.py index 487531b6cb..cb830de331 100644 --- a/amdsmi_cli/amdsmi_commands.py +++ b/amdsmi_cli/amdsmi_commands.py @@ -1722,7 +1722,7 @@ class AMDSMICommands(): "socket_energy", "set_cpu_pwr_eff_mode", "cpu_ddr_bandwidth", "cpu_temp", "cpu_dimm_temp_range_rate", "cpu_dimm_pow_conumption", "cpu_dimm_thermal_sensor", "set_cpu_gmi3_link_width", "set_cpu_pcie_lnk_rate", - "set_cpu_df_pstate_range"] + "set_cpu_df_pstate_range", "cpu_enable_apb"] curr_platform_cpu_values = [args.cpu_power_metrics, args.cpu_prochot, args.cpu_freq_metrics, args.cpu_c0_res, args.cpu_lclk_dpm_level, args.cpu_pwr_svi_telemtry_rails, args.cpu_io_bandwidth, args.cpu_xgmi_bandwidth, args.cpu_disable_apb, @@ -1731,7 +1731,7 @@ class AMDSMICommands(): args.socket_energy, args.set_cpu_pwr_eff_mode, args.cpu_ddr_bandwidth, args.cpu_temp, args.cpu_dimm_temp_range_rate, args.cpu_dimm_pow_conumption, args.cpu_dimm_thermal_sensor, args.set_cpu_gmi3_link_width, args.set_cpu_pcie_lnk_rate, - args.set_cpu_df_pstate_range] + args.set_cpu_df_pstate_range, args.cpu_enable_apb] # Handle No CPU passed @@ -1744,7 +1744,8 @@ class AMDSMICommands(): "set_cpu_pow_limit", "set_cpu_xgmi_link_width", "set_cpu_lclk_dpm_level", "set_soc_boost_limit", "set_cpu_pwr_eff_mode", "cpu_dimm_temp_range_rate", "cpu_dimm_temp_range_rate", "cpu_dimm_pow_conumption", "cpu_dimm_thermal_sensor", - "set_cpu_gmi3_link_width", "set_cpu_pcie_lnk_rate", "set_cpu_df_pstate_range"): + "set_cpu_gmi3_link_width", "set_cpu_pcie_lnk_rate", "set_cpu_df_pstate_range", + "cpu_enable_apb"): setattr(args, arg, True) if (len(self.cpu_handles)): From 1b1591571bfb0ab17655bded6c68566ba40670a8 Mon Sep 17 00:00:00 2001 From: Deepak Mewar Date: Mon, 1 Jan 2024 09:21:38 -0500 Subject: [PATCH 09/22] amdsmi interface updated for amdsmi_get_metrics_table encodings Change-Id: Iffed4071d5b2b5645f8118f3fbce26ab258e7882 --- py-interface/amdsmi_interface.py | 136 ++++++++++++++++++++----------- 1 file changed, 87 insertions(+), 49 deletions(-) diff --git a/py-interface/amdsmi_interface.py b/py-interface/amdsmi_interface.py index 6552b95e05..c3e6400683 100644 --- a/py-interface/amdsmi_interface.py +++ b/py-interface/amdsmi_interface.py @@ -27,6 +27,8 @@ from collections.abc import Iterable from . import amdsmi_wrapper from .amdsmi_exception import * +import sys +import math MAX_NUM_PROCESSES = 1024 @@ -1348,6 +1350,33 @@ def amdsmi_get_metrics_table_version( return metric_tbl_version.value + +NO_OF_32BITS = (sys.getsizeof(ctypes.c_uint32) * 8) +NO_OF_64BITS = (sys.getsizeof(ctypes.c_uint64) * 8) +KILO = math.pow(10, 3) + +# Get 2's complement of 32 bit unsigned integer +def check_msb_32(num): + msb = 1 << (NO_OF_32BITS - 1) + + '''If msb = 1 , then take 2's complement of the number''' + if num & msb: + num = ~num + 1 + return num + else: + return num + +# Get 2's complement of 64 bit unsigned integer +def check_msb_64(num): + msb = 1 << (NO_OF_64BITS - 1) + + '''If msb = 1 , then take 2's complement of the number''' + if num & msb: + num = ~num + 1 + return num + else: + return num + def amdsmi_get_metrics_table( processor_handle: amdsmi_wrapper.amdsmi_processor_handle ): @@ -1358,61 +1387,70 @@ def amdsmi_get_metrics_table( mtbl = amdsmi_wrapper.amdsmi_hsmp_metric_table_t() - _check_res(amdsmi_wrapper.amdsmi_get_metrics_table(processor_handle, mtbl)) + '''Encodings for the metric table defined for hsmp''' + fraction_q10 = 1 / math.pow(2, 10) + fraction_uq10 = fraction_q10 + fraction_uq16 = 1 / math.pow(2, 16) + + _check_res( + amdsmi_wrapper.amdsmi_get_metrics_table( + processor_handle, mtbl + ) + ) return { "mtbl_accumulation_counter": mtbl.accumulation_counter, - "mtbl_max_socket_temperature": mtbl.max_socket_temperature, - "mtbl_max_vr_temperature": mtbl.max_vr_temperature, - "mtbl_max_hbm_temperature": mtbl.max_hbm_temperature, - "mtbl_max_socket_temperature_acc": mtbl.max_socket_temperature_acc, - "mtbl_max_vr_temperature_acc": mtbl.max_vr_temperature_acc, - "mtbl_max_hbm_temperature_acc": mtbl.max_hbm_temperature_acc, - "mtbl_socket_power_limit": mtbl.socket_power_limit, - "mtbl_max_socket_power_limit": mtbl.max_socket_power_limit, - "mtbl_socket_power": mtbl.socket_power, + "mtbl_max_socket_temperature": round(check_msb_32(mtbl.max_socket_temperature) * fraction_q10 ,3), + "mtbl_max_vr_temperature": round(check_msb_32(mtbl.max_vr_temperature) * fraction_q10 ,3), + "mtbl_max_hbm_temperature": round(check_msb_32(mtbl.max_hbm_temperature) * fraction_q10 ,3), + "mtbl_max_socket_temperature_acc": round(check_msb_64(mtbl.max_socket_temperature_acc) * fraction_q10 ,3) , + "mtbl_max_vr_temperature_acc": round(check_msb_64(mtbl.max_vr_temperature_acc) * fraction_q10 ,3), + "mtbl_max_hbm_temperature_acc": round(check_msb_64(mtbl.max_hbm_temperature_acc) * fraction_q10 ,3), + "mtbl_socket_power_limit": round(mtbl.socket_power_limit * fraction_uq10 ,3), + "mtbl_max_socket_power_limit": round(mtbl.max_socket_power_limit * fraction_uq10 ,3), + "mtbl_socket_power": round(mtbl.socket_power * fraction_uq10 ,3), "mtbl_timestamp": mtbl.timestamp, - "mtbl_socket_energy_acc": mtbl.socket_energy_acc, - "mtbl_ccd_energy_acc": mtbl.ccd_energy_acc, - "mtbl_xcd_energy_acc": mtbl.xcd_energy_acc, - "mtbl_aid_energy_acc": mtbl.aid_energy_acc, - "mtbl_hbm_energy_acc": mtbl.hbm_energy_acc, - "mtbl_cclk_frequency_limit": mtbl.cclk_frequency_limit, - "mtbl_gfxclk_frequency_limit": mtbl.gfxclk_frequency_limit, - "mtbl_fclk_frequency": mtbl.fclk_frequency, - "mtbl_uclk_frequency": mtbl.uclk_frequency, - "mtbl_socclk_frequency": list(mtbl.socclk_frequency), - "mtbl_vclk_frequency": list(mtbl.vclk_frequency), - "mtbl_dclk_frequency": list(mtbl.dclk_frequency), - "mtbl_lclk_frequency": list(mtbl.lclk_frequency), - "mtbl_fclk_frequency_table": list(mtbl.fclk_frequency_table), - "mtbl_uclk_frequency_table": list(mtbl.uclk_frequency_table), - "mtbl_socclk_frequency_table": list(mtbl.socclk_frequency_table), - "mtbl_vclk_frequency_table": list(mtbl.vclk_frequency_table), - "mtbl_dclk_frequency_table": list(mtbl.dclk_frequency_table), - "mtbl_lclk_frequency_table": list(mtbl.lclk_frequency_table), - "mtbl_cclk_frequency_acc": list(mtbl.cclk_frequency_acc), - "mtbl_gfxclk_frequency_acc": list(mtbl.gfxclk_frequency_acc), - "mtbl_gfxclk_frequency": list(mtbl.gfxclk_frequency), - "mtbl_max_cclk_frequency": mtbl.max_cclk_frequency, - "mtbl_min_cclk_frequency": mtbl.min_cclk_frequency, - "mtbl_max_gfxclk_frequency": mtbl.max_gfxclk_frequency, - "mtbl_min_gfxclk_frequency": mtbl.min_gfxclk_frequency, + "mtbl_socket_energy_acc": round((mtbl.socket_energy_acc * fraction_uq16)/KILO ,3), + "mtbl_ccd_energy_acc": round((mtbl.ccd_energy_acc * fraction_uq16)/KILO ,3), + "mtbl_xcd_energy_acc": round((mtbl.xcd_energy_acc * fraction_uq16)/KILO ,3), + "mtbl_aid_energy_acc": round((mtbl.aid_energy_acc * fraction_uq16)/KILO ,3), + "mtbl_hbm_energy_acc": round((mtbl.hbm_energy_acc * fraction_uq16)/KILO ,3), + "mtbl_cclk_frequency_limit": round(mtbl.cclk_frequency_limit * fraction_uq10 ,3), + "mtbl_gfxclk_frequency_limit": round(mtbl.gfxclk_frequency_limit * fraction_uq10 ,3), + "mtbl_fclk_frequency": round(mtbl.fclk_frequency * fraction_uq10 ,3), + "mtbl_uclk_frequency": round(mtbl.uclk_frequency * fraction_uq10 ,3), + "mtbl_socclk_frequency": [round(x*fraction_uq10 ,3) for x in list(mtbl.socclk_frequency)], + "mtbl_vclk_frequency": [round(x*fraction_uq10 ,3) for x in list(mtbl.vclk_frequency)], + "mtbl_dclk_frequency": [round(x*fraction_uq10 ,3) for x in list(mtbl.dclk_frequency)], + "mtbl_lclk_frequency": [round(x*fraction_uq10 ,3) for x in list(mtbl.lclk_frequency)], + "mtbl_fclk_frequency_table": [round(x*fraction_uq10 ,3) for x in list(mtbl.fclk_frequency_table)], + "mtbl_uclk_frequency_table": [round(x*fraction_uq10 ,3) for x in list(mtbl.uclk_frequency_table)], + "mtbl_socclk_frequency_table": [round(x*fraction_uq10 ,3) for x in list(mtbl.socclk_frequency_table)], + "mtbl_vclk_frequency_table": [round(x*fraction_uq10 ,3) for x in list(mtbl.vclk_frequency_table)], + "mtbl_dclk_frequency_table": [round(x*fraction_uq10 ,3) for x in list(mtbl.dclk_frequency_table)], + "mtbl_lclk_frequency_table": [round(x*fraction_uq10 ,3) for x in list(mtbl.lclk_frequency_table)], + "mtbl_cclk_frequency_acc": [round(x*fraction_uq10 ,3) for x in list(mtbl.cclk_frequency_acc)], + "mtbl_gfxclk_frequency_acc": [round(x*fraction_uq10 ,3) for x in list(mtbl.gfxclk_frequency_acc)], + "mtbl_gfxclk_frequency": [round(x*fraction_uq10 ,3) for x in list(mtbl.gfxclk_frequency)], + "mtbl_max_cclk_frequency": round(mtbl.max_cclk_frequency * fraction_uq10 ,3), + "mtbl_min_cclk_frequency": round(mtbl.min_cclk_frequency * fraction_uq10 ,3), + "mtbl_max_gfxclk_frequency": round(mtbl.max_gfxclk_frequency * fraction_uq10 ,3), + "mtbl_min_gfxclk_frequency": round(mtbl.min_gfxclk_frequency * fraction_uq10 ,3), "mtbl_max_lclk_dpm_range": mtbl.max_lclk_dpm_range, "mtbl_min_lclk_dpm_range": mtbl.min_lclk_dpm_range, - "mtbl_xgmi_width": mtbl.xgmi_width, - "mtbl_xgmi_bitrate": mtbl.xgmi_bitrate, - "mtbl_xgmi_read_bandwidth_acc": list(mtbl.xgmi_read_bandwidth_acc), - "mtbl_xgmi_write_bandwidth_acc": list(mtbl.xgmi_write_bandwidth_acc), - "mtbl_socket_c0_residency": mtbl.socket_c0_residency, - "mtbl_socket_gfx_busy": mtbl.socket_gfx_busy, - "mtbl_dram_bandwidth_utilization": mtbl.dram_bandwidth_utilization, - "mtbl_socket_c0_residency_acc": mtbl.socket_c0_residency_acc, - "mtbl_socket_gfx_busy_acc": mtbl.socket_gfx_busy_acc, - "mtbl_dram_bandwidth_acc": mtbl.dram_bandwidth_acc, - "mtbl_max_dram_bandwidth": mtbl.max_dram_bandwidth, - "mtbl_dram_bandwidth_utilization_acc": mtbl.dram_bandwidth_utilization_acc, - "mtbl_pcie_bandwidth_acc": list(mtbl.pcie_bandwidth_acc), + "mtbl_xgmi_width": round(mtbl.xgmi_width * fraction_uq10 ,3), + "mtbl_xgmi_bitrate": round(mtbl.xgmi_bitrate * fraction_uq10 ,3), + "mtbl_xgmi_read_bandwidth_acc": [round(x*fraction_uq10 ,3) for x in list(mtbl.xgmi_read_bandwidth_acc)], + "mtbl_xgmi_write_bandwidth_acc": [round(x*fraction_uq10 ,3) for x in list(mtbl.xgmi_write_bandwidth_acc)], + "mtbl_socket_c0_residency": round(mtbl.socket_c0_residency * fraction_uq10 ,3), + "mtbl_socket_gfx_busy": round(mtbl.socket_gfx_busy * fraction_uq10 ,3), + "mtbl_dram_bandwidth_utilization": round(mtbl.dram_bandwidth_utilization * fraction_uq10 ,3), + "mtbl_socket_c0_residency_acc": round(mtbl.socket_c0_residency_acc * fraction_uq10 ,3), + "mtbl_socket_gfx_busy_acc": round(mtbl.socket_gfx_busy_acc * fraction_uq10 ,3), + "mtbl_dram_bandwidth_acc": round(mtbl.dram_bandwidth_acc * fraction_uq10 ,3), + "mtbl_max_dram_bandwidth": round(mtbl.max_dram_bandwidth * fraction_uq10 ,3), + "mtbl_dram_bandwidth_utilization_acc": round(mtbl.dram_bandwidth_utilization_acc * fraction_uq10 ,3), + "mtbl_pcie_bandwidth_acc": [round(x*fraction_uq10 ,3) for x in list(mtbl.pcie_bandwidth_acc)], "mtbl_prochot_residency_acc": mtbl.prochot_residency_acc, "mtbl_ppt_residency_acc": mtbl.ppt_residency_acc, "mtbl_socket_thm_residency_acc": mtbl.socket_thm_residency_acc, From c74f01f401300a3bec6bcfe00b36ba903e75fd3c Mon Sep 17 00:00:00 2001 From: Deepak Mewar Date: Mon, 1 Jan 2024 09:25:21 -0500 Subject: [PATCH 10/22] amdsmi_cli: Enabled hsmp metric table from CLI Change-Id: I7f9c13255f952136438249f5180dec5586d01bd7 --- amdsmi_cli/amdsmi_commands.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/amdsmi_cli/amdsmi_commands.py b/amdsmi_cli/amdsmi_commands.py index cb830de331..73af73b420 100644 --- a/amdsmi_cli/amdsmi_commands.py +++ b/amdsmi_cli/amdsmi_commands.py @@ -1939,12 +1939,12 @@ class AMDSMICommands(): static_dict["metrics_table"]["response"] = "N/A" # Note:- amdsmi_get_metrics_table has been disabled as there is fix needed in the library API and will be # in next version - """try: + try: metrics_table = amdsmi_interface.amdsmi_get_metrics_table(args.cpu) static_dict["metrics_table"]["response"] = metrics_table except amdsmi_exception.AmdSmiLibraryException as e: static_dict["metrics_table"]["response"] = "N/A" - logging.debug("Failed to get metrics table for cpu %s | %s", cpu_id, e.get_error_info())""" + logging.debug("Failed to get metrics table for cpu %s | %s", cpu_id, e.get_error_info()) if (args.socket_energy): static_dict["socket_energy"] = {} From 256907989b0e5fe9bff42f73280acd7e54a0b11e Mon Sep 17 00:00:00 2001 From: khashaik Date: Tue, 2 Jan 2024 03:07:34 -0500 Subject: [PATCH 11/22] amdsmi_cli: Fix issues in cpu API "cpu_lclk_dpm_level" - Fix issues in cpu API "cpu_lclk_dpm_level" - Fix issue for invalid core id - Update the error message for invalid devices Change-Id: I71216ff72f89cfe0c86928ae3dce1f88eae91665 --- amdsmi_cli/amdsmi_cli_exceptions.py | 2 +- amdsmi_cli/amdsmi_helpers.py | 2 +- py-interface/amdsmi_interface.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/amdsmi_cli/amdsmi_cli_exceptions.py b/amdsmi_cli/amdsmi_cli_exceptions.py index e42fc9f9f2..c61e7d94bc 100644 --- a/amdsmi_cli/amdsmi_cli_exceptions.py +++ b/amdsmi_cli/amdsmi_cli_exceptions.py @@ -119,7 +119,7 @@ class AmdSmiDeviceNotFoundException(AmdSmiException): self.command = command self.output_format = outputformat - common_message = f"Can not find a GPU with the corresponding identifier: '{self.command}'" + common_message = f"Can not find a device with the corresponding identifier: '{self.command}'" self.json_message["error"] = common_message self.json_message["code"] = self.value diff --git a/amdsmi_cli/amdsmi_helpers.py b/amdsmi_cli/amdsmi_helpers.py index 91879e721c..23ec7ce58d 100644 --- a/amdsmi_cli/amdsmi_helpers.py +++ b/amdsmi_cli/amdsmi_helpers.py @@ -385,7 +385,7 @@ class AMDSMIHelpers(): selected_device_handles = [] for core_selection in core_selections: - valid_cpu_choice = False + valid_core_choice = False for core_id, core_info in core_choices.items(): device_handle = core_info['Device Handle'] diff --git a/py-interface/amdsmi_interface.py b/py-interface/amdsmi_interface.py index c3e6400683..a59d288fef 100644 --- a/py-interface/amdsmi_interface.py +++ b/py-interface/amdsmi_interface.py @@ -1246,8 +1246,8 @@ def amdsmi_get_cpu_socket_lclk_dpm_level( _check_res(amdsmi_wrapper.amdsmi_get_cpu_socket_lclk_dpm_level(processor_handle, nbio_id, dpm_level)) return { - "nbio_max_dpm_level": nbio.max_dpm_level, - "nbio_min_dpm_level": nbio.min_dpm_level + "nbio_max_dpm_level": dpm_level.max_dpm_level, + "nbio_min_dpm_level": dpm_level.min_dpm_level } def amdsmi_set_cpu_pcie_link_rate( From 898c4bc06fc9905b270a513a1d53cc1f4c809671 Mon Sep 17 00:00:00 2001 From: Deepak Mewar Date: Tue, 2 Jan 2024 07:47:01 -0500 Subject: [PATCH 12/22] amdsmi interface updated for amdsmi_get_metrics_table units Change-Id: If211292e894df9d832b879252bebf91c17112d14 --- py-interface/amdsmi_interface.py | 90 ++++++++++++++++---------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/py-interface/amdsmi_interface.py b/py-interface/amdsmi_interface.py index a59d288fef..9da07ad84f 100644 --- a/py-interface/amdsmi_interface.py +++ b/py-interface/amdsmi_interface.py @@ -1400,57 +1400,57 @@ def amdsmi_get_metrics_table( return { "mtbl_accumulation_counter": mtbl.accumulation_counter, - "mtbl_max_socket_temperature": round(check_msb_32(mtbl.max_socket_temperature) * fraction_q10 ,3), - "mtbl_max_vr_temperature": round(check_msb_32(mtbl.max_vr_temperature) * fraction_q10 ,3), - "mtbl_max_hbm_temperature": round(check_msb_32(mtbl.max_hbm_temperature) * fraction_q10 ,3), - "mtbl_max_socket_temperature_acc": round(check_msb_64(mtbl.max_socket_temperature_acc) * fraction_q10 ,3) , - "mtbl_max_vr_temperature_acc": round(check_msb_64(mtbl.max_vr_temperature_acc) * fraction_q10 ,3), - "mtbl_max_hbm_temperature_acc": round(check_msb_64(mtbl.max_hbm_temperature_acc) * fraction_q10 ,3), - "mtbl_socket_power_limit": round(mtbl.socket_power_limit * fraction_uq10 ,3), - "mtbl_max_socket_power_limit": round(mtbl.max_socket_power_limit * fraction_uq10 ,3), - "mtbl_socket_power": round(mtbl.socket_power * fraction_uq10 ,3), - "mtbl_timestamp": mtbl.timestamp, - "mtbl_socket_energy_acc": round((mtbl.socket_energy_acc * fraction_uq16)/KILO ,3), - "mtbl_ccd_energy_acc": round((mtbl.ccd_energy_acc * fraction_uq16)/KILO ,3), - "mtbl_xcd_energy_acc": round((mtbl.xcd_energy_acc * fraction_uq16)/KILO ,3), - "mtbl_aid_energy_acc": round((mtbl.aid_energy_acc * fraction_uq16)/KILO ,3), - "mtbl_hbm_energy_acc": round((mtbl.hbm_energy_acc * fraction_uq16)/KILO ,3), - "mtbl_cclk_frequency_limit": round(mtbl.cclk_frequency_limit * fraction_uq10 ,3), - "mtbl_gfxclk_frequency_limit": round(mtbl.gfxclk_frequency_limit * fraction_uq10 ,3), - "mtbl_fclk_frequency": round(mtbl.fclk_frequency * fraction_uq10 ,3), - "mtbl_uclk_frequency": round(mtbl.uclk_frequency * fraction_uq10 ,3), - "mtbl_socclk_frequency": [round(x*fraction_uq10 ,3) for x in list(mtbl.socclk_frequency)], - "mtbl_vclk_frequency": [round(x*fraction_uq10 ,3) for x in list(mtbl.vclk_frequency)], - "mtbl_dclk_frequency": [round(x*fraction_uq10 ,3) for x in list(mtbl.dclk_frequency)], - "mtbl_lclk_frequency": [round(x*fraction_uq10 ,3) for x in list(mtbl.lclk_frequency)], - "mtbl_fclk_frequency_table": [round(x*fraction_uq10 ,3) for x in list(mtbl.fclk_frequency_table)], - "mtbl_uclk_frequency_table": [round(x*fraction_uq10 ,3) for x in list(mtbl.uclk_frequency_table)], - "mtbl_socclk_frequency_table": [round(x*fraction_uq10 ,3) for x in list(mtbl.socclk_frequency_table)], - "mtbl_vclk_frequency_table": [round(x*fraction_uq10 ,3) for x in list(mtbl.vclk_frequency_table)], - "mtbl_dclk_frequency_table": [round(x*fraction_uq10 ,3) for x in list(mtbl.dclk_frequency_table)], - "mtbl_lclk_frequency_table": [round(x*fraction_uq10 ,3) for x in list(mtbl.lclk_frequency_table)], - "mtbl_cclk_frequency_acc": [round(x*fraction_uq10 ,3) for x in list(mtbl.cclk_frequency_acc)], - "mtbl_gfxclk_frequency_acc": [round(x*fraction_uq10 ,3) for x in list(mtbl.gfxclk_frequency_acc)], - "mtbl_gfxclk_frequency": [round(x*fraction_uq10 ,3) for x in list(mtbl.gfxclk_frequency)], - "mtbl_max_cclk_frequency": round(mtbl.max_cclk_frequency * fraction_uq10 ,3), - "mtbl_min_cclk_frequency": round(mtbl.min_cclk_frequency * fraction_uq10 ,3), - "mtbl_max_gfxclk_frequency": round(mtbl.max_gfxclk_frequency * fraction_uq10 ,3), - "mtbl_min_gfxclk_frequency": round(mtbl.min_gfxclk_frequency * fraction_uq10 ,3), + "mtbl_max_socket_temperature": f"{round(check_msb_32(mtbl.max_socket_temperature) * fraction_q10 ,3)} °C", + "mtbl_max_vr_temperature": f"{round(check_msb_32(mtbl.max_vr_temperature) * fraction_q10 ,3)} °C", + "mtbl_max_hbm_temperature": f"{round(check_msb_32(mtbl.max_hbm_temperature) * fraction_q10 ,3)} °C", + "mtbl_max_socket_temperature_acc": f"{round(check_msb_64(mtbl.max_socket_temperature_acc) * fraction_q10 ,3)} °C", + "mtbl_max_vr_temperature_acc": f"{round(check_msb_64(mtbl.max_vr_temperature_acc) * fraction_q10 ,3)} °C", + "mtbl_max_hbm_temperature_acc": f"{round(check_msb_64(mtbl.max_hbm_temperature_acc) * fraction_q10 ,3)} °C", + "mtbl_socket_power_limit": f"{round(mtbl.socket_power_limit * fraction_uq10 ,3)} W", + "mtbl_max_socket_power_limit": f"{round(mtbl.max_socket_power_limit * fraction_uq10 ,3)} W", + "mtbl_socket_power": f"{round(mtbl.socket_power * fraction_uq10 ,3)} W", + "mtbl_timestamp_raw": mtbl.timestamp, + "mtbl_socket_energy_acc": f"{round((mtbl.socket_energy_acc * fraction_uq16)/KILO ,3)} kJ", + "mtbl_ccd_energy_acc": f"{round((mtbl.ccd_energy_acc * fraction_uq16)/KILO ,3)} kJ", + "mtbl_xcd_energy_acc": f"{round((mtbl.xcd_energy_acc * fraction_uq16)/KILO ,3)} kJ", + "mtbl_aid_energy_acc": f"{round((mtbl.aid_energy_acc * fraction_uq16)/KILO ,3)} kJ", + "mtbl_hbm_energy_acc": f"{round((mtbl.hbm_energy_acc * fraction_uq16)/KILO ,3)} kJ", + "mtbl_cclk_frequency_limit": f"{round(mtbl.cclk_frequency_limit * fraction_uq10 ,3)} GHz", + "mtbl_gfxclk_frequency_limit": f"{round(mtbl.gfxclk_frequency_limit * fraction_uq10 ,3)} MHz", + "mtbl_fclk_frequency": f"{round(mtbl.fclk_frequency * fraction_uq10 ,3)} MHz", + "mtbl_uclk_frequency": f"{round(mtbl.uclk_frequency * fraction_uq10 ,3)} MHz", + "mtbl_socclk_frequency": f"{[round(x*fraction_uq10 ,3) for x in list(mtbl.socclk_frequency)]} MHz", + "mtbl_vclk_frequency": f"{[round(x*fraction_uq10 ,3) for x in list(mtbl.vclk_frequency)]} MHz", + "mtbl_dclk_frequency": f"{[round(x*fraction_uq10 ,3) for x in list(mtbl.dclk_frequency)]} MHz", + "mtbl_lclk_frequency": f"{[round(x*fraction_uq10 ,3) for x in list(mtbl.lclk_frequency)]} MHz", + "mtbl_fclk_frequency_table": f"{[round(x*fraction_uq10 ,3) for x in list(mtbl.fclk_frequency_table)]} MHz", + "mtbl_uclk_frequency_table": f"{[round(x*fraction_uq10 ,3) for x in list(mtbl.uclk_frequency_table)]} MHz", + "mtbl_socclk_frequency_table": f"{[round(x*fraction_uq10 ,3) for x in list(mtbl.socclk_frequency_table)]} MHz", + "mtbl_vclk_frequency_table": f"{[round(x*fraction_uq10 ,3) for x in list(mtbl.vclk_frequency_table)]} MHz", + "mtbl_dclk_frequency_table": f"{[round(x*fraction_uq10 ,3) for x in list(mtbl.dclk_frequency_table)]} MHz", + "mtbl_lclk_frequency_table": f"{[round(x*fraction_uq10 ,3) for x in list(mtbl.lclk_frequency_table)]} MHz", + "mtbl_cclk_frequency_acc": f"{[round(x*fraction_uq10 ,3) for x in list(mtbl.cclk_frequency_acc)]} GHz", + "mtbl_gfxclk_frequency_acc": f"{[round(x*fraction_uq10 ,3) for x in list(mtbl.gfxclk_frequency_acc)]} MHz", + "mtbl_gfxclk_frequency": f"{[round(x*fraction_uq10 ,3) for x in list(mtbl.gfxclk_frequency)]} MHz", + "mtbl_max_cclk_frequency": f"{round(mtbl.max_cclk_frequency * fraction_uq10 ,3)} GHz", + "mtbl_min_cclk_frequency": f"{round(mtbl.min_cclk_frequency * fraction_uq10 ,3)} GHz", + "mtbl_max_gfxclk_frequency": f"{round(mtbl.max_gfxclk_frequency * fraction_uq10 ,3)} MHz", + "mtbl_min_gfxclk_frequency": f"{round(mtbl.min_gfxclk_frequency * fraction_uq10 ,3)} MHz", "mtbl_max_lclk_dpm_range": mtbl.max_lclk_dpm_range, "mtbl_min_lclk_dpm_range": mtbl.min_lclk_dpm_range, "mtbl_xgmi_width": round(mtbl.xgmi_width * fraction_uq10 ,3), - "mtbl_xgmi_bitrate": round(mtbl.xgmi_bitrate * fraction_uq10 ,3), - "mtbl_xgmi_read_bandwidth_acc": [round(x*fraction_uq10 ,3) for x in list(mtbl.xgmi_read_bandwidth_acc)], - "mtbl_xgmi_write_bandwidth_acc": [round(x*fraction_uq10 ,3) for x in list(mtbl.xgmi_write_bandwidth_acc)], - "mtbl_socket_c0_residency": round(mtbl.socket_c0_residency * fraction_uq10 ,3), - "mtbl_socket_gfx_busy": round(mtbl.socket_gfx_busy * fraction_uq10 ,3), - "mtbl_dram_bandwidth_utilization": round(mtbl.dram_bandwidth_utilization * fraction_uq10 ,3), + "mtbl_xgmi_bitrate": f"{round(mtbl.xgmi_bitrate * fraction_uq10 ,3)} Gbps", + "mtbl_xgmi_read_bandwidth_acc": f"{[round(x*fraction_uq10 ,3) for x in list(mtbl.xgmi_read_bandwidth_acc)]} Gbps", + "mtbl_xgmi_write_bandwidth_acc": f"{[round(x*fraction_uq10 ,3) for x in list(mtbl.xgmi_write_bandwidth_acc)]} Gbps", + "mtbl_socket_c0_residency": f"{round(mtbl.socket_c0_residency * fraction_uq10 ,3)} %", + "mtbl_socket_gfx_busy": f"{round(mtbl.socket_gfx_busy * fraction_uq10 ,3)} %", + "mtbl_dram_bandwidth_utilization": f"{round(mtbl.dram_bandwidth_utilization * fraction_uq10 ,3)} %", "mtbl_socket_c0_residency_acc": round(mtbl.socket_c0_residency_acc * fraction_uq10 ,3), "mtbl_socket_gfx_busy_acc": round(mtbl.socket_gfx_busy_acc * fraction_uq10 ,3), - "mtbl_dram_bandwidth_acc": round(mtbl.dram_bandwidth_acc * fraction_uq10 ,3), - "mtbl_max_dram_bandwidth": round(mtbl.max_dram_bandwidth * fraction_uq10 ,3), + "mtbl_dram_bandwidth_acc": f"{round(mtbl.dram_bandwidth_acc * fraction_uq10 ,3)} Gbps", + "mtbl_max_dram_bandwidth": f"{round(mtbl.max_dram_bandwidth * fraction_uq10 ,3)} Gbps", "mtbl_dram_bandwidth_utilization_acc": round(mtbl.dram_bandwidth_utilization_acc * fraction_uq10 ,3), - "mtbl_pcie_bandwidth_acc": [round(x*fraction_uq10 ,3) for x in list(mtbl.pcie_bandwidth_acc)], + "mtbl_pcie_bandwidth_acc": f"{[round(x*fraction_uq10 ,3) for x in list(mtbl.pcie_bandwidth_acc)]} Gbps", "mtbl_prochot_residency_acc": mtbl.prochot_residency_acc, "mtbl_ppt_residency_acc": mtbl.ppt_residency_acc, "mtbl_socket_thm_residency_acc": mtbl.socket_thm_residency_acc, From 7dcd5a3fd60052a9f65f85bcf0d149daa0e9145b Mon Sep 17 00:00:00 2001 From: Deepak Mewar Date: Wed, 3 Jan 2024 05:51:30 -0500 Subject: [PATCH 13/22] amdsmi interface updated to additionally return the freq src from amdsmi_get_cpu_socket_current_active_freq_limit Change-Id: I48f1026474115848a30352637415e7a1a52f3481 --- py-interface/amdsmi_interface.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/py-interface/amdsmi_interface.py b/py-interface/amdsmi_interface.py index 9da07ad84f..3c986c7e62 100644 --- a/py-interface/amdsmi_interface.py +++ b/py-interface/amdsmi_interface.py @@ -819,7 +819,7 @@ def amdsmi_get_cpu_cclk_limit( def amdsmi_get_cpu_socket_current_active_freq_limit( processor_handle: amdsmi_wrapper.amdsmi_processor_handle -) -> int: +): if not isinstance(processor_handle, amdsmi_wrapper.amdsmi_processor_handle): raise AmdSmiParameterException( processor_handle, amdsmi_wrapper.amdsmi_processor_handle @@ -827,13 +827,17 @@ def amdsmi_get_cpu_socket_current_active_freq_limit( freq = ctypes.c_uint16() src_type = ctypes.pointer(ctypes.pointer(ctypes.c_char())) + _check_res( amdsmi_wrapper.amdsmi_get_cpu_socket_current_active_freq_limit( processor_handle, ctypes.byref(freq), src_type ) ) - return f"{freq.value} MHz" + return { + "freq": f"{freq.value} MHz", + "freq_src": f"{amdsmi_wrapper.string_cast(src_type.contents)}" + } def amdsmi_get_cpu_socket_freq_range( processor_handle: amdsmi_wrapper.amdsmi_processor_handle From 4971466c22e6ce5ccbafddb1a509df8df2c4cc9f Mon Sep 17 00:00:00 2001 From: khashaik Date: Wed, 3 Jan 2024 06:49:20 -0500 Subject: [PATCH 14/22] amdsmi_cli: Fix issues for CPU related API's for DIMM - Fix interface issues for dimm temperature, dimm refresh rate and dimm power consumption Change-Id: I998209c8314e4d78a842187c5a0b127aea7dbef2 --- amdsmi_cli/amdsmi_commands.py | 4 ++-- amdsmi_cli/amdsmi_parser.py | 9 ++++++--- py-interface/amdsmi_interface.py | 15 ++++++++++++--- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/amdsmi_cli/amdsmi_commands.py b/amdsmi_cli/amdsmi_commands.py index 73af73b420..0ec6a64efb 100644 --- a/amdsmi_cli/amdsmi_commands.py +++ b/amdsmi_cli/amdsmi_commands.py @@ -1838,7 +1838,7 @@ class AMDSMICommands(): args.cpu_lclk_dpm_level[0][0]) static_dict["socket_dpm"]["dpml_level_range"] = dpm_val except amdsmi_exception.AmdSmiLibraryException as e: - static_dict["socket_dpm"]["dpml_level_range"] = dpm_val + static_dict["socket_dpm"]["dpml_level_range"] = "N/A" logging.debug("Failed to get socket dpm level range for cpu %s | %s", cpu_id, e.get_error_info()) if (args.cpu_pwr_svi_telemtry_rails): @@ -1893,7 +1893,7 @@ class AMDSMICommands(): amdsmi_interface.amdsmi_set_cpu_socket_power_cap(args.cpu, args.set_cpu_pow_limit[0][0]) static_dict["set_pow_limit"]["Response"] = "Set Operation successful" except amdsmi_exception.AmdSmiLibraryException as e: - static_dict["set_pow_limit"]["Response"] = "Set Operation successful" + static_dict["set_pow_limit"]["Response"] = "N/A" logging.debug("Failed to set power limit for cpu %s | %s", cpu_id, e.get_error_info()) if (args.set_cpu_xgmi_link_width): diff --git a/amdsmi_cli/amdsmi_parser.py b/amdsmi_cli/amdsmi_parser.py index 045cf1fa7a..f7d7346a3d 100644 --- a/amdsmi_cli/amdsmi_parser.py +++ b/amdsmi_cli/amdsmi_parser.py @@ -654,9 +654,12 @@ core limit value" set_group.add_argument('--set_cpu_pwr_eff_mode', action='append', required=False, type=int, nargs=1, metavar=("MODE"), help=set_cpu_pwr_eff_mode_help) cpu_group.add_argument('--cpu_ddr_bandwidth', action='store_true', required=False, help=cpu_ddr_bandwidth_help) cpu_group.add_argument('--cpu_temp', action='store_true', required=False, help=cpu_temp_help) - cpu_group.add_argument('--cpu_dimm_temp_range_rate', action='append', required=False, type=int, nargs=1, metavar=("DIMM_ADDR"), help=cpu_dimm_temp_range_rate_help) - cpu_group.add_argument('--cpu_dimm_pow_conumption', action='append', required=False, type=int, nargs=1, metavar=("DIMM_ADDR"), help=cpu_dimm_pow_conumption_help) - cpu_group.add_argument('--cpu_dimm_thermal_sensor', action='append', required=False, type=int, nargs=1, metavar=("DIMM_ADDR"), help=cpu_dimm_thermal_sensor_help) + cpu_group.add_argument('--cpu_dimm_temp_range_rate', action='append', required=False, type=lambda x: int(x, 0), + nargs=1, metavar=("DIMM_ADDR"), help=cpu_dimm_temp_range_rate_help) + cpu_group.add_argument('--cpu_dimm_pow_conumption', action='append', required=False, type=lambda x: int(x, 0), + nargs=1, metavar=("DIMM_ADDR"), help=cpu_dimm_pow_conumption_help) + cpu_group.add_argument('--cpu_dimm_thermal_sensor', action='append', required=False, type=lambda x: int(x, 0), + nargs=1, metavar=("DIMM_ADDR"), help=cpu_dimm_thermal_sensor_help) set_group.add_argument('--set_cpu_gmi3_link_width', action='append', required=False, type=int, nargs=2, metavar=("MIN_LW", "MAX_LW"), help=set_cpu_gmi3_link_width_help) set_group.add_argument('--set_cpu_pcie_lnk_rate', action='append', required=False, type=int, nargs=1, metavar=("LINK_RATE"), help=set_cpu_pcie_lnk_rate_help) set_group.add_argument('--set_cpu_df_pstate_range', action='append', required=False, type=int, nargs=2, metavar=("MAX_PSTATE", "MIN_PSTATE"), help=set_cpu_df_pstate_range_help) diff --git a/py-interface/amdsmi_interface.py b/py-interface/amdsmi_interface.py index 3c986c7e62..81c2e2bdca 100644 --- a/py-interface/amdsmi_interface.py +++ b/py-interface/amdsmi_interface.py @@ -1088,9 +1088,12 @@ def amdsmi_get_cpu_dimm_temp_range_and_refresh_rate( if not isinstance(dimm_addr, int): raise AmdSmiParameterException(dimm_addr, int) + dimm_addr = ctypes.c_uint8(dimm_addr) dimm = amdsmi_wrapper.amdsmi_temp_range_refresh_rate_t() - _check_res(amdsmi_wrapper.amdsmi_get_cpu_dimm_temp_range_and_refresh_rate(processor_handle, dimm)) + _check_res(amdsmi_wrapper.amdsmi_get_cpu_dimm_temp_range_and_refresh_rate(processor_handle, + dimm_addr, + ctypes.byref(dimm))) return { "dimm_temperature_range": dimm.range, @@ -1107,9 +1110,12 @@ def amdsmi_get_cpu_dimm_power_consumption( if not isinstance(dimm_addr, int): raise AmdSmiParameterException(dimm_addr, int) + dimm_addr = ctypes.c_uint8(dimm_addr) dimm = amdsmi_wrapper.amdsmi_dimm_power_t() - _check_res(amdsmi_wrapper.amdsmi_get_cpu_dimm_power_consumption(processor_handle, dimm)) + _check_res(amdsmi_wrapper.amdsmi_get_cpu_dimm_power_consumption(processor_handle, + dimm_addr, + ctypes.byref(dimm))) return { "dimm_power_consumed": f"{dimm.power} mW", @@ -1127,9 +1133,12 @@ def amdsmi_get_cpu_dimm_thermal_sensor( if not isinstance(dimm_addr, int): raise AmdSmiParameterException(dimm_addr, int) + dimm_addr = ctypes.c_uint8(dimm_addr) dimm_thermal = amdsmi_wrapper.amdsmi_dimm_thermal_t() - _check_res(amdsmi_wrapper.amdsmi_get_cpu_dimm_thermal_sensor(processor_handle, dimm_thermal)) + _check_res(amdsmi_wrapper.amdsmi_get_cpu_dimm_thermal_sensor(processor_handle, + dimm_addr, + ctypes.byref(dimm_thermal))) return { "dimm_thermal_sensor_value": dimm_thermal.sensor, From 108ae03c2365ef9fbf4c54c8680d3fb5c9cb35fe Mon Sep 17 00:00:00 2001 From: khashaik Date: Wed, 3 Jan 2024 08:01:33 -0500 Subject: [PATCH 15/22] amdsmi_cli: Update parser to add neg values check for the cpu and core arguments Change-Id: Ia7959826637e7749d999a6570df590221e85cf50 --- amdsmi_cli/amdsmi_parser.py | 68 +++++++++++++++++++++++++++---------- 1 file changed, 51 insertions(+), 17 deletions(-) diff --git a/amdsmi_cli/amdsmi_parser.py b/amdsmi_cli/amdsmi_parser.py index f7d7346a3d..c8b978e62a 100644 --- a/amdsmi_cli/amdsmi_parser.py +++ b/amdsmi_cli/amdsmi_parser.py @@ -323,6 +323,23 @@ class AMDSMIParser(argparse.ArgumentParser): type=self._positive_int, required=False, help=iterations_help) + def _validate_cpu_core(self, value): + if (int(value) < 0): + outputformat = self.helpers.get_output_format() + raise amdsmi_cli_exceptions.AmdSmiInvalidParameterValueException(value, outputformat) + + return value + + + def _validate_positive(self, value): + i_value = int(value) + if (i_value < 0): + outputformat = self.helpers.get_output_format() + raise amdsmi_cli_exceptions.AmdSmiInvalidParameterValueException(i_value, outputformat) + + return i_value + + def _add_device_arguments(self, subcommand_parser, required=False): # Device arguments help text gpu_help = f"Select a GPU ID, BDF, or UUID from the possible choices:\n{self.gpu_choices_str}" @@ -336,9 +353,11 @@ class AMDSMIParser(argparse.ArgumentParser): device_args = subcommand_parser.add_mutually_exclusive_group(required=required) device_args.add_argument('-g', '--gpu', action=self._gpu_select(self.gpu_choices), nargs='+', help=gpu_help) - device_args.add_argument('-U', '--cpu', action=self._cpu_select(self.cpu_choices), + device_args.add_argument('-U', '--cpu', type=self._validate_cpu_core, + action=self._cpu_select(self.cpu_choices), nargs='+', help=cpu_help) - device_args.add_argument('-O', '--core', action=self._core_select(self.core_choices), + device_args.add_argument('-O', '--core', type=self._validate_cpu_core, + action=self._core_select(self.core_choices), nargs='+', help=core_help) if self.helpers.is_hypervisor(): @@ -634,24 +653,36 @@ core limit value" cpu_group.add_argument('--cpu_prochot', action='store_true', required=False, help=cpu_proc_help) cpu_group.add_argument('--cpu_freq_metrics', action='store_true', required=False, help=cpu_freq_help) cpu_group.add_argument('--cpu_c0_res', action='store_true', required=False, help=cpu_c0_res_help) - cpu_group.add_argument('--cpu_lclk_dpm_level', action='append', required=False, type=int, nargs=1, metavar=("NBIOID"), help=cpu_lclk_dpm_help) - cpu_group.add_argument('--cpu_pwr_svi_telemtry_rails', action='store_true', required=False, help=cpu_pwr_svi_telemtry_rails_help) - cpu_group.add_argument('--cpu_io_bandwidth', action='append', required=False, nargs=2, metavar=("IO_BW","LINKID_NAME"), help=cpu_io_bandwidth_help) - cpu_group.add_argument('--cpu_xgmi_bandwidth', action='append', required=False, nargs=2, metavar=("XGMI_BW","LINKID_NAME"), help=cpu_xgmi_bandwidth_help) + cpu_group.add_argument('--cpu_lclk_dpm_level', action='append', required=False, type=self._validate_positive, + nargs=1, metavar=("NBIOID"), help=cpu_lclk_dpm_help) + cpu_group.add_argument('--cpu_pwr_svi_telemtry_rails', action='store_true', required=False, + help=cpu_pwr_svi_telemtry_rails_help) + cpu_group.add_argument('--cpu_io_bandwidth', action='append', required=False, nargs=2, + metavar=("IO_BW","LINKID_NAME"), help=cpu_io_bandwidth_help) + cpu_group.add_argument('--cpu_xgmi_bandwidth', action='append', required=False, nargs=2, + metavar=("XGMI_BW","LINKID_NAME"), help=cpu_xgmi_bandwidth_help) cpu_group.add_argument('--cpu_enable_apb', action='store_true', required=False, help=cpu_enable_apb_help) - cpu_group.add_argument('--cpu_disable_apb', action='append', required=False, type=int, nargs=1, metavar=("DF_PSTATE"), help=cpu_disable_apb_help) - set_group.add_argument('--set_cpu_pow_limit', action='append', required=False, type=int, nargs=1, metavar=("POW_LIMIT"),help=set_cpu_pow_limit_help) - set_group.add_argument('--set_cpu_xgmi_link_width', action='append', required=False, type=int, nargs=2, metavar=("MIN_WIDTH", "MAX_WIDTH"), help=set_cpu_xgmi_link_width_help) - set_group.add_argument('--set_cpu_lclk_dpm_level', action='append', required=False, type=int, nargs=3, metavar=("NBIOID", "MIN_DPM", "MAX_DPM"),help=set_cpu_lclk_dpm_level_help) + cpu_group.add_argument('--cpu_disable_apb', action='append', required=False, type=self._validate_positive, + nargs=1, metavar=("DF_PSTATE"), help=cpu_disable_apb_help) + set_group.add_argument('--set_cpu_pow_limit', action='append', required=False, type=self._validate_positive, + nargs=1, metavar=("POW_LIMIT"),help=set_cpu_pow_limit_help) + set_group.add_argument('--set_cpu_xgmi_link_width', action='append', required=False, type=self._validate_positive, + nargs=2, metavar=("MIN_WIDTH", "MAX_WIDTH"), help=set_cpu_xgmi_link_width_help) + set_group.add_argument('--set_cpu_lclk_dpm_level', action='append', required=False, type=self._validate_positive, + nargs=3, metavar=("NBIOID", "MIN_DPM", "MAX_DPM"),help=set_cpu_lclk_dpm_level_help) cpu_group.add_argument('--core_boost_limit', action='store_true', required=False, help=core_boost_limit_help) - cpu_group.add_argument('--core_curr_active_freq_core_limit', action='store_true', required=False, help=core_curr_active_freq_core_limit_help) - set_group.add_argument('--set_soc_boost_limit', action='append', required=False, type=int, nargs=1, metavar=("BOOST_LIMIT"), help=set_soc_boost_limit_help) - set_group.add_argument('--set_core_boost_limit', action='append', required=False, type=int, nargs=1, metavar=("BOOST_LIMIT"), help=set_core_boost_limit_help) + cpu_group.add_argument('--core_curr_active_freq_core_limit', action='store_true', required=False, + help=core_curr_active_freq_core_limit_help) + set_group.add_argument('--set_soc_boost_limit', action='append', required=False, type=self._validate_positive, + nargs=1, metavar=("BOOST_LIMIT"), help=set_soc_boost_limit_help) + set_group.add_argument('--set_core_boost_limit', action='append', required=False, type=self._validate_positive, + nargs=1, metavar=("BOOST_LIMIT"), help=set_core_boost_limit_help) cpu_group.add_argument('--cpu_metrics_ver', action='store_true', required=False, help=cpu_metrics_ver_help) cpu_group.add_argument('--cpu_metrics_table', action='store_true', required=False, help=cpu_metrics_table_help) cpu_group.add_argument('--core_energy', action='store_true', required=False, help=core_energy_help) cpu_group.add_argument('--socket_energy', action='store_true', required=False, help=socket_energy_help) - set_group.add_argument('--set_cpu_pwr_eff_mode', action='append', required=False, type=int, nargs=1, metavar=("MODE"), help=set_cpu_pwr_eff_mode_help) + set_group.add_argument('--set_cpu_pwr_eff_mode', action='append', required=False, type=self._validate_positive, + nargs=1, metavar=("MODE"), help=set_cpu_pwr_eff_mode_help) cpu_group.add_argument('--cpu_ddr_bandwidth', action='store_true', required=False, help=cpu_ddr_bandwidth_help) cpu_group.add_argument('--cpu_temp', action='store_true', required=False, help=cpu_temp_help) cpu_group.add_argument('--cpu_dimm_temp_range_rate', action='append', required=False, type=lambda x: int(x, 0), @@ -660,9 +691,12 @@ core limit value" nargs=1, metavar=("DIMM_ADDR"), help=cpu_dimm_pow_conumption_help) cpu_group.add_argument('--cpu_dimm_thermal_sensor', action='append', required=False, type=lambda x: int(x, 0), nargs=1, metavar=("DIMM_ADDR"), help=cpu_dimm_thermal_sensor_help) - set_group.add_argument('--set_cpu_gmi3_link_width', action='append', required=False, type=int, nargs=2, metavar=("MIN_LW", "MAX_LW"), help=set_cpu_gmi3_link_width_help) - set_group.add_argument('--set_cpu_pcie_lnk_rate', action='append', required=False, type=int, nargs=1, metavar=("LINK_RATE"), help=set_cpu_pcie_lnk_rate_help) - set_group.add_argument('--set_cpu_df_pstate_range', action='append', required=False, type=int, nargs=2, metavar=("MAX_PSTATE", "MIN_PSTATE"), help=set_cpu_df_pstate_range_help) + set_group.add_argument('--set_cpu_gmi3_link_width', action='append', required=False, type=self._validate_positive, + nargs=2, metavar=("MIN_LW", "MAX_LW"), help=set_cpu_gmi3_link_width_help) + set_group.add_argument('--set_cpu_pcie_lnk_rate', action='append', required=False, type=self._validate_positive, + nargs=1, metavar=("LINK_RATE"), help=set_cpu_pcie_lnk_rate_help) + set_group.add_argument('--set_cpu_df_pstate_range', action='append', required=False, type=self._validate_positive, + nargs=2, metavar=("MAX_PSTATE", "MIN_PSTATE"), help=set_cpu_df_pstate_range_help) def _add_process_parser(self, subparsers, func): if self.helpers.is_hypervisor(): From 18d8087711e4633ef315e2589aa57ff2f430bfa5 Mon Sep 17 00:00:00 2001 From: khashaik Date: Thu, 4 Jan 2024 08:20:19 -0500 Subject: [PATCH 16/22] amdsmi_cli: Add checks for no gpu devices, cpu and core devices - Add checks for no gpu devices, cpu and core devices - Update units for core energy and cpu energy Change-Id: Ieea43f1bb7fc303ebbbdf72f1ab22644a28df25c --- amdsmi_cli/amdsmi_commands.py | 77 ++++++++++++++++++++++++++------ py-interface/amdsmi_interface.py | 4 +- 2 files changed, 65 insertions(+), 16 deletions(-) diff --git a/amdsmi_cli/amdsmi_commands.py b/amdsmi_cli/amdsmi_commands.py index 0ec6a64efb..369ce0497d 100644 --- a/amdsmi_cli/amdsmi_commands.py +++ b/amdsmi_cli/amdsmi_commands.py @@ -736,6 +736,10 @@ class AMDSMICommands(): else: logging.info("No CPU devices present") + if (cpu_options and (len(self.cpu_handles) == 0)): + logging.error("No CPU devices present") + sys.exit(-1) + if (len(self.device_handles) and ((((not gpus) and (not cpus)) or gpus) and not cpu_options)): self.logger.clear_multiple_devices_ouput() @@ -746,6 +750,10 @@ class AMDSMICommands(): else: logging.info("No GPU devices present") + if (gpu_options and (len(self.device_handles) == 0)): + logging.error("No GPU devices present") + sys.exit(-1) + if (len(self.cpu_handles) == 0 and len(self.device_handles) == 0): logging.error("No CPU and GPU devices present") sys.exit(-1) @@ -1652,7 +1660,32 @@ class AMDSMICommands(): args (Namespace): Namespace containing the parsed CLI args multiple_devices (bool, optional): True if checking for multiple devices. Defaults to False. cpu (cpu_handle, optional): device_handle for target device. Defaults to None. - + cpu_power_metrics (bool, optional): Value override for args.cpu_power_metrics. Defaults to None + prochot (bool, optional): Value override for args.prochot. Defaults to None. + freq_metrics (bool, optional): Value override for args.freq_metrics. Defaults to None. + c0_res (bool, optional): Value override for args.c0_res. Defaults to None + lclk_dpm_level (list, optional): Value override for args.lclk_dpm_level. Defaults to None + pwr_svi_telemtry_rails (list, optional): value override for args.pwr_svi_telemtry_rails. Defaults to None + io_bandwidth (list, optional): value override for args.io_bandwidth. Defaults to None + xgmi_bandwidth (list, optional): value override for args.xgmi_bandwidth. Defaults to None + enable_apb (bool, optional): Value override for args.enable_apb. Defaults to None + disable_apb (bool, optional): Value override for args.disable_apb. Defaults to None + set_pow_limit (int, optional): Value override for args.cpu_set_pow_limit. Defaults to None + set_xgmi_link_width (list, optional): Value override for args.set_cpu_xgmi_link_width. Defaults to None + set_lclk_dpm_level (list, optional): Value override for args.set_cpu_lclk_dpm_level. Defaults to None + set_soc_boost_limit (list, optional): Value override for args.set_soc_boost_limit. Defaults to None + metrics_ver (bool, optional): Value override for args.cpu_metrics_ver. Defaults to None + metrics_table (bool, optional): Value override for args.cpu_metrics_table. Defaults to None + socket_energy (bool, optional): Value override for args.socket_energy. Defaults to None + set_pwr_eff_mode (list, optional): Value override for args.set_cpu_pwr_eff_mode. Defaults to None + ddr_bandwidth (bool, optional): Value override for args.ddr_bandwidth. Defaults to None + cpu_temp (bool, optional): Value override for args.cpu_temp. Defaults to None + dimm_temp_range_rate (list, optional): Dimm address.Value override for args.cpu_dimm_temp_range_rate. Defaults to None + dimm_pow_conumption (list, optional): Dimm address. Value override for args.cpu_dimm_pow_conumption. Defaults to None + dimm_thermal_sensor (list, optional): Dimm address. Value override for args.cpu_dimm_thermal_sensor. Defaults to None + set_gmi3_link_width (list, optional): Min and Max link wdiths.Value override for args.set_cpu_gmi3_link_width. Defaults to None + set_pcie_lnk_rate (list, optional): Link rate.Value override for args.set_cpu_pcie_lnk_rate. Defaults to None + set_df_pstate_range (list, optional): Max and Min pstates.Value override for args.set_cpu_df_pstate_range. Defaults to None Returns: None: Print output via AMDSMILogger to destination """ @@ -1936,9 +1969,6 @@ class AMDSMICommands(): if (args.cpu_metrics_table): static_dict["metrics_table"] = {} - static_dict["metrics_table"]["response"] = "N/A" - # Note:- amdsmi_get_metrics_table has been disabled as there is fix needed in the library API and will be - # in next version try: metrics_table = amdsmi_interface.amdsmi_get_metrics_table(args.cpu) static_dict["metrics_table"]["response"] = metrics_table @@ -2054,7 +2084,10 @@ class AMDSMICommands(): args (Namespace): Namespace containing the parsed CLI args multiple_devices (bool, optional): True if checking for multiple devices. Defaults to False. core (device_handle, optional): device_handle for target device. Defaults to None. - + boost_limit (bool, optional): Value override for args.boostlimit. Defaults to None + curr_active_freq_core_limit (bool, optional): Value override for args.boostlimit. Defaults to None + set_core_boost_limit(list, optional): boost limit value.Value override for args.set_core_boost_limit. Defaults to None + core_energy (bool, optional): Value override for args.core_energy. Defaults to None Returns: None: Print output via AMDSMILogger to destination """ @@ -2187,6 +2220,7 @@ class AMDSMICommands(): guest_data (bool, optional): Value override for args.guest_data. Defaults to None. fb_usage (bool, optional): Value override for args.fb_usage. Defaults to None. xgmi (bool, optional): Value override for args.xgmi. Defaults to None. + cpu (device_handle, optional): cpu index. Defaults to None cpu_power_metrics (bool, optional): Value override for args.cpu_power_metrics. Defaults to None prochot (bool, optional): Value override for args.prochot. Defaults to None. freq_metrics (bool, optional): Value override for args.freq_metrics. Defaults to None. @@ -2197,10 +2231,9 @@ class AMDSMICommands(): xgmi_bandwidth (list, optional): value override for args.xgmi_bandwidth. Defaults to None enable_apb (bool, optional): Value override for args.enable_apb. Defaults to None disable_apb (bool, optional): Value override for args.disable_apb. Defaults to None - set_pow_limit (bool, optional): Value override for args.cpu_set_pow_limit. Defaults to None + set_pow_limit (int, optional): Value override for args.cpu_set_pow_limit. Defaults to None set_xgmi_link_width (list, optional): Value override for args.set_cpu_xgmi_link_width. Defaults to None - set_lclk_dpm_level (bool, optional): Value override for args.set_cpu_lclk_dpm_level. Defaults to None - boost_limit (bool, optional): Value override for args.boost_limit. Defaults to None + set_lclk_dpm_level (list, optional): Value override for args.set_cpu_lclk_dpm_level. Defaults to None set_soc_boost_limit (list, optional): Value override for args.set_soc_boost_limit. Defaults to None metrics_ver (bool, optional): Value override for args.cpu_metrics_ver. Defaults to None metrics_table (bool, optional): Value override for args.cpu_metrics_table. Defaults to None @@ -2208,12 +2241,17 @@ class AMDSMICommands(): set_pwr_eff_mode (list, optional): Value override for args.set_cpu_pwr_eff_mode. Defaults to None ddr_bandwidth (bool, optional): Value override for args.ddr_bandwidth. Defaults to None cpu_temp (bool, optional): Value override for args.cpu_temp. Defaults to None - dimm_temp_range_rate (bool, optional): Value override for args.cpu_dimm_temp_range_rate. Defaults to None - dimm_pow_conumption (bool, optional): Value override for args.cpu_dimm_pow_conumption. Defaults to None - dimm_thermal_sensor (bool, optional): Value override for args.cpu_dimm_thermal_sensor. Defaults to None - set_gmi3_link_width (list, optional): Value override for args.set_cpu_gmi3_link_width. Defaults to None - set_pcie_lnk_rate (list, optional): Value override for args.set_cpu_pcie_lnk_rate. Defaults to None - set_df_pstate_range (list, optional): Value override for args.set_cpu_df_pstate_range. Defaults to None + dimm_temp_range_rate (list, optional): Dimm address.Value override for args.cpu_dimm_temp_range_rate. Defaults to None + dimm_pow_conumption (list, optional): Dimm address. Value override for args.cpu_dimm_pow_conumption. Defaults to None + dimm_thermal_sensor (list, optional): Dimm address. Value override for args.cpu_dimm_thermal_sensor. Defaults to None + set_gmi3_link_width (list, optional): Min and Max link wdiths.Value override for args.set_cpu_gmi3_link_width. Defaults to None + set_pcie_lnk_rate (list, optional): Link rate.Value override for args.set_cpu_pcie_lnk_rate. Defaults to None + set_df_pstate_range (list, optional): Max and Min pstates.Value override for args.set_cpu_df_pstate_range. Defaults to None + core (int, optional): core index. Value override for args.core.Defaults to None + boost_limit (bool, optional): Value override for args.boostlimit. Defaults to None + curr_active_freq_core_limit (bool, optional): Value override for args.boostlimit. Defaults to None + set_core_boost_limit(list, optional): boost limit value.Value override for args.set_core_boost_limit. Defaults to None + Raises: IndexError: Index error if gpu list is empty @@ -2250,6 +2288,10 @@ class AMDSMICommands(): xgmi_err, energy, mem_usage, schedule, guard, guest_data, fb_usage, xgmi) + if (gpu_options and (len(self.device_handles) == 0)): + logging.error("No GPU devices present") + sys.exit(-1) + if ((len(self.cpu_handles) and ((((not gpus) and (not cpus) and (not cores)) or cpus) and not gpu_options and not core_options))): self.logger.clear_multiple_devices_ouput() @@ -2262,6 +2304,9 @@ class AMDSMICommands(): dimm_pow_conumption,dimm_thermal_sensor, set_gmi3_link_width, set_pcie_lnk_rate, set_df_pstate_range) + if (cpu_options and (len(self.cpu_handles) == 0)): + logging.error("No CPU devices present") + sys.exit(-1) if ((len(self.core_handles) and ((((not gpus) and (not cpus) and (not cores)) or cores) and not gpu_options and not cpu_options))): @@ -2270,6 +2315,10 @@ class AMDSMICommands(): curr_active_freq_core_limit, set_core_boost_limit, core_energy) + if (core_options and (len(self.cpu_handles) == 0)): + logging.error("No Core devices present") + sys.exit(-1) + if (len(self.cpu_handles) == 0 and len(self.device_handles) == 0 and len(self.core_handles) == 0): logging.error("No CPU and GPU devices present") diff --git a/py-interface/amdsmi_interface.py b/py-interface/amdsmi_interface.py index 81c2e2bdca..87a6bd0040 100644 --- a/py-interface/amdsmi_interface.py +++ b/py-interface/amdsmi_interface.py @@ -743,7 +743,7 @@ def amdsmi_get_cpu_core_energy( ) ) - return f"{penergy.value} J" + return f"{float(penergy.value * pow(10, -6))} J" def amdsmi_get_cpu_socket_energy( processor_handle: amdsmi_wrapper.amdsmi_processor_handle @@ -760,7 +760,7 @@ def amdsmi_get_cpu_socket_energy( ) ) - return f"{penergy.value} J" + return f"{float(penergy.value * pow(10, -6))} J" def amdsmi_get_cpu_prochot_status( processor_handle: amdsmi_wrapper.amdsmi_processor_handle From a0c95e855b2eccc9fb5f833c267a4cf657a6e34a Mon Sep 17 00:00:00 2001 From: Deepak Mewar Date: Mon, 8 Jan 2024 03:30:54 -0500 Subject: [PATCH 17/22] amdsmi library updated for metric table structure Change-Id: Ie8a9840a9020282599dd413e964d86bfb8850f6a --- include/amd_smi/amdsmi.h | 2 +- src/amd_smi/amd_smi.cc | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/amd_smi/amdsmi.h b/include/amd_smi/amdsmi.h index b2ed9bbf39..da340d5704 100644 --- a/include/amd_smi/amdsmi.h +++ b/include/amd_smi/amdsmi.h @@ -1506,7 +1506,7 @@ typedef struct { /** * @brief Metrics table (supported only with hsmp proto version 6). */ -typedef struct { +typedef struct __attribute__((__packed__)){ uint32_t accumulation_counter; /* TEMPERATURE */ diff --git a/src/amd_smi/amd_smi.cc b/src/amd_smi/amd_smi.cc index 283496badb..fec0101bdd 100644 --- a/src/amd_smi/amd_smi.cc +++ b/src/amd_smi/amd_smi.cc @@ -3653,6 +3653,9 @@ amdsmi_status_t amdsmi_get_metrics_table(amdsmi_processor_handle processor_handl if (processor_handle == nullptr) return AMDSMI_STATUS_INVAL; + if(sizeof(amdsmi_hsmp_metric_table_t) != sizeof(struct hsmp_metric_table)) + return AMDSMI_STATUS_UNEXPECTED_SIZE; + amdsmi_status_t r = amdsmi_get_processor_info(processor_handle, SIZE, proc_id); if (r != AMDSMI_STATUS_SUCCESS) return r; From 19451cc508ab9b2ceed1d1ca4e335abe3e13a875 Mon Sep 17 00:00:00 2001 From: Deepak Mewar Date: Mon, 8 Jan 2024 05:47:20 -0500 Subject: [PATCH 18/22] amdsmi wrapper generated for updated hsmp metric table Change-Id: I18c795e18d9c95320826cb965f36d3fb5546ea5c --- py-interface/amdsmi_wrapper.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/py-interface/amdsmi_wrapper.py b/py-interface/amdsmi_wrapper.py index 7e6c421905..99a2c776f1 100644 --- a/py-interface/amdsmi_wrapper.py +++ b/py-interface/amdsmi_wrapper.py @@ -1720,7 +1720,7 @@ amdsmi_dpm_level_t = struct_amdsmi_dpm_level_t class struct_amdsmi_hsmp_metric_table_t(Structure): pass -struct_amdsmi_hsmp_metric_table_t._pack_ = 1 # source:False +struct_amdsmi_hsmp_metric_table_t._pack_ = 1 # source:True struct_amdsmi_hsmp_metric_table_t._fields_ = [ ('accumulation_counter', ctypes.c_uint32), ('max_socket_temperature', ctypes.c_uint32), @@ -1732,7 +1732,6 @@ struct_amdsmi_hsmp_metric_table_t._fields_ = [ ('socket_power_limit', ctypes.c_uint32), ('max_socket_power_limit', ctypes.c_uint32), ('socket_power', ctypes.c_uint32), - ('PADDING_0', ctypes.c_ubyte * 4), ('timestamp', ctypes.c_uint64), ('socket_energy_acc', ctypes.c_uint64), ('ccd_energy_acc', ctypes.c_uint64), @@ -1768,12 +1767,10 @@ struct_amdsmi_hsmp_metric_table_t._fields_ = [ ('socket_c0_residency', ctypes.c_uint32), ('socket_gfx_busy', ctypes.c_uint32), ('dram_bandwidth_utilization', ctypes.c_uint32), - ('PADDING_1', ctypes.c_ubyte * 4), ('socket_c0_residency_acc', ctypes.c_uint64), ('socket_gfx_busy_acc', ctypes.c_uint64), ('dram_bandwidth_acc', ctypes.c_uint64), ('max_dram_bandwidth', ctypes.c_uint32), - ('PADDING_2', ctypes.c_ubyte * 4), ('dram_bandwidth_utilization_acc', ctypes.c_uint64), ('pcie_bandwidth_acc', ctypes.c_uint64 * 4), ('prochot_residency_acc', ctypes.c_uint32), From 994b956d5e8201a78cb810240705c3b7ad4baaaf Mon Sep 17 00:00:00 2001 From: khashaik Date: Tue, 9 Jan 2024 05:39:06 -0500 Subject: [PATCH 19/22] amdsmi_cli: Updated README.md file in the amdsmi_cli - Update the README.md file in amdsmi_cli folder to include information for CPU's and CORE's along with the GPU's Change-Id: I7670811696bc5299a287a6bc8883afe40eeeb557 --- amdsmi_cli/README.md | 941 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 772 insertions(+), 169 deletions(-) diff --git a/amdsmi_cli/README.md b/amdsmi_cli/README.md index b656a87ea4..78eba9076c 100644 --- a/amdsmi_cli/README.md +++ b/amdsmi_cli/README.md @@ -78,11 +78,10 @@ amd-smi will report the version and current platform detected when running the c ~$ amd-smi usage: amd-smi [-h] ... -AMD System Management Interface | Version: 23.4.0.0 | ROCm version: 6.1.0 | -Platform: Linux Baremetal +AMD System Management Interface | Version: 23.4.0.0 | ROCm version: 6.1.0 | Platform: Linux +Baremetal - -optional arguments: +options: -h, --help show this help message and exit AMD-SMI Commands: @@ -98,6 +97,7 @@ AMD-SMI Commands: topology Displays topology information of the devices set Set options for devices reset Reset options for devices + monitor Monitor metrics for target devices ``` More detailed verison information is available from `amd-smi version` @@ -111,7 +111,7 @@ For convenience, here is the help output for each command ``` bash ~$ amd-smi list --help usage: amd-smi list [-h] [--json | --csv] [--file FILE] [--loglevel LEVEL] - [-g GPU [GPU ...]] + [-g GPU [GPU ...] | -U CPU [CPU ...] | -O CORE [CORE ...]] Lists all the devices on the system and the links between devices. Lists all the sockets and for each socket, GPUs and/or CPUs associated to @@ -119,66 +119,106 @@ that socket alongside some basic information for each device. In virtualization environments, it can also list VFs associated to each GPU with some basic information for each VF. -optional arguments: - -h, --help show this help message and exit - -g, --gpu GPU [GPU ...] Select a GPU ID, BDF, or UUID from the possible choices: - ID: 0 | BDF:0000:23:00.0 | UUID:ffff73bf-0000-1000-80ff-ffffffffffff - all | Selects all devices +options: + -h, --help show this help message and exit + -g, --gpu GPU [GPU ...] Select a GPU ID, BDF, or UUID from the possible choices: + ID: 0 | BDF: 0000:01:00.0 | UUID: 71ff74a0-0000-1000-8066-0a3c71d5f817 + ID: 1 | BDF: 0001:01:00.0 | UUID: b4ff74a0-0000-1000-80b2-fa0be8628b1a + ID: 2 | BDF: 0002:01:00.0 | UUID: a9ff74a0-0000-1000-8007-3066a98ba4a6 + ID: 3 | BDF: 0003:01:00.0 | UUID: 53ff74a0-0000-1000-80a0-a1ff3830f499 + all | Selects all devices + -U, --cpu CPU [CPU ...] Select a CPU ID from the possible choices: + ID: 0 + ID: 1 + ID: 2 + ID: 3 + all | Selects all devices + -O, --core CORE [CORE ...] Select a Core ID from the possible choices: + ID: 0 - 95 + all | Selects all devices Command Modifiers: - --json Displays output in JSON format (human readable by default). - --csv Displays output in CSV format (human readable by default). - --file FILE Saves output into a file on the provided path (stdout by default). - --loglevel LEVEL Set the logging level from the possible choices: - DEBUG, INFO, WARNING, ERROR, CRITICAL + --json Displays output in JSON format (human readable by default). + --csv Displays output in CSV format (human readable by default). + --file FILE Saves output into a file on the provided path (stdout by default). + --loglevel LEVEL Set the logging level from the possible choices: + DEBUG, INFO, WARNING, ERROR, CRITICAL ``` ```bash ~$ amd-smi static --help usage: amd-smi static [-h] [--json | --csv] [--file FILE] [--loglevel LEVEL] - [-g GPU [GPU ...]] [-a] [-b] [-V] [-d] [-v] [-c] [-B] [-r] [-p] [-l] - [-u] + [-g GPU [GPU ...] | -U CPU [CPU ...] | -O CORE [CORE ...]] [-a] [-b] + [-V] [-d] [-v] [-c] [-B] [-s] [-i] [-r] [-p] [-l] [-u] If no GPU is specified, returns static information for all GPUs on the system. If no static argument is provided, all static information will be displayed. Static Arguments: - -h, --help show this help message and exit - -g, --gpu GPU [GPU ...] Select a GPU ID, BDF, or UUID from the possible choices: - ID: 0 | BDF:0000:23:00.0 | UUID:ffff73bf-0000-1000-80ff-ffffffffffff - all | Selects all devices - -a, --asic All asic information - -b, --bus All bus information - -V, --vbios All video bios information (if available) - -d, --driver Displays driver version - -v, --vram All vram information - -c, --cache All cache information - -B, --board All board information - -r, --ras Displays RAS features information - -p, --partition Partition information - -l, --limit All limit metric values (i.e. power and thermal limits) - -u, --numa All numa node information + -h, --help show this help message and exit + -g, --gpu GPU [GPU ...] Select a GPU ID, BDF, or UUID from the possible choices: + ID: 0 | BDF: 0000:01:00.0 | UUID: 71ff74a0-0000-1000-8066-0a3c71d5f817 + ID: 1 | BDF: 0001:01:00.0 | UUID: b4ff74a0-0000-1000-80b2-fa0be8628b1a + ID: 2 | BDF: 0002:01:00.0 | UUID: a9ff74a0-0000-1000-8007-3066a98ba4a6 + ID: 3 | BDF: 0003:01:00.0 | UUID: 53ff74a0-0000-1000-80a0-a1ff3830f499 + all | Selects all devices + -U, --cpu CPU [CPU ...] Select a CPU ID from the possible choices: + ID: 0 + ID: 1 + ID: 2 + ID: 3 + all | Selects all devices + -O, --core CORE [CORE ...] Select a Core ID from the possible choices: + ID: 0 - 95 + all | Selects all devices + -a, --asic All asic information + -b, --bus All bus information + -V, --vbios All video bios information (if available) + -d, --driver Displays driver version + -v, --vram All vram information + -c, --cache All cache information + -B, --board All board information + -r, --ras Displays RAS features information + -p, --partition Partition information + -l, --limit All limit metric values (i.e. power and thermal limits) + -u, --numa All numa node information + +CPU Option: + -s, --smu All SMU FW information + -i, --interface_ver Displays hsmp interface version Command Modifiers: - --json Displays output in JSON format (human readable by default). - --csv Displays output in CSV format (human readable by default). - --file FILE Saves output into a file on the provided path (stdout by default). - --loglevel LEVEL Set the logging level from the possible choices: - DEBUG, INFO, WARNING, ERROR, CRITICAL + --json Displays output in JSON format (human readable by default). + --csv Displays output in CSV format (human readable by default). + --file FILE Saves output into a file on the provided path (stdout by default). + --loglevel LEVEL Set the logging level from the possible choices: + DEBUG, INFO, WARNING, ERROR, CRITICAL ``` ``` bash ~$ amd-smi firmware --help usage: amd-smi firmware [-h] [--json | --csv] [--file FILE] [--loglevel LEVEL] - [-g GPU [GPU ...]] [-f] + [-g GPU [GPU ...] | -U CPU [CPU ...] | -O CORE [CORE ...]] [-f] If no GPU is specified, return firmware information for all GPUs on the system. Firmware Arguments: -h, --help show this help message and exit -g, --gpu GPU [GPU ...] Select a GPU ID, BDF, or UUID from the possible choices: - ID: 0 | BDF:0000:23:00.0 | UUID:ffff73bf-0000-1000-80ff-ffffffffffff + ID: 0 | BDF: 0000:01:00.0 | UUID: 71ff74a0-0000-1000-8066-0a3c71d5f817 + ID: 1 | BDF: 0001:01:00.0 | UUID: b4ff74a0-0000-1000-80b2-fa0be8628b1a + ID: 2 | BDF: 0002:01:00.0 | UUID: a9ff74a0-0000-1000-8007-3066a98ba4a6 + ID: 3 | BDF: 0003:01:00.0 | UUID: 53ff74a0-0000-1000-80a0-a1ff3830f499 all | Selects all devices + -U, --cpu CPU [CPU ...] Select a CPU ID from the possible choices: + ID: 0 + ID: 1 + ID: 2 + ID: 3 + all | Selects all devices + -O, --core CORE [CORE ...] Select a Core ID from the possible choices: + ID: 0 - 95 + all | Selects all devices -f, --ucode-list, --fw-list All FW list information Command Modifiers: @@ -186,78 +226,161 @@ Command Modifiers: --csv Displays output in CSV format (human readable by default). --file FILE Saves output into a file on the provided path (stdout by default). --loglevel LEVEL Set the logging level from the possible choices: - DEBUG, INFO, WARNING, ERROR, CRITICAL + DEBUG, INFO, WARNING, ERROR, CRITICAL ``` ```bash ~$ amd-smi bad-pages --help usage: amd-smi bad-pages [-h] [--json | --csv] [--file FILE] [--loglevel LEVEL] - [-g GPU [GPU ...]] [-p] [-r] [-u] + [-g GPU [GPU ...] | -U CPU [CPU ...] | -O CORE [CORE ...]] [-p] + [-r] [-u] If no GPU is specified, return bad page information for all GPUs on the system. Bad Pages Arguments: - -h, --help show this help message and exit - -g, --gpu GPU [GPU ...] Select a GPU ID, BDF, or UUID from the possible choices: - ID: 0 | BDF:0000:23:00.0 | UUID:ffff73bf-0000-1000-80ff-ffffffffffff - all | Selects all devices - -p, --pending Displays all pending retired pages - -r, --retired Displays retired pages - -u, --un-res Displays unreservable pages + -h, --help show this help message and exit + -g, --gpu GPU [GPU ...] Select a GPU ID, BDF, or UUID from the possible choices: + ID: 0 | BDF: 0000:01:00.0 | UUID: 71ff74a0-0000-1000-8066-0a3c71d5f817 + ID: 1 | BDF: 0001:01:00.0 | UUID: b4ff74a0-0000-1000-80b2-fa0be8628b1a + ID: 2 | BDF: 0002:01:00.0 | UUID: a9ff74a0-0000-1000-8007-3066a98ba4a6 + ID: 3 | BDF: 0003:01:00.0 | UUID: 53ff74a0-0000-1000-80a0-a1ff3830f499 + all | Selects all devices + -U, --cpu CPU [CPU ...] Select a CPU ID from the possible choices: + ID: 0 + ID: 1 + ID: 2 + ID: 3 + all | Selects all devices + -O, --core CORE [CORE ...] Select a Core ID from the possible choices: + ID: 0 - 95 + all | Selects all devices + -p, --pending Displays all pending retired pages + -r, --retired Displays retired pages + -u, --un-res Displays unreservable pages Command Modifiers: - --json Displays output in JSON format (human readable by default). - --csv Displays output in CSV format (human readable by default). - --file FILE Saves output into a file on the provided path (stdout by default). - --loglevel LEVEL Set the logging level from the possible choices: - DEBUG, INFO, WARNING, ERROR, CRITICAL + --json Displays output in JSON format (human readable by default). + --csv Displays output in CSV format (human readable by default). + --file FILE Saves output into a file on the provided path (stdout by default). + --loglevel LEVEL Set the logging level from the possible choices: + DEBUG, INFO, WARNING, ERROR, CRITICAL ``` ```bash ~$ amd-smi metric --help usage: amd-smi metric [-h] [--json | --csv] [--file FILE] [--loglevel LEVEL] - [-g GPU [GPU ...]] [-w INTERVAL] [-W TIME] [-i ITERATIONS] [-m] [-u] - [-p] [-c] [-t] [-e] [-k] [-P] [-f] [-C] [-o] [-l] [-x] [-E] + [-g GPU [GPU ...] | -U CPU [CPU ...] | -O CORE [CORE ...]] + [-w INTERVAL] [-W TIME] [-i ITERATIONS] [-m] [-u] [-p] [-c] [-t] + [-e] [-P] [-k] [-f] [-C] [-o] [-l] [-x] [-E] [--cpu_power_metrics] + [--cpu_prochot] [--cpu_freq_metrics] [--cpu_c0_res] + [--cpu_lclk_dpm_level NBIOID] [--cpu_pwr_svi_telemtry_rails] + [--cpu_io_bandwidth IO_BW LINKID_NAME] + [--cpu_xgmi_bandwidth XGMI_BW LINKID_NAME] [--cpu_enable_apb] + [--cpu_disable_apb DF_PSTATE] [--set_cpu_pow_limit POW_LIMIT] + [--set_cpu_xgmi_link_width MIN_WIDTH MAX_WIDTH] + [--set_cpu_lclk_dpm_level NBIOID MIN_DPM MAX_DPM] + [--core_boost_limit] [--core_curr_active_freq_core_limit] + [--set_soc_boost_limit BOOST_LIMIT] + [--set_core_boost_limit BOOST_LIMIT] [--cpu_metrics_ver] + [--cpu_metrics_table] [--core_energy] [--socket_energy] + [--set_cpu_pwr_eff_mode MODE] [--cpu_ddr_bandwidth] [--cpu_temp] + [--cpu_dimm_temp_range_rate DIMM_ADDR] + [--cpu_dimm_pow_conumption DIMM_ADDR] + [--cpu_dimm_thermal_sensor DIMM_ADDR] + [--set_cpu_gmi3_link_width MIN_LW MAX_LW] + [--set_cpu_pcie_lnk_rate LINK_RATE] + [--set_cpu_df_pstate_range MAX_PSTATE MIN_PSTATE] If no GPU is specified, returns metric information for all GPUs on the system. If no metric argument is provided all metric information will be displayed. Metric arguments: - -h, --help show this help message and exit - -g, --gpu GPU [GPU ...] Select a GPU ID, BDF, or UUID from the possible choices: - ID: 0 | BDF:0000:23:00.0 | UUID:ffff73bf-0000-1000-80ff-ffffffffffff - all | Selects all devices - -w, --watch INTERVAL Reprint the command in a loop of INTERVAL seconds - -W, --watch_time TIME The total TIME to watch the given command - -i, --iterations ITERATIONS Total number of ITERATIONS to loop on the given command - -m, --mem-usage Memory usage per block - -u, --usage Displays engine usage information - -p, --power Current power usage - -c, --clock Average, max, and current clock frequencies - -t, --temperature Current temperatures - -e, --ecc Total number of ECC errors - -k, --ecc-block Number of ECC errors per block - -P, --pcie Current PCIe speed, width, and replay count - -f, --fan Current fan speed - -C, --voltage-curve Display voltage curve - -o, --overdrive Current GPU clock overdrive level - -l, --perf-level Current DPM performance level - -x, --xgmi-err XGMI error information since last read - -E, --energy Amount of energy consumed + -h, --help show this help message and exit + -g, --gpu GPU [GPU ...] Select a GPU ID, BDF, or UUID from the possible choices: + ID: 0 | BDF: 0000:01:00.0 | UUID: 71ff74a0-0000-1000-8066-0a3c71d5f817 + ID: 1 | BDF: 0001:01:00.0 | UUID: b4ff74a0-0000-1000-80b2-fa0be8628b1a + ID: 2 | BDF: 0002:01:00.0 | UUID: a9ff74a0-0000-1000-8007-3066a98ba4a6 + ID: 3 | BDF: 0003:01:00.0 | UUID: 53ff74a0-0000-1000-80a0-a1ff3830f499 + all | Selects all devices + -U, --cpu CPU [CPU ...] Select a CPU ID from the possible choices: + ID: 0 + ID: 1 + ID: 2 + ID: 3 + all | Selects all devices + -O, --core CORE [CORE ...] Select a Core ID from the possible choices: + ID: 0 - 95 + all | Selects all devices + -w, --watch INTERVAL Reprint the command in a loop of INTERVAL seconds + -W, --watch_time TIME The total TIME to watch the given command + -i, --iterations ITERATIONS Total number of ITERATIONS to loop on the given command + -m, --mem-usage Memory usage per block + -u, --usage Displays engine usage information + -p, --power Current power usage + -c, --clock Average, max, and current clock frequencies + -t, --temperature Current temperatures + -e, --ecc Total number of ECC errors + -P, --pcie Current PCIe speed, width, and replay count + -k, --ecc-block Number of ECC errors per block + -f, --fan Current fan speed + -C, --voltage-curve Display voltage curve + -o, --overdrive Current GPU clock overdrive level + -l, --perf-level Current DPM performance level + -x, --xgmi-err XGMI error information since last read + -E, --energy Amount of energy consumed + +CPU Option: + --cpu_power_metrics Cpu power metrics + --cpu_prochot Displays prochot status + --cpu_freq_metrics Displays currentFclkMemclk frequencies and cclk frequency limit + --cpu_c0_res Displays C0 residency + --cpu_lclk_dpm_level NBIOID Displays lclk dpm level range. Requires socket ID and nbio id as inputs + --cpu_pwr_svi_telemtry_rails Displays svi based telemetry for all rails + --cpu_io_bandwidth IO_BW LINKID_NAME Displays current IO bandwidth for the selected CPU. + input parameters are bandwidth type(1) and link ID encodings + i.e. P2, P3, G0 - G7 + --cpu_xgmi_bandwidth XGMI_BW LINKID_NAME Displays current XGMI bandwidth for the selected CPU + input parameters are bandwidth type(1,2,4) and link ID encodings + i.e. P2, P3, G0 - G7 + --cpu_enable_apb Enables the DF p-state performance boost algorithm + --cpu_disable_apb DF_PSTATE Disables the DF p-state performance boost algorithm. + --core_boost_limit Get booslimit for the selected cores + --core_curr_active_freq_core_limit Get Current CCLK limit set per Core + --cpu_metrics_ver Displays metrics table version + --cpu_metrics_table Displays metric table + --core_energy Displays core energy for the selected core + --socket_energy Displays socket energy for the selected socket + --cpu_ddr_bandwidth Displays per socket max ddr bw, current utilized bw and current utilized ddr bw in percentage + --cpu_temp Displays cpu socket temperature + --cpu_dimm_temp_range_rate DIMM_ADDR Displays dimm temperature range and refresh rate + --cpu_dimm_pow_conumption DIMM_ADDR Displays dimm power consumption + --cpu_dimm_thermal_sensor DIMM_ADDR Displays dimm thermal sensor + +Set Options: + --set_cpu_pow_limit POW_LIMIT Set power limit for the given socket. Input parameter is power limit value. + --set_cpu_xgmi_link_width MIN_WIDTH MAX_WIDTH Set max and Min linkwidth. Input parameters are min and max link width values + --set_cpu_lclk_dpm_level NBIOID MIN_DPM MAX_DPM Sets the max and min dpm level on a given NBIO. Inpur parameters are die_index, min dpm, max dpm. + --set_soc_boost_limit BOOST_LIMIT Sets the boost limit for the given socket. Input parameter is socket limit value + --set_core_boost_limit BOOST_LIMIT Sets the boost limit for the given core. Input parameter is core limit value + --set_cpu_pwr_eff_mode MODE Sets the power efficency mode policy. Input parameter is mode. + --set_cpu_gmi3_link_width MIN_LW MAX_LW Sets max and min gmi3 link width range + --set_cpu_pcie_lnk_rate LINK_RATE Sets pcie link rate + --set_cpu_df_pstate_range MAX_PSTATE MIN_PSTATE Sets max and min df-pstates Command Modifiers: - --json Displays output in JSON format (human readable by default). - --csv Displays output in CSV format (human readable by default). - --file FILE Saves output into a file on the provided path (stdout by default). - --loglevel LEVEL Set the logging level from the possible choices: - DEBUG, INFO, WARNING, ERROR, CRITICAL + --json Displays output in JSON format (human readable by default). + --csv Displays output in CSV format (human readable by default). + --file FILE Saves output into a file on the provided path (stdout by default). + --loglevel LEVEL Set the logging level from the possible choices: + DEBUG, INFO, WARNING, ERROR, CRITICAL ``` ```bash ~$ amd-smi process --help usage: amd-smi process [-h] [--json | --csv] [--file FILE] [--loglevel LEVEL] - [-g GPU [GPU ...]] [-w INTERVAL] [-W TIME] [-i ITERATIONS] [-G] - [-e] [-p PID] [-n NAME] + [-g GPU [GPU ...] | -U CPU [CPU ...] | -O CORE [CORE ...]] + [-w INTERVAL] [-W TIME] [-i ITERATIONS] [-G] [-e] [-p PID] + [-n NAME] If no GPU is specified, returns information for all GPUs on the system. If no process argument is provided all process information will be displayed. @@ -265,8 +388,20 @@ If no process argument is provided all process information will be displayed. Process arguments: -h, --help show this help message and exit -g, --gpu GPU [GPU ...] Select a GPU ID, BDF, or UUID from the possible choices: - ID: 0 | BDF:0000:23:00.0 | UUID:ffff73bf-0000-1000-80ff-ffffffffffff + ID: 0 | BDF: 0000:01:00.0 | UUID: 71ff74a0-0000-1000-8066-0a3c71d5f817 + ID: 1 | BDF: 0001:01:00.0 | UUID: b4ff74a0-0000-1000-80b2-fa0be8628b1a + ID: 2 | BDF: 0002:01:00.0 | UUID: a9ff74a0-0000-1000-8007-3066a98ba4a6 + ID: 3 | BDF: 0003:01:00.0 | UUID: 53ff74a0-0000-1000-80a0-a1ff3830f499 all | Selects all devices + -U, --cpu CPU [CPU ...] Select a CPU ID from the possible choices: + ID: 0 + ID: 1 + ID: 2 + ID: 3 + all | Selects all devices + -O, --core CORE [CORE ...] Select a Core ID from the possible choices: + ID: 0 - 95 + all | Selects all devices -w, --watch INTERVAL Reprint the command in a loop of INTERVAL seconds -W, --watch_time TIME The total TIME to watch the given command -i, --iterations ITERATIONS Total number of ITERATIONS to loop on the given command @@ -287,57 +422,82 @@ Command Modifiers: ```bash ~$ amd-smi event --help usage: amd-smi event [-h] [--json | --csv] [--file FILE] [--loglevel LEVEL] - [-g GPU [GPU ...]] + [-g GPU [GPU ...] | -U CPU [CPU ...] | -O CORE [CORE ...]] If no GPU is specified, returns event information for all GPUs on the system. Event Arguments: - -h, --help show this help message and exit - -g, --gpu GPU [GPU ...] Select a GPU ID, BDF, or UUID from the possible choices: - ID: 0 | BDF:0000:23:00.0 | UUID:ffff73bf-0000-1000-80ff-ffffffffffff - all | Selects all devices + -h, --help show this help message and exit + -g, --gpu GPU [GPU ...] Select a GPU ID, BDF, or UUID from the possible choices: + ID: 0 | BDF: 0000:01:00.0 | UUID: 71ff74a0-0000-1000-8066-0a3c71d5f817 + ID: 1 | BDF: 0001:01:00.0 | UUID: b4ff74a0-0000-1000-80b2-fa0be8628b1a + ID: 2 | BDF: 0002:01:00.0 | UUID: a9ff74a0-0000-1000-8007-3066a98ba4a6 + ID: 3 | BDF: 0003:01:00.0 | UUID: 53ff74a0-0000-1000-80a0-a1ff3830f499 + all | Selects all devices + -U, --cpu CPU [CPU ...] Select a CPU ID from the possible choices: + ID: 0 + ID: 1 + ID: 2 + ID: 3 + all | Selects all devices + -O, --core CORE [CORE ...] Select a Core ID from the possible choices: + ID: 0 - 95 + all | Selects all devices Command Modifiers: - --json Displays output in JSON format (human readable by default). - --csv Displays output in CSV format (human readable by default). - --file FILE Saves output into a file on the provided path (stdout by default). - --loglevel LEVEL Set the logging level from the possible choices: - DEBUG, INFO, WARNING, ERROR, CRITICAL + --json Displays output in JSON format (human readable by default). + --csv Displays output in CSV format (human readable by default). + --file FILE Saves output into a file on the provided path (stdout by default). + --loglevel LEVEL Set the logging level from the possible choices: + DEBUG, INFO, WARNING, ERROR, CRITICAL ``` ```bash ~$ amd-smi topology --help usage: amd-smi topology [-h] [--json | --csv] [--file FILE] [--loglevel LEVEL] - [-g GPU [GPU ...]] [-a] [-w] [-o] [-t] [-b] + [-g GPU [GPU ...] | -U CPU [CPU ...] | -O CORE [CORE ...]] [-a] + [-w] [-o] [-t] [-b] If no GPU is specified, returns information for all GPUs on the system. If no topology argument is provided all topology information will be displayed. Topology arguments: - -h, --help show this help message and exit - -g, --gpu GPU [GPU ...] Select a GPU ID, BDF, or UUID from the possible choices: - ID: 0 | BDF:0000:23:00.0 | UUID:ffff73bf-0000-1000-80ff-ffffffffffff - all | Selects all devices - -a, --access Displays link accessibility between GPUs - -w, --weight Displays relative weight between GPUs - -o, --hops Displays the number of hops between GPUs - -t, --link-type Displays the link type between GPUs - -b, --numa-bw Display max and min bandwidth between nodes + -h, --help show this help message and exit + -g, --gpu GPU [GPU ...] Select a GPU ID, BDF, or UUID from the possible choices: + ID: 0 | BDF: 0000:01:00.0 | UUID: 71ff74a0-0000-1000-8066-0a3c71d5f817 + ID: 1 | BDF: 0001:01:00.0 | UUID: b4ff74a0-0000-1000-80b2-fa0be8628b1a + ID: 2 | BDF: 0002:01:00.0 | UUID: a9ff74a0-0000-1000-8007-3066a98ba4a6 + ID: 3 | BDF: 0003:01:00.0 | UUID: 53ff74a0-0000-1000-80a0-a1ff3830f499 + all | Selects all devices + -U, --cpu CPU [CPU ...] Select a CPU ID from the possible choices: + ID: 0 + ID: 1 + ID: 2 + ID: 3 + all | Selects all devices + -O, --core CORE [CORE ...] Select a Core ID from the possible choices: + ID: 0 - 95 + all | Selects all devices + -a, --access Displays link accessibility between GPUs + -w, --weight Displays relative weight between GPUs + -o, --hops Displays the number of hops between GPUs + -t, --link-type Displays the link type between GPUs + -b, --numa-bw Display max and min bandwidth between nodes Command Modifiers: - --json Displays output in JSON format (human readable by default). - --csv Displays output in CSV format (human readable by default). - --file FILE Saves output into a file on the provided path (stdout by default). - --loglevel LEVEL Set the logging level from the possible choices: - DEBUG, INFO, WARNING, ERROR, CRITICAL - + --json Displays output in JSON format (human readable by default). + --csv Displays output in CSV format (human readable by default). + --file FILE Saves output into a file on the provided path (stdout by default). + --loglevel LEVEL Set the logging level from the possible choices: + DEBUG, INFO, WARNING, ERROR, CRITICAL ``` ```bash ~$ amd-smi set --help -usage: amd-smi set [-h] [--json | --csv] [--file FILE] [--loglevel LEVEL] -g GPU [GPU ...] - [-f %] [-l LEVEL] [-P SETPROFILE] [-d SCLKMAX] [-C PARTITION] - [-M PARTITION] [-o WATTS] +usage: amd-smi set [-h] [--json | --csv] [--file FILE] [--loglevel LEVEL] + (-g GPU [GPU ...] | -U CPU [CPU ...] | -O CORE [CORE ...]) [-f %] + [-l LEVEL] [-P SETPROFILE] [-d SCLKMAX] [-C PARTITION] [-M PARTITION] + [-o WATTS] A GPU must be specified to set a configuration. A set argument must be provided; Multiple set arguments are accepted @@ -345,8 +505,20 @@ A set argument must be provided; Multiple set arguments are accepted Set Arguments: -h, --help show this help message and exit -g, --gpu GPU [GPU ...] Select a GPU ID, BDF, or UUID from the possible choices: - ID: 0 | BDF:0000:23:00.0 | UUID:ffff73bf-0000-1000-80ff-ffffffffffff + ID: 0 | BDF: 0000:01:00.0 | UUID: 71ff74a0-0000-1000-8066-0a3c71d5f817 + ID: 1 | BDF: 0001:01:00.0 | UUID: b4ff74a0-0000-1000-80b2-fa0be8628b1a + ID: 2 | BDF: 0002:01:00.0 | UUID: a9ff74a0-0000-1000-8007-3066a98ba4a6 + ID: 3 | BDF: 0003:01:00.0 | UUID: 53ff74a0-0000-1000-80a0-a1ff3830f499 all | Selects all devices + -U, --cpu CPU [CPU ...] Select a CPU ID from the possible choices: + ID: 0 + ID: 1 + ID: 2 + ID: 3 + all | Selects all devices + -O, --core CORE [CORE ...] Select a Core ID from the possible choices: + ID: 0 - 95 + all | Selects all devices -f, --fan % Set GPU fan speed (0-255 or 0-100%) -l, --perf-level LEVEL Set performance level -P, --profile SETPROFILE Set power profile level (#) or a quoted string of custom profile attributes @@ -367,32 +539,45 @@ Command Modifiers: ```bash ~$ amd-smi reset --help -usage: amd-smi reset [-h] [--json | --csv] [--file FILE] [--loglevel LEVEL] -g GPU - [GPU ...] [-G] [-c] [-f] [-p] [-x] [-d] [-C] [-M] [-o] +usage: amd-smi reset [-h] [--json | --csv] [--file FILE] [--loglevel LEVEL] + (-g GPU [GPU ...] | -U CPU [CPU ...] | -O CORE [CORE ...]) [-G] [-c] + [-f] [-p] [-x] [-d] [-C] [-M] [-o] A GPU must be specified to reset a configuration. A reset argument must be provided; Multiple reset arguments are accepted Reset Arguments: - -h, --help show this help message and exit - -g, --gpu GPU [GPU ...] Select a GPU ID, BDF, or UUID from the possible choices: - ID: 0 | BDF:0000:23:00.0 | UUID:ffff73bf-0000-1000-80ff-ffffffffffff - all | Selects all devices - -G, --gpureset Reset the specified GPU - -c, --clocks Reset clocks and overdrive to default - -f, --fans Reset fans to automatic (driver) control - -p, --profile Reset power profile back to default - -x, --xgmierr Reset XGMI error counts - -d, --perf-determinism Disable performance determinism - -C, --compute-partition Reset compute partitions on the specified GPU - -M, --memory-partition Reset memory partitions on the specified GPU - -o, --power-cap Reset power capacity limit to max capable + -h, --help show this help message and exit + -g, --gpu GPU [GPU ...] Select a GPU ID, BDF, or UUID from the possible choices: + ID: 0 | BDF: 0000:01:00.0 | UUID: 71ff74a0-0000-1000-8066-0a3c71d5f817 + ID: 1 | BDF: 0001:01:00.0 | UUID: b4ff74a0-0000-1000-80b2-fa0be8628b1a + ID: 2 | BDF: 0002:01:00.0 | UUID: a9ff74a0-0000-1000-8007-3066a98ba4a6 + ID: 3 | BDF: 0003:01:00.0 | UUID: 53ff74a0-0000-1000-80a0-a1ff3830f499 + all | Selects all devices + -U, --cpu CPU [CPU ...] Select a CPU ID from the possible choices: + ID: 0 + ID: 1 + ID: 2 + ID: 3 + all | Selects all devices + -O, --core CORE [CORE ...] Select a Core ID from the possible choices: + ID: 0 - 95 + all | Selects all devices + -G, --gpureset Reset the specified GPU + -c, --clocks Reset clocks and overdrive to default + -f, --fans Reset fans to automatic (driver) control + -p, --profile Reset power profile back to default + -x, --xgmierr Reset XGMI error counts + -d, --perf-determinism Disable performance determinism + -C, --compute-partition Reset compute partitions on the specified GPU + -M, --memory-partition Reset memory partitions on the specified GPU + -o, --power-cap Reset power capacity limit to max capable Command Modifiers: - --json Displays output in JSON format (human readable by default). - --csv Displays output in CSV format (human readable by default). - --file FILE Saves output into a file on the provided path (stdout by default). - --loglevel LEVEL Set the logging level from the possible choices: + --json Displays output in JSON format (human readable by default). + --csv Displays output in CSV format (human readable by default). + --file FILE Saves output into a file on the provided path (stdout by default). + --loglevel LEVEL Set the logging level from the possible choices: DEBUG, INFO, WARNING, ERROR, CRITICAL ``` @@ -402,68 +587,486 @@ Here is some example output from the tool: ```bash ~$ amd-smi static +CPU: 0 +SMU: + FW_VERSION: 85:81:0 +INTERFACE_VERSION: + PROTO VERSION: 6 + +CPU: 1 +SMU: + FW_VERSION: 85:81:0 +INTERFACE_VERSION: + PROTO VERSION: 6 + +CPU: 2 +SMU: + FW_VERSION: 85:81:0 +INTERFACE_VERSION: + PROTO VERSION: 6 + +CPU: 3 +SMU: + FW_VERSION: 85:81:0 +INTERFACE_VERSION: + PROTO VERSION: 6 + + GPU: 0 ASIC: - MARKET_NAME: 0x73bf + MARKET_NAME: MI300A VENDOR_ID: 0x1002 VENDOR_NAME: Advanced Micro Devices Inc. [AMD/ATI] SUBVENDOR_ID: 0 - DEVICE_ID: 0x73bf - REV_ID: 0xc3 - ASIC_SERIAL: 0xffffffffffffffff - OAM_ID: N/A + DEVICE_ID: 0x74a0 + REV_ID: 0x0 + ASIC_SERIAL: 0x71660a3c71d5f817 + OAM_ID: 0 BUS: - BDF: 0000:23:00.0 - MAX_PCIE_SPEED: 16 GT/s + BDF: 0000:01:00.0 + MAX_PCIE_SPEED: 32 GT/s MAX_PCIE_LANES: 16 - PCIE_INTERFACE_VERSION: Gen 4 + PCIE_INTERFACE_VERSION: Gen 5 SLOT_TYPE: PCIE VBIOS: - NAME: NAVI21 Gaming XL D41209 - BUILD_DATE: 2020/10/29 13:30 - PART_NUMBER: 113-D4120900-101 - VERSION: 020.001.000.038.015720 + NAME: N/A + BUILD_DATE: N/A + PART_NUMBER: N/A + VERSION: N/A BOARD: MODEL_NUMBER: N/A - PRODUCT_SERIAL: 0 + PRODUCT_SERIAL: N/A FRU_ID: N/A MANUFACTURER_NAME: N/A PRODUCT_NAME: N/A LIMIT: - MAX_POWER: 203 W - CURRENT_POWER: 203 W - SLOWDOWN_EDGE_TEMPERATURE: 100 °C - SLOWDOWN_HOTSPOT_TEMPERATURE: 110 °C - SLOWDOWN_VRAM_TEMPERATURE: 100 °C - SHUTDOWN_EDGE_TEMPERATURE: 105 °C - SHUTDOWN_HOTSPOT_TEMPERATURE: 115 °C + MAX_POWER: 550 W + CURRENT_POWER: 0 W + SLOWDOWN_EDGE_TEMPERATURE: N/A + SLOWDOWN_HOTSPOT_TEMPERATURE: 100 °C + SLOWDOWN_VRAM_TEMPERATURE: 95 °C + SHUTDOWN_EDGE_TEMPERATURE: N/A + SHUTDOWN_HOTSPOT_TEMPERATURE: 110 °C SHUTDOWN_VRAM_TEMPERATURE: 105 °C DRIVER: DRIVER_NAME: amdgpu - DRIVER_VERSION: 6.1.10 + DRIVER_VERSION: 6.5.2 VRAM: - VRAM_TYPE: GDDR6 - VRAM_VENDOR: SAMSUNG - VRAM_SIZE_MB: 16368 MB + VRAM_TYPE: HBM + VRAM_VENDOR: HYNIX + VRAM_SIZE_MB: 96432 MB CACHE: CACHE 0: - CACHE_SIZE: 16 KB + CACHE_SIZE: 32 KB CACHE_LEVEL: 1 - MAX_NUM_CU_SHARED: 1 - NUM_CACHE_INSTANCE: 304 + MAX_NUM_CU_SHARED: 2 + NUM_CACHE_INSTANCE: 348 + DATA_CACHE: ENABLED + SIMD_CACHE: ENABLED + CACHE 1: + CACHE_SIZE: 64 KB + CACHE_LEVEL: 1 + MAX_NUM_CU_SHARED: 2 + NUM_CACHE_INSTANCE: 120 + INST_CACHE: ENABLED + SIMD_CACHE: ENABLED + CACHE 2: + CACHE_SIZE: 24576 KB + CACHE_LEVEL: 2 + MAX_NUM_CU_SHARED: 228 + NUM_CACHE_INSTANCE: 1 + DATA_CACHE: ENABLED + SIMD_CACHE: ENABLED + CACHE 3: + CACHE_SIZE: 262144 KB + CACHE_LEVEL: 3 + MAX_NUM_CU_SHARED: 228 + NUM_CACHE_INSTANCE: 1 + DATA_CACHE: ENABLED + SIMD_CACHE: ENABLED RAS: - EEPROM_VERSION: N/A - PARITY_SCHEMA: N/A - SINGLE_BIT_SCHEMA: N/A - DOUBLE_BIT_SCHEMA: N/A - POISON_SCHEMA: N/A - ECC_BLOCK_STATE: N/A + EEPROM_VERSION: 0x0 + PARITY_SCHEMA: DISABLED + SINGLE_BIT_SCHEMA: DISABLED + DOUBLE_BIT_SCHEMA: DISABLED + POISON_SCHEMA: ENABLED + ECC_BLOCK_STATE: + BLOCK: UMC + STATUS: DISABLED + BLOCK: SDMA + STATUS: ENABLED + BLOCK: GFX + STATUS: ENABLED + BLOCK: MMHUB + STATUS: ENABLED + BLOCK: ATHUB + STATUS: DISABLED + BLOCK: PCIE_BIF + STATUS: DISABLED + BLOCK: HDP + STATUS: DISABLED + BLOCK: XGMI_WAFL + STATUS: DISABLED + BLOCK: DF + STATUS: DISABLED + BLOCK: SMN + STATUS: DISABLED + BLOCK: SEM + STATUS: DISABLED + BLOCK: MP0 + STATUS: DISABLED + BLOCK: MP1 + STATUS: DISABLED + BLOCK: FUSE + STATUS: DISABLED PARTITION: - COMPUTE_PARTITION: N/A - MEMORY_PARTITION: N/A + COMPUTE_PARTITION: SPX + MEMORY_PARTITION: NPS1 NUMA: NODE: 0 - AFFINITY: NONE + AFFINITY: 0 + +GPU: 1 +ASIC: + MARKET_NAME: MI300A + VENDOR_ID: 0x1002 + VENDOR_NAME: Advanced Micro Devices Inc. [AMD/ATI] + SUBVENDOR_ID: 0 + DEVICE_ID: 0x74a0 + REV_ID: 0x0 + ASIC_SERIAL: 0xb4b2fa0be8628b1a + OAM_ID: 1 +BUS: + BDF: 0001:01:00.0 + MAX_PCIE_SPEED: 32 GT/s + MAX_PCIE_LANES: 16 + PCIE_INTERFACE_VERSION: Gen 5 + SLOT_TYPE: PCIE +VBIOS: + NAME: N/A + BUILD_DATE: N/A + PART_NUMBER: N/A + VERSION: N/A +BOARD: + MODEL_NUMBER: N/A + PRODUCT_SERIAL: N/A + FRU_ID: N/A + MANUFACTURER_NAME: N/A + PRODUCT_NAME: N/A +LIMIT: + MAX_POWER: 550 W + CURRENT_POWER: 0 W + SLOWDOWN_EDGE_TEMPERATURE: N/A + SLOWDOWN_HOTSPOT_TEMPERATURE: 100 °C + SLOWDOWN_VRAM_TEMPERATURE: 95 °C + SHUTDOWN_EDGE_TEMPERATURE: N/A + SHUTDOWN_HOTSPOT_TEMPERATURE: 110 °C + SHUTDOWN_VRAM_TEMPERATURE: 105 °C +DRIVER: + DRIVER_NAME: amdgpu + DRIVER_VERSION: 6.5.2 +VRAM: + VRAM_TYPE: HBM + VRAM_VENDOR: HYNIX + VRAM_SIZE_MB: 96432 MB +CACHE: + CACHE 0: + CACHE_SIZE: 32 KB + CACHE_LEVEL: 1 + MAX_NUM_CU_SHARED: 2 + NUM_CACHE_INSTANCE: 348 + DATA_CACHE: ENABLED + SIMD_CACHE: ENABLED + CACHE 1: + CACHE_SIZE: 64 KB + CACHE_LEVEL: 1 + MAX_NUM_CU_SHARED: 2 + NUM_CACHE_INSTANCE: 120 + INST_CACHE: ENABLED + SIMD_CACHE: ENABLED + CACHE 2: + CACHE_SIZE: 24576 KB + CACHE_LEVEL: 2 + MAX_NUM_CU_SHARED: 228 + NUM_CACHE_INSTANCE: 1 + DATA_CACHE: ENABLED + SIMD_CACHE: ENABLED + CACHE 3: + CACHE_SIZE: 262144 KB + CACHE_LEVEL: 3 + MAX_NUM_CU_SHARED: 228 + NUM_CACHE_INSTANCE: 1 + DATA_CACHE: ENABLED + SIMD_CACHE: ENABLED +RAS: + EEPROM_VERSION: 0x0 + PARITY_SCHEMA: DISABLED + SINGLE_BIT_SCHEMA: DISABLED + DOUBLE_BIT_SCHEMA: DISABLED + POISON_SCHEMA: ENABLED + ECC_BLOCK_STATE: + BLOCK: UMC + STATUS: DISABLED + BLOCK: SDMA + STATUS: ENABLED + BLOCK: GFX + STATUS: ENABLED + BLOCK: MMHUB + STATUS: ENABLED + BLOCK: ATHUB + STATUS: DISABLED + BLOCK: PCIE_BIF + STATUS: DISABLED + BLOCK: HDP + STATUS: DISABLED + BLOCK: XGMI_WAFL + STATUS: DISABLED + BLOCK: DF + STATUS: DISABLED + BLOCK: SMN + STATUS: DISABLED + BLOCK: SEM + STATUS: DISABLED + BLOCK: MP0 + STATUS: DISABLED + BLOCK: MP1 + STATUS: DISABLED + BLOCK: FUSE + STATUS: DISABLED +PARTITION: + COMPUTE_PARTITION: SPX + MEMORY_PARTITION: NPS1 +NUMA: + NODE: 1 + AFFINITY: 1 + +GPU: 2 +ASIC: + MARKET_NAME: MI300A + VENDOR_ID: 0x1002 + VENDOR_NAME: Advanced Micro Devices Inc. [AMD/ATI] + SUBVENDOR_ID: 0 + DEVICE_ID: 0x74a0 + REV_ID: 0x0 + ASIC_SERIAL: 0xa9073066a98ba4a6 + OAM_ID: 2 +BUS: + BDF: 0002:01:00.0 + MAX_PCIE_SPEED: 32 GT/s + MAX_PCIE_LANES: 16 + PCIE_INTERFACE_VERSION: Gen 5 + SLOT_TYPE: PCIE +VBIOS: + NAME: N/A + BUILD_DATE: N/A + PART_NUMBER: N/A + VERSION: N/A +BOARD: + MODEL_NUMBER: N/A + PRODUCT_SERIAL: N/A + FRU_ID: N/A + MANUFACTURER_NAME: N/A + PRODUCT_NAME: N/A +LIMIT: + MAX_POWER: 550 W + CURRENT_POWER: 0 W + SLOWDOWN_EDGE_TEMPERATURE: N/A + SLOWDOWN_HOTSPOT_TEMPERATURE: 100 °C + SLOWDOWN_VRAM_TEMPERATURE: 95 °C + SHUTDOWN_EDGE_TEMPERATURE: N/A + SHUTDOWN_HOTSPOT_TEMPERATURE: 110 °C + SHUTDOWN_VRAM_TEMPERATURE: 105 °C +DRIVER: + DRIVER_NAME: amdgpu + DRIVER_VERSION: 6.5.2 +VRAM: + VRAM_TYPE: HBM + VRAM_VENDOR: HYNIX + VRAM_SIZE_MB: 96432 MB +CACHE: + CACHE 0: + CACHE_SIZE: 32 KB + CACHE_LEVEL: 1 + MAX_NUM_CU_SHARED: 2 + NUM_CACHE_INSTANCE: 348 + DATA_CACHE: ENABLED + SIMD_CACHE: ENABLED + CACHE 1: + CACHE_SIZE: 64 KB + CACHE_LEVEL: 1 + MAX_NUM_CU_SHARED: 2 + NUM_CACHE_INSTANCE: 120 + INST_CACHE: ENABLED + SIMD_CACHE: ENABLED + CACHE 2: + CACHE_SIZE: 24576 KB + CACHE_LEVEL: 2 + MAX_NUM_CU_SHARED: 228 + NUM_CACHE_INSTANCE: 1 + DATA_CACHE: ENABLED + SIMD_CACHE: ENABLED + CACHE 3: + CACHE_SIZE: 262144 KB + CACHE_LEVEL: 3 + MAX_NUM_CU_SHARED: 228 + NUM_CACHE_INSTANCE: 1 + DATA_CACHE: ENABLED + SIMD_CACHE: ENABLED +RAS: + EEPROM_VERSION: 0x0 + PARITY_SCHEMA: DISABLED + SINGLE_BIT_SCHEMA: DISABLED + DOUBLE_BIT_SCHEMA: DISABLED + POISON_SCHEMA: ENABLED + ECC_BLOCK_STATE: + BLOCK: UMC + STATUS: DISABLED + BLOCK: SDMA + STATUS: ENABLED + BLOCK: GFX + STATUS: ENABLED + BLOCK: MMHUB + STATUS: ENABLED + BLOCK: ATHUB + STATUS: DISABLED + BLOCK: PCIE_BIF + STATUS: DISABLED + BLOCK: HDP + STATUS: DISABLED + BLOCK: XGMI_WAFL + STATUS: DISABLED + BLOCK: DF + STATUS: DISABLED + BLOCK: SMN + STATUS: DISABLED + BLOCK: SEM + STATUS: DISABLED + BLOCK: MP0 + STATUS: DISABLED + BLOCK: MP1 + STATUS: DISABLED + BLOCK: FUSE + STATUS: DISABLED +PARTITION: + COMPUTE_PARTITION: SPX + MEMORY_PARTITION: NPS1 +NUMA: + NODE: 2 + AFFINITY: 2 + +GPU: 3 +ASIC: + MARKET_NAME: MI300A + VENDOR_ID: 0x1002 + VENDOR_NAME: Advanced Micro Devices Inc. [AMD/ATI] + SUBVENDOR_ID: 0 + DEVICE_ID: 0x74a0 + REV_ID: 0x0 + ASIC_SERIAL: 0x53a0a1ff3830f499 + OAM_ID: 3 +BUS: + BDF: 0003:01:00.0 + MAX_PCIE_SPEED: 32 GT/s + MAX_PCIE_LANES: 16 + PCIE_INTERFACE_VERSION: Gen 5 + SLOT_TYPE: PCIE +VBIOS: + NAME: N/A + BUILD_DATE: N/A + PART_NUMBER: N/A + VERSION: N/A +BOARD: + MODEL_NUMBER: N/A + PRODUCT_SERIAL: N/A + FRU_ID: N/A + MANUFACTURER_NAME: N/A + PRODUCT_NAME: N/A +LIMIT: + MAX_POWER: 550 W + CURRENT_POWER: 0 W + SLOWDOWN_EDGE_TEMPERATURE: N/A + SLOWDOWN_HOTSPOT_TEMPERATURE: 100 °C + SLOWDOWN_VRAM_TEMPERATURE: 95 °C + SHUTDOWN_EDGE_TEMPERATURE: N/A + SHUTDOWN_HOTSPOT_TEMPERATURE: 110 °C + SHUTDOWN_VRAM_TEMPERATURE: 105 °C +DRIVER: + DRIVER_NAME: amdgpu + DRIVER_VERSION: 6.5.2 +VRAM: + VRAM_TYPE: HBM + VRAM_VENDOR: HYNIX + VRAM_SIZE_MB: 96432 MB +CACHE: + CACHE 0: + CACHE_SIZE: 32 KB + CACHE_LEVEL: 1 + MAX_NUM_CU_SHARED: 2 + NUM_CACHE_INSTANCE: 348 + DATA_CACHE: ENABLED + SIMD_CACHE: ENABLED + CACHE 1: + CACHE_SIZE: 64 KB + CACHE_LEVEL: 1 + MAX_NUM_CU_SHARED: 2 + NUM_CACHE_INSTANCE: 120 + INST_CACHE: ENABLED + SIMD_CACHE: ENABLED + CACHE 2: + CACHE_SIZE: 24576 KB + CACHE_LEVEL: 2 + MAX_NUM_CU_SHARED: 228 + NUM_CACHE_INSTANCE: 1 + DATA_CACHE: ENABLED + SIMD_CACHE: ENABLED + CACHE 3: + CACHE_SIZE: 262144 KB + CACHE_LEVEL: 3 + MAX_NUM_CU_SHARED: 228 + NUM_CACHE_INSTANCE: 1 + DATA_CACHE: ENABLED + SIMD_CACHE: ENABLED +RAS: + EEPROM_VERSION: 0x0 + PARITY_SCHEMA: DISABLED + SINGLE_BIT_SCHEMA: DISABLED + DOUBLE_BIT_SCHEMA: DISABLED + POISON_SCHEMA: ENABLED + ECC_BLOCK_STATE: + BLOCK: UMC + STATUS: DISABLED + BLOCK: SDMA + STATUS: ENABLED + BLOCK: GFX + STATUS: ENABLED + BLOCK: MMHUB + STATUS: ENABLED + BLOCK: ATHUB + STATUS: DISABLED + BLOCK: PCIE_BIF + STATUS: DISABLED + BLOCK: HDP + STATUS: DISABLED + BLOCK: XGMI_WAFL + STATUS: DISABLED + BLOCK: DF + STATUS: DISABLED + BLOCK: SMN + STATUS: DISABLED + BLOCK: SEM + STATUS: DISABLED + BLOCK: MP0 + STATUS: DISABLED + BLOCK: MP1 + STATUS: DISABLED + BLOCK: FUSE + STATUS: DISABLED +PARTITION: + COMPUTE_PARTITION: SPX + MEMORY_PARTITION: NPS1 +NUMA: + NODE: 3 + AFFINITY: 3 ``` ## Disclaimer From 27fbbc338877e98ada55ea7e744d9e32a9129f7c Mon Sep 17 00:00:00 2001 From: khashaik Date: Wed, 10 Jan 2024 01:29:28 -0500 Subject: [PATCH 20/22] amdsmi_cli: Update help section - Update help section Change-Id: Ida8022a27ecc9df3ebef94e27e89624c18a9cf46 --- amdsmi_cli/amdsmi_parser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/amdsmi_cli/amdsmi_parser.py b/amdsmi_cli/amdsmi_parser.py index c8b978e62a..f419b724f2 100644 --- a/amdsmi_cli/amdsmi_parser.py +++ b/amdsmi_cli/amdsmi_parser.py @@ -575,7 +575,7 @@ class AMDSMIParser(argparse.ArgumentParser): \n input parameters are bandwidth type(1,2,4) and link ID encodings\ \n i.e. P2, P3, G0 - G7" cpu_enable_apb_help = "Enables the DF p-state performance boost algorithm" - cpu_disable_apb_help = "Disables the DF p-state performance boost alogorithm." + cpu_disable_apb_help = "Disables the DF p-state performance boost algorithm." "Input parameter is DFPstate (0 -3 )" set_cpu_pow_limit_help = "Set power limit for the given socket. Input parameter is \ power limit value." @@ -597,7 +597,7 @@ core limit value" cpu_ddr_bandwidth_help = "Displays per socket max ddr bw, current utilized bw and current utilized ddr bw in percentage" cpu_temp_help = "Displays cpu socket temperature" cpu_dimm_temp_range_rate_help = "Displays dimm temperature range and refresh rate" - cpu_dimm_pow_conumption_help = "Displays dimm power conumption" + cpu_dimm_pow_conumption_help = "Displays dimm power consumption" cpu_dimm_thermal_sensor_help = "Displays dimm thermal sensor" set_cpu_gmi3_link_width_help = "Sets max and min gmi3 link width range" set_cpu_pcie_lnk_rate_help = "Sets pcie link rate" From 5d0b47966199aef87c0514ff27cac6aacefd8df1 Mon Sep 17 00:00:00 2001 From: Deepak Mewar Date: Thu, 11 Jan 2024 06:54:19 -0500 Subject: [PATCH 21/22] amdsmi library updated for esmi error status mapping to amdsmi Change-Id: I7e4dd146a1a9af496556efcf811b2e1ed565b09e --- example/amdsmi_esmi_intg_example.cc | 53 ++++++---- include/amd_smi/amdsmi.h | 4 +- src/amd_smi/amd_smi.cc | 159 +++++++++++++++------------- 3 files changed, 120 insertions(+), 96 deletions(-) diff --git a/example/amdsmi_esmi_intg_example.cc b/example/amdsmi_esmi_intg_example.cc index 376d8ababb..fc3af395c8 100644 --- a/example/amdsmi_esmi_intg_example.cc +++ b/example/amdsmi_esmi_intg_example.cc @@ -58,11 +58,11 @@ { \ if (RET != AMDSMI_STATUS_SUCCESS) { \ const char *err_str; \ - const char **status_str; \ - cout << "AMDSMI call returned " << RET << " at line " \ - << __LINE__ << endl; \ - status_str = amdsmi_get_esmi_err_msg(RET, &err_str); \ - cout << *status_str << endl; \ + amdsmi_status_t status; \ + status = amdsmi_get_esmi_err_msg(RET, &err_str); \ + std::cout << "AMDSMI call returned " << status << " at line " \ + << __LINE__ << std::endl; \ + std::cout << err_str << std::endl; \ return RET; \ } \ } @@ -130,14 +130,16 @@ int main(int argc, char **argv) { for (uint32_t index = 0; index < plist.size(); index++) { ret = amdsmi_get_cpu_hsmp_proto_ver(plist[index], &proto_ver); - CHK_AMDSMI_RET(ret) + if(ret != AMDSMI_STATUS_SUCCESS) + cout<<"Failed to get hsmp proto version"<<"["<(socket_power)/1000<<"\t|"; @@ -210,7 +219,8 @@ int main(int argc, char **argv) { cout<<"\n| PowerLimit (Watts)\t\t | "; ret = amdsmi_get_cpu_socket_power_cap(plist[index], &power_limit); - CHK_AMDSMI_RET(ret) + if(ret != AMDSMI_STATUS_SUCCESS) + cout<<"Failed to get cpu socket power cap"<<"["<(power_limit)/1000<<"\t|"; @@ -223,7 +233,8 @@ int main(int argc, char **argv) { cout<<"\n| PowerLimitMax (Watts)\t\t | "; ret = amdsmi_get_cpu_socket_power_cap_max(plist[index], &power_max); - CHK_AMDSMI_RET(ret) + if(ret != AMDSMI_STATUS_SUCCESS) + cout<<"Failed to get cpu socket power cap max"<<"["<(power_max)/1000<<"\t|"; @@ -237,15 +248,21 @@ int main(int argc, char **argv) { power_max = 0; cout<<"\nEnter the max power to be set:\n"; cin>>input_power; + ret = amdsmi_get_cpu_socket_power_cap_max(plist[index], &power_max); - CHK_AMDSMI_RET(ret) + if(ret != AMDSMI_STATUS_SUCCESS) + cout<<"Failed to get cpu socket power cap max"<<"["< power_max)) { cout<<"Input power is more than max power limit," " limiting to "<(power_max)/1000<<"Watts\n"; input_power = power_max; } + ret = amdsmi_set_cpu_socket_power_cap(plist[index], input_power); - CHK_AMDSMI_RET(ret) + if(ret != AMDSMI_STATUS_SUCCESS) + cout<<"Failed to set cpu socket power cap"<<"["<(input_power)/1000<<" Watts successfully\n"; @@ -253,8 +270,10 @@ int main(int argc, char **argv) { power_limit = 0; cout<<"\n| PowerLimit (Watts) \t\t | "; + ret = amdsmi_get_cpu_socket_power_cap(plist[index], &power_limit); - CHK_AMDSMI_RET(ret) + if(ret != AMDSMI_STATUS_SUCCESS) + cout<<"Failed to get cpu socket power cap"<<"["<(power_limit)/1000<<"\t|"; @@ -270,11 +289,9 @@ int main(int argc, char **argv) { amdsmi_hsmp_metric_table_t mtbl = {}; ret = amdsmi_get_metrics_table(plist[index], &mtbl); - CHK_AMDSMI_RET(ret) if (ret != AMDSMI_STATUS_SUCCESS) { - cout<<"Failed to get Metrics Table for CPU["<(status)) + return iter.second; + } + return AMDSMI_STATUS_SUCCESS; +} + amdsmi_status_t amdsmi_get_cpu_hsmp_proto_ver(amdsmi_processor_handle processor_handle, uint32_t *proto_ver) { @@ -2719,10 +2728,10 @@ amdsmi_status_t amdsmi_get_cpu_hsmp_proto_ver(amdsmi_processor_handle processor_ return AMDSMI_STATUS_INVAL; status = static_cast(esmi_hsmp_proto_ver_get(&hsmp_proto_ver)); - *proto_ver = hsmp_proto_ver; - if (status != AMDSMI_STATUS_SUCCESS) - return status; + return amdsmi_errno_to_esmi_status(status); + + *proto_ver = hsmp_proto_ver; return AMDSMI_STATUS_SUCCESS; } @@ -2739,14 +2748,13 @@ amdsmi_status_t amdsmi_get_cpu_smu_fw_version(amdsmi_processor_handle processor_ return AMDSMI_STATUS_INVAL; status = static_cast(esmi_smu_fw_version_get(&smu_fw)); + if (status != AMDSMI_STATUS_SUCCESS) + return amdsmi_errno_to_esmi_status(status); amdsmi_smu_fw->major = smu_fw.major; amdsmi_smu_fw->minor = smu_fw.minor; amdsmi_smu_fw->debug = smu_fw.debug; - if (status != AMDSMI_STATUS_SUCCESS) - return status; - return AMDSMI_STATUS_SUCCESS; } @@ -2769,10 +2777,10 @@ amdsmi_status_t amdsmi_get_cpu_core_energy(amdsmi_processor_handle processor_han core_ind = (uint8_t)std::stoi(proc_id, NULL, 0); status = static_cast(esmi_core_energy_get(core_ind, &core_input)); - *penergy = core_input; - if (status != AMDSMI_STATUS_SUCCESS) - return status; + return amdsmi_errno_to_esmi_status(status); + + *penergy = core_input; return AMDSMI_STATUS_SUCCESS; @@ -2797,10 +2805,10 @@ amdsmi_status_t amdsmi_get_cpu_socket_energy(amdsmi_processor_handle processor_h sock_ind = (uint8_t)std::stoi(proc_id, NULL, 0); status = static_cast(esmi_socket_energy_get(sock_ind, &pkg_input)); - *penergy = pkg_input; - if (status != AMDSMI_STATUS_SUCCESS) - return status; + return amdsmi_errno_to_esmi_status(status); + + *penergy = pkg_input; return AMDSMI_STATUS_SUCCESS; } @@ -2824,10 +2832,10 @@ amdsmi_status_t amdsmi_get_cpu_prochot_status(amdsmi_processor_handle processor_ sock_ind = (uint8_t)std::stoi(proc_id, NULL, 0); status = static_cast(esmi_prochot_status_get(sock_ind, &phot)); - *prochot = phot; - if (status != AMDSMI_STATUS_SUCCESS) - return status; + return amdsmi_errno_to_esmi_status(status); + + *prochot = phot; return AMDSMI_STATUS_SUCCESS; } @@ -2851,12 +2859,12 @@ amdsmi_status_t amdsmi_get_cpu_fclk_mclk(amdsmi_processor_handle processor_handl sock_ind = (uint8_t)std::stoi(proc_id, NULL, 0); status = static_cast(esmi_fclk_mclk_get(sock_ind, &f_clk, &m_clk)); + if (status != AMDSMI_STATUS_SUCCESS) + return amdsmi_errno_to_esmi_status(status); + *fclk = f_clk; *mclk = m_clk; - if (status != AMDSMI_STATUS_SUCCESS) - return status; - return AMDSMI_STATUS_SUCCESS; } @@ -2879,10 +2887,10 @@ amdsmi_status_t amdsmi_get_cpu_cclk_limit(amdsmi_processor_handle processor_hand sock_ind = (uint8_t)std::stoi(proc_id, NULL, 0); status = static_cast(esmi_cclk_limit_get(sock_ind, &c_clk)); - *cclk = c_clk; - if (status != AMDSMI_STATUS_SUCCESS) - return status; + return amdsmi_errno_to_esmi_status(status); + + *cclk = c_clk; return AMDSMI_STATUS_SUCCESS; } @@ -2906,10 +2914,10 @@ amdsmi_status_t amdsmi_get_cpu_socket_current_active_freq_limit(amdsmi_processor sock_ind = (uint8_t)std::stoi(proc_id, NULL, 0); status = static_cast(esmi_socket_current_active_freq_limit_get(sock_ind, &limit, src_type)); - *freq = limit; - if (status != AMDSMI_STATUS_SUCCESS) - return status; + return amdsmi_errno_to_esmi_status(status); + + *freq = limit; return AMDSMI_STATUS_SUCCESS; } @@ -2934,12 +2942,12 @@ amdsmi_status_t amdsmi_get_cpu_socket_freq_range(amdsmi_processor_handle process sock_ind = (uint8_t)std::stoi(proc_id, NULL, 0); status = static_cast(esmi_socket_freq_range_get(sock_ind, &f_max, &f_min)); + if (status != AMDSMI_STATUS_SUCCESS) + return amdsmi_errno_to_esmi_status(status); + *fmax = f_max; *fmin = f_min; - if (status != AMDSMI_STATUS_SUCCESS) - return status; - return AMDSMI_STATUS_SUCCESS; } @@ -2962,10 +2970,10 @@ amdsmi_status_t amdsmi_get_cpu_core_current_freq_limit(amdsmi_processor_handle p core_ind = (uint8_t)std::stoi(proc_id, NULL, 0); status = static_cast(esmi_current_freq_limit_core_get(core_ind, &c_clk)); - *freq = c_clk; - if (status != AMDSMI_STATUS_SUCCESS) - return status; + return amdsmi_errno_to_esmi_status(status); + + *freq = c_clk; return AMDSMI_STATUS_SUCCESS; @@ -2990,10 +2998,10 @@ amdsmi_status_t amdsmi_get_cpu_socket_power(amdsmi_processor_handle processor_ha sock_ind = (uint8_t)std::stoi(proc_id, NULL, 0); status = static_cast(esmi_socket_power_get(sock_ind, &avg_power)); - *ppower = avg_power; - if (status != AMDSMI_STATUS_SUCCESS) - return status; + return amdsmi_errno_to_esmi_status(status); + + *ppower = avg_power; return AMDSMI_STATUS_SUCCESS; } @@ -3017,10 +3025,10 @@ amdsmi_status_t amdsmi_get_cpu_socket_power_cap(amdsmi_processor_handle processo sock_ind = (uint8_t)std::stoi(proc_id, NULL, 0); status = static_cast(esmi_socket_power_cap_get(sock_ind, &p_cap)); - *pcap = p_cap; - if (status != AMDSMI_STATUS_SUCCESS) - return status; + return amdsmi_errno_to_esmi_status(status); + + *pcap = p_cap; return AMDSMI_STATUS_SUCCESS; } @@ -3044,10 +3052,10 @@ amdsmi_status_t amdsmi_get_cpu_socket_power_cap_max(amdsmi_processor_handle proc sock_ind = (uint8_t)std::stoi(proc_id, NULL, 0); status = static_cast(esmi_socket_power_cap_max_get(sock_ind, &p_max)); - *pmax = p_max; - if (status != AMDSMI_STATUS_SUCCESS) - return status; + return amdsmi_errno_to_esmi_status(status); + + *pmax = p_max; return AMDSMI_STATUS_SUCCESS; } @@ -3071,10 +3079,10 @@ amdsmi_status_t amdsmi_get_cpu_pwr_svi_telemetry_all_rails(amdsmi_processor_hand sock_ind = (uint8_t)std::stoi(proc_id, NULL, 0); status = static_cast(esmi_pwr_svi_telemetry_all_rails_get(sock_ind, &pow)); - *power = pow; - if (status != AMDSMI_STATUS_SUCCESS) - return status; + return amdsmi_errno_to_esmi_status(status); + + *power = pow; return AMDSMI_STATUS_SUCCESS; } @@ -3099,7 +3107,7 @@ amdsmi_status_t amdsmi_set_cpu_socket_power_cap(amdsmi_processor_handle processo status = static_cast(esmi_socket_power_cap_set(sock_ind, pcap)); if (status != AMDSMI_STATUS_SUCCESS) - return status; + return amdsmi_errno_to_esmi_status(status); return AMDSMI_STATUS_SUCCESS; } @@ -3124,7 +3132,7 @@ amdsmi_status_t amdsmi_set_cpu_pwr_efficiency_mode(amdsmi_processor_handle proce status = static_cast(esmi_pwr_efficiency_mode_set(sock_ind, mode)); if (status != AMDSMI_STATUS_SUCCESS) - return status; + return amdsmi_errno_to_esmi_status(status); return AMDSMI_STATUS_SUCCESS; } @@ -3148,10 +3156,10 @@ amdsmi_status_t amdsmi_get_cpu_core_boostlimit(amdsmi_processor_handle processor core_ind = (uint8_t)std::stoi(proc_id, NULL, 0); status = static_cast(esmi_core_boostlimit_get(core_ind, &boostlimit)); - *pboostlimit = boostlimit; - if (status != AMDSMI_STATUS_SUCCESS) - return status; + return amdsmi_errno_to_esmi_status(status); + + *pboostlimit = boostlimit; return AMDSMI_STATUS_SUCCESS; } @@ -3175,10 +3183,10 @@ amdsmi_status_t amdsmi_get_cpu_socket_c0_residency(amdsmi_processor_handle proce sock_ind = (uint8_t)std::stoi(proc_id, NULL, 0); status = static_cast(esmi_socket_c0_residency_get(sock_ind, &res)); - *pc0_residency = res; - if (status != AMDSMI_STATUS_SUCCESS) - return status; + return amdsmi_errno_to_esmi_status(status); + + *pc0_residency = res; return AMDSMI_STATUS_SUCCESS; } @@ -3201,9 +3209,8 @@ amdsmi_status_t amdsmi_set_cpu_core_boostlimit(amdsmi_processor_handle processor core_ind = (uint8_t)std::stoi(proc_id, NULL, 0); status = static_cast(esmi_core_boostlimit_set(core_ind, boostlimit)); - if (status != AMDSMI_STATUS_SUCCESS) - return status; + return amdsmi_errno_to_esmi_status(status); return AMDSMI_STATUS_SUCCESS; } @@ -3228,7 +3235,7 @@ amdsmi_status_t amdsmi_set_cpu_socket_boostlimit(amdsmi_processor_handle process status = static_cast(esmi_socket_boostlimit_set(sock_ind, boostlimit)); if (status != AMDSMI_STATUS_SUCCESS) - return status; + return amdsmi_errno_to_esmi_status(status); return AMDSMI_STATUS_SUCCESS; } @@ -3246,7 +3253,7 @@ amdsmi_status_t amdsmi_get_cpu_ddr_bw(amdsmi_processor_handle processor_handle, status = static_cast(esmi_ddr_bw_get(&ddr)); if (status != AMDSMI_STATUS_SUCCESS) - return status; + return amdsmi_errno_to_esmi_status(status); ddr_bw->max_bw = ddr.max_bw; ddr_bw->utilized_bw = ddr.utilized_bw; @@ -3275,7 +3282,7 @@ amdsmi_status_t amdsmi_get_cpu_socket_temperature(amdsmi_processor_handle proces status = static_cast(esmi_socket_temperature_get(sock_ind, &tmon)); if (status != AMDSMI_STATUS_SUCCESS) - return status; + return amdsmi_errno_to_esmi_status(status); *ptmon = tmon; @@ -3305,7 +3312,7 @@ amdsmi_status_t amdsmi_get_cpu_dimm_temp_range_and_refresh_rate( status = static_cast(esmi_dimm_temp_range_and_refresh_rate_get( sock_ind, dimm_addr, &dimm_rate)); if (status != AMDSMI_STATUS_SUCCESS) - return status; + return amdsmi_errno_to_esmi_status(status); rate->range = dimm_rate.range; rate->ref_rate = dimm_rate.ref_rate; @@ -3334,7 +3341,7 @@ amdsmi_status_t amdsmi_get_cpu_dimm_power_consumption(amdsmi_processor_handle pr status = static_cast(esmi_dimm_power_consumption_get(sock_ind, dimm_addr, &d_power)); if (status != AMDSMI_STATUS_SUCCESS) - return status; + return amdsmi_errno_to_esmi_status(status); dimm_pow->power = d_power.power; dimm_pow->update_rate = d_power.update_rate; @@ -3364,7 +3371,7 @@ amdsmi_status_t amdsmi_get_cpu_dimm_thermal_sensor(amdsmi_processor_handle proce status = static_cast(esmi_dimm_thermal_sensor_get(sock_ind, dimm_addr, &d_sensor)); if (status != AMDSMI_STATUS_SUCCESS) - return status; + return amdsmi_errno_to_esmi_status(status); dimm_temp->temp = d_sensor.temp; dimm_temp->update_rate = d_sensor.update_rate; @@ -3385,7 +3392,7 @@ amdsmi_status_t amdsmi_set_cpu_xgmi_width(amdsmi_processor_handle processor_hand status = static_cast(esmi_xgmi_width_set(min, max)); if (status != AMDSMI_STATUS_SUCCESS) - return status; + return amdsmi_errno_to_esmi_status(status); return AMDSMI_STATUS_SUCCESS; } @@ -3410,7 +3417,7 @@ amdsmi_status_t amdsmi_set_cpu_gmi3_link_width_range(amdsmi_processor_handle pro status = static_cast(esmi_gmi3_link_width_range_set(sock_ind, min_link_width, max_link_width)); if (status != AMDSMI_STATUS_SUCCESS) - return status; + return amdsmi_errno_to_esmi_status(status); return AMDSMI_STATUS_SUCCESS; } @@ -3433,7 +3440,7 @@ amdsmi_status_t amdsmi_cpu_apb_enable(amdsmi_processor_handle processor_handle) status = static_cast(esmi_apb_enable(sock_ind)); if (status != AMDSMI_STATUS_SUCCESS) - return status; + return amdsmi_errno_to_esmi_status(status); return AMDSMI_STATUS_SUCCESS; } @@ -3457,7 +3464,7 @@ amdsmi_status_t amdsmi_cpu_apb_disable(amdsmi_processor_handle processor_handle, status = static_cast(esmi_apb_disable(sock_ind, pstate)); if (status != AMDSMI_STATUS_SUCCESS) - return status; + return amdsmi_errno_to_esmi_status(status); return AMDSMI_STATUS_SUCCESS; } @@ -3481,7 +3488,7 @@ amdsmi_status_t amdsmi_set_cpu_socket_lclk_dpm_level(amdsmi_processor_handle pro status = static_cast(esmi_socket_lclk_dpm_level_set(sock_ind, nbio_id, min, max)); if (status != AMDSMI_STATUS_SUCCESS) - return status; + return amdsmi_errno_to_esmi_status(status); return AMDSMI_STATUS_SUCCESS; } @@ -3507,7 +3514,7 @@ amdsmi_status_t amdsmi_get_cpu_socket_lclk_dpm_level(amdsmi_processor_handle pro status = static_cast(esmi_socket_lclk_dpm_level_get(sock_ind, nbio_id, &nb)); if (status != AMDSMI_STATUS_SUCCESS) - return status; + return amdsmi_errno_to_esmi_status(status); nbio->min_dpm_level = nb.min_dpm_level; nbio->max_dpm_level = nb.max_dpm_level; @@ -3535,7 +3542,7 @@ amdsmi_status_t amdsmi_set_cpu_pcie_link_rate(amdsmi_processor_handle processor_ status = static_cast(esmi_pcie_link_rate_set(sock_ind, rate_ctrl, prev_mode)); if (status != AMDSMI_STATUS_SUCCESS) - return status; + return amdsmi_errno_to_esmi_status(status); return AMDSMI_STATUS_SUCCESS; } @@ -3560,7 +3567,7 @@ amdsmi_status_t amdsmi_set_cpu_df_pstate_range(amdsmi_processor_handle processor status = static_cast(esmi_df_pstate_range_set(sock_ind, max_pstate, min_pstate)); if (status != AMDSMI_STATUS_SUCCESS) - return status; + return amdsmi_errno_to_esmi_status(status); return AMDSMI_STATUS_SUCCESS; } @@ -3590,7 +3597,7 @@ amdsmi_status_t amdsmi_get_cpu_current_io_bandwidth(amdsmi_processor_handle proc status = static_cast(esmi_current_io_bandwidth_get(sock_ind, io_link, &bw)); if (status != AMDSMI_STATUS_SUCCESS) - return status; + return amdsmi_errno_to_esmi_status(status); *io_bw = bw; @@ -3614,7 +3621,7 @@ amdsmi_status_t amdsmi_get_cpu_current_xgmi_bw(amdsmi_processor_handle processor status = static_cast(esmi_current_xgmi_bw_get(io_link, &bw)); if (status != AMDSMI_STATUS_SUCCESS) - return status; + return amdsmi_errno_to_esmi_status(status); *xgmi_bw = bw; @@ -3633,10 +3640,10 @@ amdsmi_status_t amdsmi_get_metrics_table_version(amdsmi_processor_handle process return AMDSMI_STATUS_INVAL; status = static_cast(esmi_metrics_table_version_get(&metrics_tbl_ver)); - *metrics_version = metrics_tbl_ver; - if (status != AMDSMI_STATUS_SUCCESS) - return status; + return amdsmi_errno_to_esmi_status(status); + + *metrics_version = metrics_tbl_ver; return AMDSMI_STATUS_SUCCESS; } @@ -3664,7 +3671,7 @@ amdsmi_status_t amdsmi_get_metrics_table(amdsmi_processor_handle processor_handl status = static_cast(esmi_metrics_table_get(sock_ind, &metrics_tbl)); if (status != AMDSMI_STATUS_SUCCESS) - return status; + return amdsmi_errno_to_esmi_status(status); std::memcpy(metrics_table, &metrics_tbl, sizeof(amdsmi_hsmp_metric_table_t)); @@ -3691,21 +3698,21 @@ amdsmi_status_t amdsmi_first_online_core_on_cpu_socket(amdsmi_processor_handle p status = static_cast(esmi_first_online_core_on_socket(sock_ind, &online_core)); if (status != AMDSMI_STATUS_SUCCESS) - return status; + return amdsmi_errno_to_esmi_status(status); *pcore_ind = online_core; return AMDSMI_STATUS_SUCCESS; } -const char** amdsmi_get_esmi_err_msg(amdsmi_status_t status, const char **status_string) +amdsmi_status_t amdsmi_get_esmi_err_msg(amdsmi_status_t status, const char **status_string) { for (auto& iter : amd::smi::esmi_status_map) { if (iter.first == status) { *status_string = esmi_get_err_msg(static_cast(iter.first)); - break; + return iter.second; } } - return status_string; + return AMDSMI_STATUS_SUCCESS; } #endif From 730a82417e375446b982d43b0b0f71418c1bfb1e Mon Sep 17 00:00:00 2001 From: Deepak Mewar Date: Thu, 11 Jan 2024 07:29:24 -0500 Subject: [PATCH 22/22] amdsmi wrapper generated for updated amdsmi_get_esmi_err_msg Change-Id: I2388cd75111774852ae6426071d890bbf2d9d0c9 --- py-interface/amdsmi_wrapper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-interface/amdsmi_wrapper.py b/py-interface/amdsmi_wrapper.py index 99a2c776f1..235c78ede6 100644 --- a/py-interface/amdsmi_wrapper.py +++ b/py-interface/amdsmi_wrapper.py @@ -2399,7 +2399,7 @@ amdsmi_first_online_core_on_cpu_socket = _libraries['libamd_smi.so'].amdsmi_firs amdsmi_first_online_core_on_cpu_socket.restype = amdsmi_status_t amdsmi_first_online_core_on_cpu_socket.argtypes = [amdsmi_processor_handle, ctypes.POINTER(ctypes.c_uint32)] amdsmi_get_esmi_err_msg = _libraries['libamd_smi.so'].amdsmi_get_esmi_err_msg -amdsmi_get_esmi_err_msg.restype = ctypes.POINTER(ctypes.POINTER(ctypes.c_char)) +amdsmi_get_esmi_err_msg.restype = amdsmi_status_t amdsmi_get_esmi_err_msg.argtypes = [amdsmi_status_t, ctypes.POINTER(ctypes.POINTER(ctypes.c_char))] __all__ = \ ['AGG_BW0', 'AMDSMI_ARG_PTR_NULL', 'AMDSMI_AVERAGE_POWER',