From aa633783aabd5e87d704efe869ec7cf93fccf001 Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Wed, 7 Feb 2024 05:40:25 -0600 Subject: [PATCH 1/7] SWDEV-439217 - Updated amdsmi_get_gpu_asic_info python api Signed-off-by: Maisam Arif Change-Id: Iafcfb10bec9a9a04574afdd95f10971f537e433b [ROCm/amdsmi commit: 7a19dbbfe6ee7ec012339a88ef408a122d7a672b] --- projects/amdsmi/amdsmi_cli/amdsmi_commands.py | 10 ---- .../amdsmi/py-interface/amdsmi_interface.py | 49 ++++++++++++++----- 2 files changed, 38 insertions(+), 21 deletions(-) diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py index 2c950db42e..ac774aae97 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py @@ -323,16 +323,6 @@ class AMDSMICommands(): if args.asic: try: asic_info = amdsmi_interface.amdsmi_get_gpu_asic_info(args.gpu) - asic_info['vendor_id'] = hex(asic_info['vendor_id']) - asic_info['vendor_name'] = asic_info['vendor_name'].replace(',', '') - asic_info['device_id'] = hex(asic_info['device_id']) - asic_info['rev_id'] = hex(asic_info['rev_id']) - if asic_info['asic_serial'] != '': - asic_info['asic_serial'] = hex(int(asic_info['asic_serial'], base=16)) - else: - asic_info['asic_serial'] = "N/A" - if asic_info['oam_id'] == 0xFFFF: # uint 16 max - asic_info['oam_id'] = "N/A" static_dict['asic'] = asic_info except amdsmi_exception.AmdSmiLibraryException as e: static_dict['asic'] = "N/A" diff --git a/projects/amdsmi/py-interface/amdsmi_interface.py b/projects/amdsmi/py-interface/amdsmi_interface.py index aac25d4a7c..721685c0a8 100644 --- a/projects/amdsmi/py-interface/amdsmi_interface.py +++ b/projects/amdsmi/py-interface/amdsmi_interface.py @@ -1562,23 +1562,50 @@ def amdsmi_get_gpu_asic_info( processor_handle, amdsmi_wrapper.amdsmi_processor_handle ) - asic_info = amdsmi_wrapper.amdsmi_asic_info_t() + asic_info_struct = amdsmi_wrapper.amdsmi_asic_info_t() _check_res( amdsmi_wrapper.amdsmi_get_gpu_asic_info( - processor_handle, ctypes.byref(asic_info)) + processor_handle, ctypes.byref(asic_info_struct)) ) - return { - "market_name": asic_info.market_name.decode("utf-8"), - "vendor_id": asic_info.vendor_id, - "vendor_name": asic_info.vendor_name.decode("utf-8"), - "subvendor_id": asic_info.subvendor_id if asic_info.subvendor_id == '' else hex(asic_info.subvendor_id), - "device_id": asic_info.device_id, - "rev_id": asic_info.rev_id, - "asic_serial": asic_info.asic_serial.decode("utf-8"), - "oam_id": asic_info.oam_id + asic_info = { + "market_name": asic_info_struct.market_name.decode("utf-8"), + "vendor_id": asic_info_struct.vendor_id, + "vendor_name": asic_info_struct.vendor_name.decode("utf-8"), + "subvendor_id": asic_info_struct.subvendor_id, + "device_id": asic_info_struct.device_id, + "rev_id": asic_info_struct.rev_id, + "asic_serial": asic_info_struct.asic_serial.decode("utf-8"), + "oam_id": asic_info_struct.oam_id } + string_values = ["market_name", "vendor_name"] + for value in string_values: + if not asic_info[value]: + asic_info[value] = "N/A" + + hex_values = ["vendor_id", "subvendor_id", "device_id", "rev_id"] + for value in hex_values: + if asic_info[value]: + asic_info[value] = hex(asic_info[value]) + else: + asic_info[value] = "N/A" + + # Ensure hex output for asic_serial + if asic_info["asic_serial"]: + asic_info["asic_serial"] = str.format("0x{:016X}", int(asic_info["asic_serial"], base=16)) + else: + asic_info["asic_serial"] = "N/A" + + # Check for max value as a sign for not applicable + if asic_info["oam_id"] == 0xFFFF: # uint 16 max + asic_info["oam_id"] = "N/A" + + # Remove commas from vendor name for clean output + asic_info["vendor_name"] = asic_info["vendor_name"].replace(',', '') + + return asic_info + def amdsmi_get_power_cap_info( processor_handle: amdsmi_wrapper.amdsmi_processor_handle, From b6f62bb651344680c40f0d71856496ecda2e4dbf Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Tue, 6 Feb 2024 17:40:10 -0600 Subject: [PATCH 2/7] Renamed amdsmi_get_metrics_table to amdsmi_get_cpu_metrics_table Renamed structs to be more conistent with what they are calling Signed-off-by: Maisam Arif Change-Id: I6f2be2fcb76f004aa592f0dad8545565700ccd4b [ROCm/amdsmi commit: f831cf49f76ad437fb5f05a595353ad61d2c4493] --- projects/amdsmi/amdsmi_cli/amdsmi_commands.py | 4 +-- .../example/amdsmi_esmi_intg_example.cc | 4 +-- projects/amdsmi/include/amd_smi/amdsmi.h | 20 ++++++------- projects/amdsmi/py-interface/README.md | 20 ++++++------- projects/amdsmi/py-interface/__init__.py | 4 +-- .../amdsmi/py-interface/amdsmi_interface.py | 10 +++---- .../amdsmi/py-interface/amdsmi_wrapper.py | 30 +++++++++---------- projects/amdsmi/src/amd_smi/amd_smi.cc | 10 +++---- 8 files changed, 51 insertions(+), 51 deletions(-) diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py index ac774aae97..ad21167b45 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py @@ -1951,7 +1951,7 @@ class AMDSMICommands(): if (args.cpu_metrics_ver): static_dict["metric_version"] = {} try: - version = amdsmi_interface.amdsmi_get_metrics_table_version(args.cpu) + version = amdsmi_interface.amdsmi_get_hsmp_metrics_table_version(args.cpu) static_dict["metric_version"]["version"] = version except amdsmi_exception.AmdSmiLibraryException as e: static_dict["metric_version"]["version"] = "N/A" @@ -1972,7 +1972,7 @@ class AMDSMICommands(): static_dict["metrics_table"]["cpu_model"] = "N/A" logging.debug("Failed to get cpu model | %s", e.get_error_info()) try: - metrics_table = amdsmi_interface.amdsmi_get_metrics_table(args.cpu) + metrics_table = amdsmi_interface.amdsmi_get_hsmp_metrics_table(args.cpu) static_dict["metrics_table"]["response"] = metrics_table except amdsmi_exception.AmdSmiLibraryException as e: static_dict["metrics_table"]["response"] = "N/A" diff --git a/projects/amdsmi/example/amdsmi_esmi_intg_example.cc b/projects/amdsmi/example/amdsmi_esmi_intg_example.cc index fc3af395c8..e3b3b67199 100644 --- a/projects/amdsmi/example/amdsmi_esmi_intg_example.cc +++ b/projects/amdsmi/example/amdsmi_esmi_intg_example.cc @@ -287,8 +287,8 @@ int main(int argc, char **argv) { double fraction_uq10 = fraction_q10; const char* err_str1; - amdsmi_hsmp_metric_table_t mtbl = {}; - ret = amdsmi_get_metrics_table(plist[index], &mtbl); + amdsmi_hsmp_metrics_table_t mtbl = {}; + ret = amdsmi_get_hsmp_metrics_table(plist[index], &mtbl); if (ret != AMDSMI_STATUS_SUCCESS) { cout<<"Failed to get Metrics Table for CPU["< Date: Fri, 9 Feb 2024 15:35:24 -0600 Subject: [PATCH 3/7] fix: [rocm/amd_smi_lib] amdsmi_get_gpu_activity gfx/memory activity does not update Checks and forces rereading gpu metrics unconditionally Code changes related to the following: * Device::dev_log_gpu_metrics() * amdsmi_get_gpu_metrics_header_info() Removed unintentionally during work on 'header cleanup Remove non-unified headers' * Examples * Unit tests Change-Id: I83710e173c0f7102d0b7f865c18474c979a95cd8 Signed-off-by: Oliveira, Daniel [ROCm/amdsmi commit: 78074d7d77298446b34856b361e86096031fb6b2] --- .../amdsmi/example/amd_smi_drm_example.cc | 179 ++++++++++++++++++ projects/amdsmi/include/amd_smi/amdsmi.h | 43 +++-- .../amdsmi/py-interface/amdsmi_wrapper.py | 30 +-- .../rocm_smi/src/rocm_smi_gpu_metrics.cc | 167 ++++++++-------- projects/amdsmi/src/amd_smi/amd_smi.cc | 11 ++ .../functional/gpu_metrics_read.cc | 17 ++ 6 files changed, 334 insertions(+), 113 deletions(-) diff --git a/projects/amdsmi/example/amd_smi_drm_example.cc b/projects/amdsmi/example/amd_smi_drm_example.cc index 076aeb3942..53a1863240 100644 --- a/projects/amdsmi/example/amd_smi_drm_example.cc +++ b/projects/amdsmi/example/amd_smi_drm_example.cc @@ -51,6 +51,7 @@ #include #include #include +#include #include "amd_smi/amdsmi.h" @@ -212,6 +213,13 @@ void getFWNameFromId(int id, char *name) } } +template +std::string print_unsigned_int(T value) { + std::stringstream ss; + ss << static_cast(value | 0); + + return ss.str(); +} int main() { amdsmi_status_t ret; @@ -655,6 +663,177 @@ int main() { << "\n\n"; std::cout << "\t\t Max Power Cap: " << cap_info.max_power_cap << "\n\n"; + + /// Get GPU Metrics info + std::cout << "\n\n"; + amdsmi_gpu_metrics_t gpu_metrics; + ret = amdsmi_get_gpu_metrics_info(processor_handles[j], &gpu_metrics); + CHK_AMDSMI_RET(ret) + printf(" Output of amdsmi_get_gpu_metrics_info:\n"); + printf("\tDevice[%d] BDF %04lx:%02x:%02x.%d\n\n", i, + bdf.fields.domain_number, + bdf.fields.bus_number, + bdf.fields.device_number, + bdf.fields.function_number); + + std::cout << "\t**.common_header.format_revision : " + << print_unsigned_int(gpu_metrics.common_header.format_revision) << "\n"; + std::cout << "\t**.common_header.content_revision : " + << print_unsigned_int(gpu_metrics.common_header.content_revision) << "\n"; + std::cout << "\t**.temperature_edge : " << std::dec + << gpu_metrics.temperature_edge << "\n"; + std::cout << "\t**.temperature_hotspot : " << std::dec + << gpu_metrics.temperature_hotspot << "\n"; + std::cout << "\t**.temperature_mem : " << std::dec + << gpu_metrics.temperature_mem << "\n"; + std::cout << "\t**.temperature_vrgfx : " << std::dec + << gpu_metrics.temperature_vrgfx << "\n"; + std::cout << "\t**.temperature_vrsoc : " << std::dec + << gpu_metrics.temperature_vrsoc << "\n"; + std::cout << "\t**.temperature_vrmem : " << std::dec + << gpu_metrics.temperature_vrmem << "\n"; + std::cout << "\t**.average_gfx_activity : " << std::dec + << gpu_metrics.average_gfx_activity << "\n"; + std::cout << "\t**.average_umc_activity : " << std::dec + << gpu_metrics.average_umc_activity << "\n"; + std::cout << "\t**.average_mm_activity : " << std::dec + << gpu_metrics.average_mm_activity << "\n"; + std::cout << "\t**.average_socket_power : " << std::dec + << gpu_metrics.average_socket_power << "\n"; + std::cout << "\t**.energy_accumulator : " << std::dec + << gpu_metrics.energy_accumulator << "\n"; + std::cout << "\t**.system_clock_counter : " << std::dec + << gpu_metrics.system_clock_counter << "\n"; + std::cout << "\t**.average_gfxclk_frequency : " << std::dec + << gpu_metrics.average_gfxclk_frequency << "\n"; + std::cout << "\t**.average_socclk_frequency : " << std::dec + << gpu_metrics.average_socclk_frequency << "\n"; + std::cout << "\t**.average_uclk_frequency : " << std::dec + << gpu_metrics.average_uclk_frequency << "\n"; + std::cout << "\t**.average_vclk0_frequency : " << std::dec + << gpu_metrics.average_vclk0_frequency<< "\n"; + std::cout << "\t**.average_dclk0_frequency : " << std::dec + << gpu_metrics.average_dclk0_frequency << "\n"; + std::cout << "\t**.average_vclk1_frequency : " << std::dec + << gpu_metrics.average_vclk1_frequency << "\n"; + std::cout << "\t**.average_dclk1_frequency : " << std::dec + << gpu_metrics.average_dclk1_frequency << "\n"; + std::cout << "\t**.current_gfxclk : " << std::dec + << gpu_metrics.current_gfxclk << "\n"; + std::cout << "\t**.current_socclk : " << std::dec + << gpu_metrics.current_socclk << "\n"; + std::cout << "\t**.current_uclk : " << std::dec + << gpu_metrics.current_uclk << "\n"; + std::cout << "\t**.current_vclk0 : " << std::dec + << gpu_metrics.current_vclk0 << "\n"; + std::cout << "\t**.current_dclk0 : " << std::dec + << gpu_metrics.current_dclk0 << "\n"; + std::cout << "\t**.current_vclk1 : " << std::dec + << gpu_metrics.current_vclk1 << "\n"; + std::cout << "\t**.current_dclk1 : " << std::dec + << gpu_metrics.current_dclk1 << "\n"; + std::cout << "\t**.throttle_status : " << std::dec + << gpu_metrics.throttle_status << "\n"; + std::cout << "\t**.current_fan_speed : " << std::dec + << gpu_metrics.current_fan_speed << "\n"; + std::cout << "\t**.pcie_link_width : " << std::dec + << gpu_metrics.pcie_link_width << "\n"; + std::cout << "\t**.pcie_link_speed : " << std::dec + << gpu_metrics.pcie_link_speed << "\n"; + std::cout << "\t**.gfx_activity_acc : " << std::dec + << gpu_metrics.gfx_activity_acc << "\n"; + std::cout << "\t**.mem_activity_acc : " << std::dec + << gpu_metrics.mem_activity_acc << "\n"; + std::cout << "\t**.firmware_timestamp : " << std::dec + << gpu_metrics.firmware_timestamp << "\n"; + std::cout << "\t**.voltage_soc : " << std::dec + << gpu_metrics.voltage_soc << "\n"; + std::cout << "\t**.voltage_gfx : " << std::dec + << gpu_metrics.voltage_gfx << "\n"; + std::cout << "\t**.voltage_mem : " << std::dec + << gpu_metrics.voltage_mem << "\n"; + std::cout << "\t**.indep_throttle_status : " << std::dec + << gpu_metrics.indep_throttle_status << "\n"; + std::cout << "\t**.current_socket_power : " << std::dec + << gpu_metrics.current_socket_power << "\n"; + std::cout << "\t**.gfxclk_lock_status : " << std::dec + << gpu_metrics.gfxclk_lock_status << "\n"; + std::cout << "\t**.xgmi_link_width : " << std::dec + << gpu_metrics.xgmi_link_width << "\n"; + std::cout << "\t**.xgmi_link_speed : " << std::dec + << gpu_metrics.xgmi_link_speed << "\n"; + std::cout << "\t**.pcie_bandwidth_acc : " << std::dec + << gpu_metrics.pcie_bandwidth_acc << "\n"; + std::cout << "\t**.pcie_bandwidth_inst : " << std::dec + << gpu_metrics.pcie_bandwidth_inst << "\n"; + std::cout << "\t**.pcie_l0_to_recov_count_acc : " << std::dec + << gpu_metrics.pcie_l0_to_recov_count_acc << "\n"; + std::cout << "\t**.pcie_replay_count_acc : " << std::dec + << gpu_metrics.pcie_replay_count_acc << "\n"; + std::cout << "\t**.pcie_replay_rover_count_acc : " << std::dec + << gpu_metrics.pcie_replay_rover_count_acc << "\n"; + + std::cout << "\t**.temperature_hbm[] : " << std::dec << "\n"; + for (const auto& temp : gpu_metrics.temperature_hbm) { + std::cout << "\t -> " << std::dec << temp << "\n"; + } + + std::cout << "\t**.vcn_activity[] : " << std::dec << "\n"; + for (const auto& vcn : gpu_metrics.vcn_activity) { + std::cout << "\t -> " << std::dec << vcn << "\n"; + } + + std::cout << "\t**.xgmi_read_data_acc[] : " << std::dec << "\n"; + for (const auto& read_data : gpu_metrics.xgmi_read_data_acc) { + std::cout << "\t -> " << std::dec << read_data << "\n"; + } + + std::cout << "\t**.xgmi_write_data_acc[] : " << std::dec << "\n"; + for (const auto& write_data : gpu_metrics.xgmi_write_data_acc) { + std::cout << "\t -> " << std::dec << write_data << "\n"; + } + + std::cout << "\t**.current_gfxclks[] : " << std::dec << "\n"; + for (const auto& gfxclk : gpu_metrics.current_gfxclks) { + std::cout << "\t -> " << std::dec << gfxclk << "\n"; + } + + std::cout << "\t**.current_socclks[] : " << std::dec << "\n"; + for (const auto& socclk : gpu_metrics.current_socclks) { + std::cout << "\t -> " << std::dec << socclk << "\n"; + } + + std::cout << "\t**.current_vclk0s[] : " << std::dec << "\n"; + for (const auto& vclk : gpu_metrics.current_vclk0s) { + std::cout << "\t -> " << std::dec << vclk << "\n"; + } + + std::cout << "\t**.current_dclk0s[] : " << std::dec << "\n"; + for (const auto& dclk : gpu_metrics.current_dclk0s) { + std::cout << "\t -> " << std::dec << dclk << "\n"; + } + + std::cout << "\n"; + std::cout << "\t ** -> Checking metrics with constant changes ** " << "\n"; + constexpr uint16_t kMAX_ITER_TEST = 10; + amdsmi_gpu_metrics_t gpu_metrics_check; + for (auto idx = uint16_t(1); idx <= kMAX_ITER_TEST; ++idx) { + amdsmi_get_gpu_metrics_info(processor_handles[j], &gpu_metrics_check); + std::cout << "\t\t -> firmware_timestamp [" << idx << "/" << kMAX_ITER_TEST << "]: " << gpu_metrics_check.firmware_timestamp << "\n"; + } + + std::cout << "\n"; + for (auto idx = uint16_t(1); idx <= kMAX_ITER_TEST; ++idx) { + amdsmi_get_gpu_metrics_info(processor_handles[j], &gpu_metrics_check); + std::cout << "\t\t -> system_clock_counter [" << idx << "/" << kMAX_ITER_TEST << "]: " << gpu_metrics_check.system_clock_counter << "\n"; + } + std::cout << "\n"; + + std::cout << "\n"; + std::cout << "\t ** Note: Values MAX'ed out (UINTX MAX are unsupported for the version in question) ** " << "\n"; + std::cout << "\n"; + std::cout << "+=======+==================+============+==============" + << "+=============+=============+=============+============+\n"; } } diff --git a/projects/amdsmi/include/amd_smi/amdsmi.h b/projects/amdsmi/include/amd_smi/amdsmi.h index bb6af21350..bea7d5df00 100644 --- a/projects/amdsmi/include/amd_smi/amdsmi.h +++ b/projects/amdsmi/include/amd_smi/amdsmi.h @@ -1619,7 +1619,7 @@ typedef struct __attribute__((__packed__)){ /** * @brief Initialize the AMD SMI library * - * @platform{gpu_bm_linux} @platform{host} @platform{cpu_bm} @platform{guest_1vf} + * @platform{gpu_bm_linux} @platform{host} @platform{cpu_bm} @platform{guest_1vf} * @platform{guest_mvf} @platform{guest_windows} * * @details This function initializes the library and the internal data structures, @@ -1642,7 +1642,7 @@ amdsmi_status_t amdsmi_init(uint64_t init_flags); /** * @brief Shutdown the AMD SMI library * - * @platform{gpu_bm_linux} @platform{host} @platform{cpu_bm} @platform{guest_1vf} + * @platform{gpu_bm_linux} @platform{host} @platform{cpu_bm} @platform{guest_1vf} * @platform{guest_mvf} @platform{guest_windows} * * @details This function shuts down the library and internal data structures and @@ -1663,7 +1663,7 @@ amdsmi_status_t amdsmi_shut_down(void); /** * @brief Get the list of socket handles in the system. * - * @platform{gpu_bm_linux} @platform{host} @platform{cpu_bm} @platform{guest_1vf} + * @platform{gpu_bm_linux} @platform{host} @platform{cpu_bm} @platform{guest_1vf} * @platform{guest_mvf} @platform{guest_windows} * * @details Depends on what flag is passed to ::amdsmi_init. AMDSMI_INIT_AMD_GPUS @@ -1726,7 +1726,7 @@ amdsmi_status_t amdsmi_get_cpusocket_handles(uint32_t *socket_count, /** * @brief Get information about the given socket * - * @platform{gpu_bm_linux} @platform{host} @platform{guest_1vf} + * @platform{gpu_bm_linux} @platform{host} @platform{guest_1vf} * @platform{guest_mvf} @platform{guest_windows} * * @details This function retrieves socket information. The @p socket_handle must @@ -1818,7 +1818,7 @@ amdsmi_status_t amdsmi_get_processor_handles_by_type(amdsmi_socket_handle socket /** * @brief Get the list of the processor handles associated to a socket. * - * @platform{gpu_bm_linux} @platform{host} @platform{guest_1vf} + * @platform{gpu_bm_linux} @platform{host} @platform{guest_1vf} * @platform{guest_mvf} @platform{guest_windows} * * @details This function retrieves the processor handles of a socket. The @@ -1886,7 +1886,7 @@ amdsmi_status_t amdsmi_get_cpucore_handles(amdsmi_cpusocket_handle socket_handle /** * @brief Get the processor type of the processor_handle * - * @platform{gpu_bm_linux} @platform{host} @platform{cpu_bm} @platform{guest_1vf} + * @platform{gpu_bm_linux} @platform{host} @platform{cpu_bm} @platform{guest_1vf} * @platform{guest_mvf} @platform{guest_windows} * * @details This function retrieves the processor type. A processor_handle must be provided @@ -1906,7 +1906,7 @@ amdsmi_status_t amdsmi_get_processor_type(amdsmi_processor_handle processor_hand /** * @brief Get processor handle with the matching bdf. * - * @platform{gpu_bm_linux} @platform{host} @platform{guest_1vf} + * @platform{gpu_bm_linux} @platform{host} @platform{guest_1vf} * @platform{guest_mvf} @platform{guest_windows} * * @details Given bdf info @p bdf, this function will get @@ -2462,7 +2462,7 @@ amdsmi_get_gpu_bad_page_info(amdsmi_processor_handle processor_handle, uint32_t * @brief Returns RAS features info. * * @platform{gpu_bm_linux} @platform{host} - * + * * @param[in] processor_handle Device handle which to query * * @param[out] ras_feature RAS features that are currently enabled and supported on @@ -2635,7 +2635,7 @@ amdsmi_status_t amdsmi_get_gpu_fan_speed_max(amdsmi_processor_handle processor_h * specified temperature sensor on the specified device. It is not supported on * virtual machine guest * - * @platform{gpu_bm_linux} @platform{host} + * @platform{gpu_bm_linux} @platform{host} * * @details Given a processor handle @p processor_handle, a sensor type @p sensor_type, a * ::amdsmi_temperature_metric_t @p metric and a pointer to an int64_t @p @@ -2666,7 +2666,7 @@ amdsmi_status_t amdsmi_get_temp_metric(amdsmi_processor_handle processor_handle, /** * @brief Returns gpu cache info. * - * @platform{gpu_bm_linux} @platform{host} + * @platform{gpu_bm_linux} @platform{host} * * @param[in] processor_handle PF of a processor for which to query * @@ -2935,6 +2935,27 @@ amdsmi_status_t amdsmi_reset_gpu(amdsmi_processor_handle processor_handle); amdsmi_status_t amdsmi_get_gpu_od_volt_info(amdsmi_processor_handle processor_handle, amdsmi_od_volt_freq_data_t *odv); +/** + * @brief Get the 'metrics_header_info' from the GPU metrics associated with the device + * + * @platform{gpu_bm_linux} @platform{guest_1vf} + * + * @details Given a processor handle @p processor_handle and a pointer to a amd_metrics_table_header_t in which + * the 'metrics_header_info' will stored + * + * @param[in] processor_handle Device which to query + * + * @param[inout] header_value a pointer to amd_metrics_table_header_t to which the device gpu + * metric unit will be stored + * + * @retval ::AMDSMI_STATUS_SUCCESS is returned upon successful call. + * ::AMDSMI_STATUS_NOT_SUPPORTED is returned in case the metric unit + * does not exist for the given device + * + */ +amdsmi_status_t +amdsmi_get_gpu_metrics_header_info(amdsmi_processor_handle processor_handle, amd_metrics_table_header_t* header_value); + /** * @brief This function retrieves the gpu metrics information. It is not supported * on virtual machine guest @@ -4375,7 +4396,7 @@ amdsmi_status_t amdsmi_get_gpu_vram_info( /** * @brief Returns the board part number and board information for the requested device * - * @platform{gpu_bm_linux} @platform{host} @platform{guest_1vf} @platform{guest_mvf} + * @platform{gpu_bm_linux} @platform{host} @platform{guest_1vf} @platform{guest_mvf} * * @param[in] processor_handle Device which to query * diff --git a/projects/amdsmi/py-interface/amdsmi_wrapper.py b/projects/amdsmi/py-interface/amdsmi_wrapper.py index 88d58e5303..5587576fac 100644 --- a/projects/amdsmi/py-interface/amdsmi_wrapper.py +++ b/projects/amdsmi/py-interface/amdsmi_wrapper.py @@ -746,19 +746,6 @@ amdsmi_card_form_factor_t = ctypes.c_uint32 # enum class struct_amdsmi_pcie_info_t(Structure): pass -class struct_pcie_static_(Structure): - pass - -struct_pcie_static_._pack_ = 1 # source:False -struct_pcie_static_._fields_ = [ - ('max_pcie_lanes', ctypes.c_uint16), - ('PADDING_0', ctypes.c_ubyte * 2), - ('max_pcie_speed', ctypes.c_uint32), - ('pcie_interface_version', ctypes.c_uint32), - ('slot_type', amdsmi_card_form_factor_t), - ('reserved', ctypes.c_uint64 * 10), -] - class struct_pcie_metric_(Structure): pass @@ -777,6 +764,19 @@ struct_pcie_metric_._fields_ = [ ('reserved', ctypes.c_uint64 * 13), ] +class struct_pcie_static_(Structure): + pass + +struct_pcie_static_._pack_ = 1 # source:False +struct_pcie_static_._fields_ = [ + ('max_pcie_lanes', ctypes.c_uint16), + ('PADDING_0', ctypes.c_ubyte * 2), + ('max_pcie_speed', ctypes.c_uint32), + ('pcie_interface_version', ctypes.c_uint32), + ('slot_type', amdsmi_card_form_factor_t), + ('reserved', ctypes.c_uint64 * 10), +] + struct_amdsmi_pcie_info_t._pack_ = 1 # source:False struct_amdsmi_pcie_info_t._fields_ = [ ('pcie_static', struct_pcie_static_), @@ -1993,6 +1993,9 @@ amdsmi_reset_gpu.argtypes = [amdsmi_processor_handle] amdsmi_get_gpu_od_volt_info = _libraries['libamd_smi.so'].amdsmi_get_gpu_od_volt_info amdsmi_get_gpu_od_volt_info.restype = amdsmi_status_t amdsmi_get_gpu_od_volt_info.argtypes = [amdsmi_processor_handle, ctypes.POINTER(struct_amdsmi_od_volt_freq_data_t)] +amdsmi_get_gpu_metrics_header_info = _libraries['libamd_smi.so'].amdsmi_get_gpu_metrics_header_info +amdsmi_get_gpu_metrics_header_info.restype = amdsmi_status_t +amdsmi_get_gpu_metrics_header_info.argtypes = [amdsmi_processor_handle, ctypes.POINTER(struct_amd_metrics_table_header_t)] amdsmi_get_gpu_metrics_info = _libraries['libamd_smi.so'].amdsmi_get_gpu_metrics_info amdsmi_get_gpu_metrics_info.restype = amdsmi_status_t amdsmi_get_gpu_metrics_info.argtypes = [amdsmi_processor_handle, ctypes.POINTER(struct_amdsmi_gpu_metrics_t)] @@ -2527,6 +2530,7 @@ __all__ = \ 'amdsmi_get_gpu_id', 'amdsmi_get_gpu_memory_partition', 'amdsmi_get_gpu_memory_reserved_pages', 'amdsmi_get_gpu_memory_total', 'amdsmi_get_gpu_memory_usage', + 'amdsmi_get_gpu_metrics_header_info', 'amdsmi_get_gpu_metrics_info', 'amdsmi_get_gpu_od_volt_curve_regions', 'amdsmi_get_gpu_od_volt_info', 'amdsmi_get_gpu_overdrive_level', diff --git a/projects/amdsmi/rocm_smi/src/rocm_smi_gpu_metrics.cc b/projects/amdsmi/rocm_smi/src/rocm_smi_gpu_metrics.cc index 1618e328a9..37b6577625 100755 --- a/projects/amdsmi/rocm_smi/src/rocm_smi_gpu_metrics.cc +++ b/projects/amdsmi/rocm_smi/src/rocm_smi_gpu_metrics.cc @@ -2685,47 +2685,42 @@ rsmi_status_t Device::dev_read_gpu_metrics_header_data() // Check if/when metrics table needs to be refreshed. auto now_ts = actual_timestamp_in_secs(); - if ((!m_gpu_metrics_header.m_structure_size) || - (!m_gpu_metrics_header.m_format_revision) || - (!m_gpu_metrics_header.m_content_revision)) { - auto op_result = readDevInfo(DevInfoTypes::kDevGpuMetrics, - sizeof(AMDGpuMetricsHeader_v1_t), - &m_gpu_metrics_header); - if ((status_code = ErrnoToRsmiStatus(op_result)) != - rsmi_status_t::RSMI_STATUS_SUCCESS) { - ostrstream << __PRETTY_FUNCTION__ - << " | ======= end ======= " - << " | Fail " - << " | Device #: " << index() - << " | Metric Version: " << stringfy_metrics_header(m_gpu_metrics_header) - << " | Cause: readDevInfo(kDevGpuMetrics)" - << " | Returning = " - << getRSMIStatusString(status_code) - << " Could not read Metrics Header: " - << print_unsigned_int(m_gpu_metrics_header.m_structure_size) - << " |"; - LOG_ERROR(ostrstream); - return status_code; - } - if ((status_code = is_gpu_metrics_version_supported(m_gpu_metrics_header)) == - rsmi_status_t::RSMI_STATUS_NOT_SUPPORTED) { - ostrstream << __PRETTY_FUNCTION__ - << " | ======= end ======= " - << " | Fail " - << " | Device #: " << index() - << " | Metric Version: " << stringfy_metrics_header(m_gpu_metrics_header) - << " | Cause: gpu metric file version is not supported: " - << " | Returning = " - << getRSMIStatusString(status_code) - << " Could not read Metrics Header: " - << print_unsigned_int(m_gpu_metrics_header.m_structure_size) - << " |"; - LOG_ERROR(ostrstream); - return status_code; - } - - m_gpu_metrics_updated_timestamp = actual_timestamp_in_secs(); + auto op_result = readDevInfo(DevInfoTypes::kDevGpuMetrics, + sizeof(AMDGpuMetricsHeader_v1_t), + &m_gpu_metrics_header); + if ((status_code = ErrnoToRsmiStatus(op_result)) != + rsmi_status_t::RSMI_STATUS_SUCCESS) { + ostrstream << __PRETTY_FUNCTION__ + << " | ======= end ======= " + << " | Fail " + << " | Device #: " << index() + << " | Metric Version: " << stringfy_metrics_header(m_gpu_metrics_header) + << " | Cause: readDevInfo(kDevGpuMetrics)" + << " | Returning = " + << getRSMIStatusString(status_code) + << " Could not read Metrics Header: " + << print_unsigned_int(m_gpu_metrics_header.m_structure_size) + << " |"; + LOG_ERROR(ostrstream); + return status_code; } + if ((status_code = is_gpu_metrics_version_supported(m_gpu_metrics_header)) == + rsmi_status_t::RSMI_STATUS_NOT_SUPPORTED) { + ostrstream << __PRETTY_FUNCTION__ + << " | ======= end ======= " + << " | Fail " + << " | Device #: " << index() + << " | Metric Version: " << stringfy_metrics_header(m_gpu_metrics_header) + << " | Cause: gpu metric file version is not supported: " + << " | Returning = " + << getRSMIStatusString(status_code) + << " Could not read Metrics Header: " + << print_unsigned_int(m_gpu_metrics_header.m_structure_size) + << " |"; + LOG_ERROR(ostrstream); + return status_code; + } + m_gpu_metrics_updated_timestamp = actual_timestamp_in_secs(); ostrstream << __PRETTY_FUNCTION__ << " | ======= end ======= " @@ -2847,23 +2842,21 @@ rsmi_status_t Device::setup_gpu_metrics_reading() } // - // if/in case setup_gpu_metrics_reading() was called already use the same pointer + m_gpu_metrics_ptr.reset(); + m_gpu_metrics_ptr = amdgpu_metrics_factory(gpu_metrics_flag_version); if (!m_gpu_metrics_ptr) { - m_gpu_metrics_ptr = amdgpu_metrics_factory(gpu_metrics_flag_version); - if (!m_gpu_metrics_ptr) { - status_code = rsmi_status_t::RSMI_STATUS_UNEXPECTED_DATA; - ostrstream << __PRETTY_FUNCTION__ - << " | ======= end ======= " - << " | Fail " - << " | Device #: " << index() - << " | Metric Version: " << stringfy_metrics_header(dev_get_metrics_header()) - << " | Cause: amdgpu_metrics_factory() couldn't get a valid metric object" - << " | Returning = " - << getRSMIStatusString(status_code) - << " |"; - LOG_ERROR(ostrstream); - return status_code; - } + status_code = rsmi_status_t::RSMI_STATUS_UNEXPECTED_DATA; + ostrstream << __PRETTY_FUNCTION__ + << " | ======= end ======= " + << " | Fail " + << " | Device #: " << index() + << " | Metric Version: " << stringfy_metrics_header(dev_get_metrics_header()) + << " | Cause: amdgpu_metrics_factory() couldn't get a valid metric object" + << " | Returning = " + << getRSMIStatusString(status_code) + << " |"; + LOG_ERROR(ostrstream); + return status_code; } // @@ -2943,23 +2936,21 @@ rsmi_status_t Device::dev_log_gpu_metrics(std::ostringstream& outstream_metrics) // meaning, we didn't run any queries, and just want to // print all the gpu metrics content, we need to setup // the environment first. - if (!m_gpu_metrics_ptr) { - status_code = setup_gpu_metrics_reading(); - if ((status_code != rsmi_status_t::RSMI_STATUS_SUCCESS) || (!m_gpu_metrics_ptr)) { - // At this point we should have a valid gpu_metrics pointer. - status_code = rsmi_status_t::RSMI_STATUS_UNEXPECTED_DATA; - ostrstream << __PRETTY_FUNCTION__ - << " | ======= end ======= " - << " | Fail " - << " | Device #: " << index() - << " | Metric Version: " << stringfy_metrics_header(dev_get_metrics_header()) - << " | Cause: Couldn't get a valid metric object" - << " | Returning = " - << getRSMIStatusString(status_code) - << " |"; - LOG_ERROR(ostrstream); - return status_code; - } + status_code = setup_gpu_metrics_reading(); + if ((status_code != rsmi_status_t::RSMI_STATUS_SUCCESS) || (!m_gpu_metrics_ptr)) { + // At this point we should have a valid gpu_metrics pointer. + status_code = rsmi_status_t::RSMI_STATUS_UNEXPECTED_DATA; + ostrstream << __PRETTY_FUNCTION__ + << " | ======= end ======= " + << " | Fail " + << " | Device #: " << index() + << " | Metric Version: " << stringfy_metrics_header(dev_get_metrics_header()) + << " | Cause: Couldn't get a valid metric object" + << " | Returning = " + << getRSMIStatusString(status_code) + << " |"; + LOG_ERROR(ostrstream); + return status_code; } // Header info @@ -3105,22 +3096,20 @@ rsmi_status_t Device::run_internal_gpu_metrics_query(AMDGpuMetricsUnitType_t met ostrstream << __PRETTY_FUNCTION__ << " | ======= start ======="; LOG_TRACE(ostrstream); - if (!m_gpu_metrics_ptr) { - status_code = setup_gpu_metrics_reading(); - if ((status_code != rsmi_status_t::RSMI_STATUS_SUCCESS) || (!m_gpu_metrics_ptr)) { - status_code = rsmi_status_t::RSMI_STATUS_UNEXPECTED_DATA; - ostrstream << __PRETTY_FUNCTION__ - << " | ======= end ======= " - << " | Fail " - << " | Device #: " << index() - << " | Metric Version: " << stringfy_metrics_header(dev_get_metrics_header()) - << " | Cause: Couldn't get a valid metric object" - << " | Returning = " - << getRSMIStatusString(status_code) - << " |"; - LOG_ERROR(ostrstream); - return status_code; - } + status_code = setup_gpu_metrics_reading(); + if ((status_code != rsmi_status_t::RSMI_STATUS_SUCCESS) || (!m_gpu_metrics_ptr)) { + status_code = rsmi_status_t::RSMI_STATUS_UNEXPECTED_DATA; + ostrstream << __PRETTY_FUNCTION__ + << " | ======= end ======= " + << " | Fail " + << " | Device #: " << index() + << " | Metric Version: " << stringfy_metrics_header(dev_get_metrics_header()) + << " | Cause: Couldn't get a valid metric object" + << " | Returning = " + << getRSMIStatusString(status_code) + << " |"; + LOG_ERROR(ostrstream); + return status_code; } // Lookup the dynamic table diff --git a/projects/amdsmi/src/amd_smi/amd_smi.cc b/projects/amdsmi/src/amd_smi/amd_smi.cc index 52d069a04c..2a992742ff 100644 --- a/projects/amdsmi/src/amd_smi/amd_smi.cc +++ b/projects/amdsmi/src/amd_smi/amd_smi.cc @@ -1108,6 +1108,17 @@ amdsmi_status_t amdsmi_get_gpu_ecc_status(amdsmi_processor_handle processor_han reinterpret_cast(state)); } +amdsmi_status_t +amdsmi_get_gpu_metrics_header_info(amdsmi_processor_handle processor_handle, + amd_metrics_table_header_t *header_value) +{ + AMDSMI_CHECK_INIT(); + // nullptr api supported + + return rsmi_wrapper(rsmi_dev_metrics_header_info_get, processor_handle, + reinterpret_cast(header_value)); +} + amdsmi_status_t amdsmi_get_gpu_metrics_info( amdsmi_processor_handle processor_handle, amdsmi_gpu_metrics_t *pgpu_metrics) { diff --git a/projects/amdsmi/tests/amd_smi_test/functional/gpu_metrics_read.cc b/projects/amdsmi/tests/amd_smi_test/functional/gpu_metrics_read.cc index 031897da9f..ea86c2982f 100644 --- a/projects/amdsmi/tests/amd_smi_test/functional/gpu_metrics_read.cc +++ b/projects/amdsmi/tests/amd_smi_test/functional/gpu_metrics_read.cc @@ -349,6 +349,23 @@ void TestGpuMetricsRead::Run(void) { << static_cast(smu.pcie_nak_rcvd_count_acc) << "\n"; std::cout << "pcie_replay_rover_count_acc= " << std::dec << static_cast(smu.pcie_replay_rover_count_acc) << "\n"; + + // Check for constant changes/refresh metrics + std::cout << "\n"; + std::cout << "\t ** -> Checking metrics with constant changes ** " << "\n"; + constexpr uint16_t kMAX_ITER_TEST = 10; + amdsmi_gpu_metrics_t gpu_metrics_check; + for (auto idx = uint16_t(1); idx <= kMAX_ITER_TEST; ++idx) { + amdsmi_get_gpu_metrics_info(processor_handles_[i], &gpu_metrics_check); + std::cout << "\t\t -> firmware_timestamp [" << idx << "/" << kMAX_ITER_TEST << "]: " << gpu_metrics_check.firmware_timestamp << "\n"; + } + + std::cout << "\n"; + for (auto idx = uint16_t(1); idx <= kMAX_ITER_TEST; ++idx) { + amdsmi_get_gpu_metrics_info(processor_handles_[i], &gpu_metrics_check); + std::cout << "\t\t -> system_clock_counter [" << idx << "/" << kMAX_ITER_TEST << "]: " << gpu_metrics_check.system_clock_counter << "\n"; + } + std::cout << "\n"; } } From 57419ff3cc2bba45048596b1dfe9c5d05709814a Mon Sep 17 00:00:00 2001 From: Deepak Mewar Date: Tue, 13 Feb 2024 04:42:38 -0500 Subject: [PATCH 4/7] Updated amdsmi header for ESMI doxygen formatting Referencing htttps://github.com/ROCm/amdsmi/pull/10 Change-Id: I516e3643130db8a4213aee7dfcaca27363e3171e Signed-off-by: Maisam Arif [ROCm/amdsmi commit: 34ccbb5d1bb7fa775d9a70cc2ce244bd5376361b] --- projects/amdsmi/docs/doxygen/Doxyfile | 2 +- projects/amdsmi/include/amd_smi/amdsmi.h | 130 +++++++++++------------ 2 files changed, 66 insertions(+), 66 deletions(-) diff --git a/projects/amdsmi/docs/doxygen/Doxyfile b/projects/amdsmi/docs/doxygen/Doxyfile index 0b2949737d..f181c6d7c1 100644 --- a/projects/amdsmi/docs/doxygen/Doxyfile +++ b/projects/amdsmi/docs/doxygen/Doxyfile @@ -2276,7 +2276,7 @@ INCLUDE_FILE_PATTERNS = # recursively expanded use the := operator instead of the = operator. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -PREDEFINED = +PREDEFINED = ENABLE_ESMI_LIB # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # tag can be used to specify a list of macro names that should be expanded. The diff --git a/projects/amdsmi/include/amd_smi/amdsmi.h b/projects/amdsmi/include/amd_smi/amdsmi.h index bea7d5df00..587ee9dea2 100644 --- a/projects/amdsmi/include/amd_smi/amdsmi.h +++ b/projects/amdsmi/include/amd_smi/amdsmi.h @@ -4669,10 +4669,10 @@ amdsmi_get_gpu_total_ecc_count(amdsmi_processor_handle processor_handle, amdsmi_ #ifdef ENABLE_ESMI_LIB -/*---------------------------------------------------------------------------*/ -/** @defgroup energyinfo Energy information (RAPL MSR) */ -/*---------------------------------------------------------------------------*/ -/** @{ */ +/*****************************************************************************/ +/** @defgroup energyinfo Energy information (RAPL MSR) + * @{ + */ /** * @brief Get the core energy for a given core. @@ -4702,12 +4702,12 @@ amdsmi_status_t amdsmi_get_cpu_core_energy(amdsmi_processor_handle processor_han amdsmi_status_t amdsmi_get_cpu_socket_energy(amdsmi_processor_handle processor_handle, uint64_t *penergy); -/** @} */ +/** @} End energyinfo */ -/*---------------------------------------------------------------------------*/ -/** @defgroup systemstatistics HSMP system statistics */ -/*---------------------------------------------------------------------------*/ -/** @{ */ +/*****************************************************************************/ +/** @defgroup systemstatistics HSMP system statistics + * @{ + */ /** * @brief Get SMU Firmware Version. @@ -4825,12 +4825,12 @@ amdsmi_status_t amdsmi_get_cpu_socket_freq_range(amdsmi_processor_handle process amdsmi_status_t amdsmi_get_cpu_core_current_freq_limit(amdsmi_processor_handle processor_handle, uint32_t *freq); -/** @} */ +/** @} systemstatistics */ -/*---------------------------------------------------------------------------*/ -/** @defgroup powercont Power Control */ -/*---------------------------------------------------------------------------*/ -/** @{ */ +/*****************************************************************************/ +/** @defgroup powercont Power Control + * @{ + */ /** * @brief Get the socket power. @@ -4916,12 +4916,12 @@ amdsmi_status_t amdsmi_set_cpu_socket_power_cap(amdsmi_processor_handle processo amdsmi_status_t amdsmi_set_cpu_pwr_efficiency_mode(amdsmi_processor_handle processor_handle, uint8_t mode); -/** @} */ +/** @} powercont */ -/*---------------------------------------------------------------------------*/ -/** @defgroup perfcont Performance (Boost limit) Control */ -/*---------------------------------------------------------------------------*/ -/** @{ */ +/*****************************************************************************/ +/** @defgroup perfcont Performance (Boost limit) Control + * @{ + */ /** * @brief Get the core boost limit. @@ -4979,12 +4979,12 @@ amdsmi_status_t amdsmi_set_cpu_core_boostlimit(amdsmi_processor_handle processor amdsmi_status_t amdsmi_set_cpu_socket_boostlimit(amdsmi_processor_handle processor_handle, uint32_t boostlimit); -/** @} */ +/** @} perfcont */ -/*---------------------------------------------------------------------------*/ -/** @defgroup ddrquer DDR bandwidth monitor */ -/*---------------------------------------------------------------------------*/ -/** @{ */ +/*****************************************************************************/ +/** @defgroup ddrquer DDR bandwidth monitor + * @{ + */ /** * @brief Get the DDR bandwidth data. @@ -4999,12 +4999,12 @@ amdsmi_status_t amdsmi_set_cpu_socket_boostlimit(amdsmi_processor_handle process amdsmi_status_t amdsmi_get_cpu_ddr_bw(amdsmi_processor_handle processor_handle, amdsmi_ddr_bw_metrics_t *ddr_bw); -/** @} */ +/** @} ddrquer */ -/*---------------------------------------------------------------------------*/ -/** @defgroup tempquer Temperature Query */ -/*---------------------------------------------------------------------------*/ -/** @{ */ +/*****************************************************************************/ +/** @defgroup tempquer Temperature Query + * @{ + */ /** * @brief Get socket temperature. @@ -5020,12 +5020,12 @@ amdsmi_status_t amdsmi_get_cpu_ddr_bw(amdsmi_processor_handle processor_handle, amdsmi_status_t amdsmi_get_cpu_socket_temperature(amdsmi_processor_handle processor_handle, uint32_t *ptmon); -/** @} */ +/** @} tempquer */ -/*---------------------------------------------------------------------------*/ -/** @defgroup dimmstatistics Dimm statistics */ -/*---------------------------------------------------------------------------*/ -/** @{ */ +/*****************************************************************************/ +/** @defgroup dimmstatistics Dimm statistics + * @{ + */ /** * @brief Get DIMM temperature range and refresh rate. @@ -5072,12 +5072,12 @@ amdsmi_status_t amdsmi_get_cpu_dimm_thermal_sensor(amdsmi_processor_handle proce uint8_t dimm_addr, amdsmi_dimm_thermal_t *dimm_temp); -/** @} */ +/** @} dimmstatistics */ -/*---------------------------------------------------------------------------*/ -/** @defgroup xgmibwcont xGMI bandwidth control */ -/*---------------------------------------------------------------------------*/ -/** @{ */ +/*****************************************************************************/ +/** @defgroup xgmibwcont xGMI bandwidth control + * @{ + */ /** * @brief Set xgmi width. @@ -5092,12 +5092,12 @@ amdsmi_status_t amdsmi_get_cpu_dimm_thermal_sensor(amdsmi_processor_handle proce amdsmi_status_t amdsmi_set_cpu_xgmi_width(amdsmi_processor_handle processor_handle, uint8_t min, uint8_t max); -/** @} */ +/** @} xgmibwcont */ -/*---------------------------------------------------------------------------*/ -/** @defgroup gmi3widthcont GMI3 width control */ -/*---------------------------------------------------------------------------*/ -/** @{ */ +/*****************************************************************************/ +/** @defgroup gmi3widthcont GMI3 width control + * @{ + */ /** * @brief Set gmi3 link width range. @@ -5113,12 +5113,12 @@ amdsmi_status_t amdsmi_set_cpu_xgmi_width(amdsmi_processor_handle processor_hand amdsmi_status_t amdsmi_set_cpu_gmi3_link_width_range(amdsmi_processor_handle processor_handle, uint8_t min_link_width, uint8_t max_link_width); -/** @} */ +/** @} gmi3widthcont */ -/*---------------------------------------------------------------------------*/ -/** @defgroup pstatecnt Pstate selection */ -/*---------------------------------------------------------------------------*/ -/** @{ */ +/*****************************************************************************/ +/** @defgroup pstatecnt Pstate selection + * @{ + */ /** * @brief Enable APB. @@ -5202,12 +5202,12 @@ amdsmi_status_t amdsmi_set_cpu_pcie_link_rate(amdsmi_processor_handle processor_ amdsmi_status_t amdsmi_set_cpu_df_pstate_range(amdsmi_processor_handle processor_handle, uint8_t max_pstate, uint8_t min_pstate); -/** @} */ +/** @} pstatecnt */ -/*---------------------------------------------------------------------------*/ -/** @defgroup bwquer Bandwidth monitor */ -/*---------------------------------------------------------------------------*/ -/** @{ */ +/*****************************************************************************/ +/** @defgroup bwquer Bandwidth monitor + * @{ + */ /** * @brief Get current input output bandwidth. @@ -5237,12 +5237,12 @@ amdsmi_status_t amdsmi_get_cpu_current_io_bandwidth(amdsmi_processor_handle proc amdsmi_status_t amdsmi_get_cpu_current_xgmi_bw(amdsmi_processor_handle processor_handle, amdsmi_link_id_bw_type_t link, uint32_t *xgmi_bw); -/** @} */ +/** @} bwquer */ -/*---------------------------------------------------------------------------*/ -/** @defgroup MetQuer HSMP Metrics Table */ -/*---------------------------------------------------------------------------*/ -/** @{ */ +/*****************************************************************************/ +/** @defgroup MetQuer HSMP Metrics Table + * @{ + */ /** * @brief Get HSMP metrics table version @@ -5270,12 +5270,12 @@ amdsmi_status_t amdsmi_get_hsmp_metrics_table_version(amdsmi_processor_handle pr amdsmi_status_t amdsmi_get_hsmp_metrics_table(amdsmi_processor_handle processor_handle, amdsmi_hsmp_metrics_table_t *metrics_table); -/** @} */ +/** @} MetQuer */ -/*---------------------------------------------------------------------------*/ -/** @defgroup auxiquer Auxillary functions */ -/*---------------------------------------------------------------------------*/ -/** @{ */ +/*****************************************************************************/ +/** @defgroup auxiquer Auxillary functions + * @{ + */ /** * @brief Get first online core on socket. @@ -5326,7 +5326,7 @@ amdsmi_status_t amdsmi_get_cpu_model(uint32_t *cpu_model); */ amdsmi_status_t amdsmi_get_esmi_err_msg(amdsmi_status_t status, const char **status_string); #endif -/** @} */ +/** @} auxiquer */ #ifdef __cplusplus } #endif // __cplusplus From 4728d05c5ff5ddbb1798377cd1ac824475ec05ae Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Wed, 7 Feb 2024 05:55:04 -0600 Subject: [PATCH 5/7] Align list and cache_info to Host Signed-off-by: Maisam Arif Change-Id: I4fa55b360b74d5a202d0b9b4eb7aee660b0a1bcf [ROCm/amdsmi commit: 77710921a4b9742a7196c94d7ad0d5874a42f856] --- projects/amdsmi/amdsmi_cli/amdsmi_commands.py | 35 +++++---- .../amdsmi/example/amd_smi_drm_example.cc | 2 +- projects/amdsmi/include/amd_smi/amdsmi.h | 12 ++-- projects/amdsmi/py-interface/README.md | 37 +++++----- .../amdsmi/py-interface/amdsmi_interface.py | 39 +++++----- .../amdsmi/py-interface/amdsmi_wrapper.py | 71 ++++++++++--------- projects/amdsmi/src/amd_smi/amd_smi.cc | 21 +++--- 7 files changed, 117 insertions(+), 100 deletions(-) diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py index ad21167b45..7462d2c53e 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py @@ -152,10 +152,10 @@ class AMDSMICommands(): # Store values based on format if self.logger.is_human_readable_format(): - self.logger.store_output(args.gpu, 'AMDSMI_SPACING_REMOVAL', {'bdf':bdf, 'uuid':uuid}) + self.logger.store_output(args.gpu, 'AMDSMI_SPACING_REMOVAL', {'gpu_bdf':bdf, 'gpu_uuid':uuid}) else: - self.logger.store_output(args.gpu, 'bdf', bdf) - self.logger.store_output(args.gpu, 'uuid', uuid) + self.logger.store_output(args.gpu, 'gpu_bdf', bdf) + self.logger.store_output(args.gpu, 'gpu_uuid', uuid) if multiple_devices: self.logger.store_multiple_device_output() @@ -550,21 +550,32 @@ class AMDSMICommands(): static_dict['vram'] = vram_info if args.cache: try: - cache_info = amdsmi_interface.amdsmi_get_gpu_cache_info(args.gpu) - logging.debug(f"cache_info dictionary = {cache_info}") - + cach_info_list = amdsmi_interface.amdsmi_get_gpu_cache_info(args.gpu) + logging.debug(f"cache_info dictionary = {cach_info_list}") if self.logger.is_human_readable_format(): - for key, cache_values in cache_info.items(): - cache_values['cache_size'] = f"{cache_values['cache_size']} KB" + cache_info_dict_format = {} + for cache_dict in cach_info_list: + cache_index = "cache_" + str(cache_dict["cache"]) + cache_info_dict_format[cache_index] = cache_dict + + # Remove cache index from new dictionary + cache_info_dict_format[cache_index].pop("cache") + + # Add cache_size unit + cache_info_dict_format[cache_index]["cache_size"] = f"{cache_info_dict_format[cache_index]['cache_size']} KB" + # take cache_properties out of list -> display as string, removing brackets - cache_values['cache_properties'] = ", ".join(cache_values['cache_properties']) - logging.debug(f"After human_readable | cache_info = {cache_info}") + cache_info_dict_format[cache_index]["cache_properties"] = ", ".join(cache_info_dict_format[cache_index]["cache_properties"]) + + cach_info_list = cache_info_dict_format + + logging.debug(f"After human_readable | cache_info = {cach_info_list}") except amdsmi_exception.AmdSmiLibraryException as e: - cache_info = "N/A" + cach_info_list = "N/A" logging.debug("Failed to get cache info for gpu %s | %s", gpu_id, e.get_error_info()) - static_dict['cache'] = cache_info + static_dict['cache_info'] = cach_info_list if 'ras' in current_platform_args: if args.ras: ras_dict = {"eeprom_version": "N/A", diff --git a/projects/amdsmi/example/amd_smi_drm_example.cc b/projects/amdsmi/example/amd_smi_drm_example.cc index 53a1863240..e18fc1cfce 100644 --- a/projects/amdsmi/example/amd_smi_drm_example.cc +++ b/projects/amdsmi/example/amd_smi_drm_example.cc @@ -323,7 +323,7 @@ int main() { printf("\tCache Level: %d, Cache Size: %d KB, Cache type: 0x%x\n", cache_info.cache[i].cache_level, cache_info.cache[i].cache_size, - cache_info.cache[i].properties); + cache_info.cache[i].cache_properties); printf("\tMax number CU shared: %d, Number of instances: %d\n", cache_info.cache[i].max_num_cu_shared, cache_info.cache[i].num_cache_instance); diff --git a/projects/amdsmi/include/amd_smi/amdsmi.h b/projects/amdsmi/include/amd_smi/amdsmi.h index 587ee9dea2..bbc3ffe782 100644 --- a/projects/amdsmi/include/amd_smi/amdsmi.h +++ b/projects/amdsmi/include/amd_smi/amdsmi.h @@ -541,19 +541,19 @@ typedef struct { * @brief cache properties */ typedef enum { - CACHE_PROPERTIES_ENABLED = 0x00000001, - CACHE_PROPERTIES_DATA_CACHE = 0x00000002, - CACHE_PROPERTIES_INST_CACHE = 0x00000004, - CACHE_PROPERTIES_CPU_CACHE = 0x00000008, - CACHE_PROPERTIES_SIMD_CACHE = 0x00000010, + AMDSMI_CACHE_PROPERTIES_ENABLED = 0x00000001, + AMDSMI_CACHE_PROPERTIES_DATA_CACHE = 0x00000002, + AMDSMI_CACHE_PROPERTIES_INST_CACHE = 0x00000004, + AMDSMI_CACHE_PROPERTIES_CPU_CACHE = 0x00000008, + AMDSMI_CACHE_PROPERTIES_SIMD_CACHE = 0x00000010, } amdsmi_cache_properties_type_t; typedef struct { uint32_t num_cache_types; struct cache_ { + uint32_t cache_properties; // amdsmi_cache_properties_type_t which is a bitmask uint32_t cache_size; /* In KB */ uint32_t cache_level; - uint32_t properties; // amdsmi_cache_properties_type_t which is a bitmask uint32_t max_num_cu_shared; /* Indicates how many Compute Units share this cache instance */ uint32_t num_cache_instance; /* total number of instance of this cache type */ uint32_t reserved[3]; diff --git a/projects/amdsmi/py-interface/README.md b/projects/amdsmi/py-interface/README.md index 3f9f4c4611..96abe99459 100644 --- a/projects/amdsmi/py-interface/README.md +++ b/projects/amdsmi/py-interface/README.md @@ -465,32 +465,33 @@ except AmdSmiException as e: ### amdsmi_get_gpu_cache_info -Description: Returns dictionary of cache information for the given GPU. +Description: Returns a list of dictionaries containing cache information for the given GPU. Input parameters: * `processor_handle` device which to query -Output: Dictionary of Dictionaries containing cache information -Schema: { cache_index: - { - cache_properties: - { - "type": "array", - "items": { - "type": "string" - } - }, - cache_size: {"type" : "number"}, - cache_level: {"type" : "number"}, - max_num_cu_shared: {"type" : "number"}, - num_cache_instance: {"type" : "number"} - } - } +Output: List of Dictionaries containing cache information following the schema below: +Schema: + +```JSON +{ + cache: {"type" : "number"}, + cache_properties: + { + "type" : "array", + "items" : {"type" : "string"} + }, + cache_size: {"type" : "number"}, + cache_level: {"type" : "number"}, + max_num_cu_shared: {"type" : "number"}, + num_cache_instance: {"type" : "number"} +} +``` Field | Description ---|--- -`cache_index` | cache index is a string of format "cache_#" up to 10 caches will be available +`cache` | cache index from 0-9 `cache_properties` | list of up to 4 cache property type strings. Ex. data ("DATA_CACHE"), instruction ("INST_CACHE"), CPU ("CPU_CACHE"), or SIMD ("SIMD_CACHE"). `cache_size` | size of cache in KB `cache_level` | level of cache diff --git a/projects/amdsmi/py-interface/amdsmi_interface.py b/projects/amdsmi/py-interface/amdsmi_interface.py index 0d7fff14e8..5def0d6a31 100644 --- a/projects/amdsmi/py-interface/amdsmi_interface.py +++ b/projects/amdsmi/py-interface/amdsmi_interface.py @@ -1652,51 +1652,52 @@ def amdsmi_get_gpu_vram_info( def amdsmi_get_gpu_cache_info( processor_handle: amdsmi_wrapper.amdsmi_processor_handle, -) -> Dict[str, Dict[str, Any]]: +) -> List[Dict[str, Any]]: if not isinstance(processor_handle, amdsmi_wrapper.amdsmi_processor_handle): raise AmdSmiParameterException( processor_handle, amdsmi_wrapper.amdsmi_processor_handle ) - cache_info = amdsmi_wrapper.amdsmi_gpu_cache_info_t() + cache_info_struct = amdsmi_wrapper.amdsmi_gpu_cache_info_t() _check_res( amdsmi_wrapper.amdsmi_get_gpu_cache_info( - processor_handle, ctypes.byref(cache_info)) + processor_handle, ctypes.byref(cache_info_struct)) ) - cache_info_dict = {} - for cache_index in range(cache_info.num_cache_types): + cache_info_list = [] + for cache_index in range(cache_info_struct.num_cache_types): # Put cache_properties at the start of the dictionary for readability cache_dict = { - "cache_properties": [], - "cache_size": cache_info.cache[cache_index].cache_size, - "cache_level": cache_info.cache[cache_index].cache_level, - "max_num_cu_shared": cache_info.cache[cache_index].max_num_cu_shared, - "num_cache_instance": cache_info.cache[cache_index].num_cache_instance + "cache": cache_index, + "cache_properties": [], # This will be a list of strings + "cache_size": cache_info_struct.cache[cache_index].cache_size, + "cache_level": cache_info_struct.cache[cache_index].cache_level, + "max_num_cu_shared": cache_info_struct.cache[cache_index].max_num_cu_shared, + "num_cache_instance": cache_info_struct.cache[cache_index].num_cache_instance } # Check against cache properties bitmask - cache_properties = cache_info.cache[cache_index].properties - data_cache = cache_properties & amdsmi_wrapper.CACHE_PROPERTIES_DATA_CACHE - inst_cache = cache_properties & amdsmi_wrapper.CACHE_PROPERTIES_INST_CACHE - cpu_cache = cache_properties & amdsmi_wrapper.CACHE_PROPERTIES_CPU_CACHE - simd_cache = cache_properties & amdsmi_wrapper.CACHE_PROPERTIES_SIMD_CACHE + cache_properties = cache_info_struct.cache[cache_index].cache_properties + data_cache = cache_properties & amdsmi_wrapper.AMDSMI_CACHE_PROPERTIES_DATA_CACHE + inst_cache = cache_properties & amdsmi_wrapper.AMDSMI_CACHE_PROPERTIES_INST_CACHE + cpu_cache = cache_properties & amdsmi_wrapper.AMDSMI_CACHE_PROPERTIES_CPU_CACHE + simd_cache = cache_properties & amdsmi_wrapper.AMDSMI_CACHE_PROPERTIES_SIMD_CACHE cache_properties_status = [data_cache, inst_cache, cpu_cache, simd_cache] cache_property_list = [] for cache_property in cache_properties_status: if cache_property: property_name = amdsmi_wrapper.amdsmi_cache_properties_type_t__enumvalues[cache_property] - property_name = property_name.replace("CACHE_PROPERTIES_", "") + property_name = property_name.replace("AMDSMI_CACHE_PROPERTIES_", "") cache_property_list.append(property_name) cache_dict["cache_properties"] = cache_property_list - cache_info_dict[f"cache_{cache_index}"] = cache_dict + cache_info_list.append(cache_dict) - if not cache_info_dict: + if not cache_info_list: raise AmdSmiLibraryException(amdsmi_wrapper.AMDSMI_STATUS_NO_DATA) - return cache_info_dict + return cache_info_list def amdsmi_get_gpu_vbios_info( diff --git a/projects/amdsmi/py-interface/amdsmi_wrapper.py b/projects/amdsmi/py-interface/amdsmi_wrapper.py index 5587576fac..9c21209eb0 100644 --- a/projects/amdsmi/py-interface/amdsmi_wrapper.py +++ b/projects/amdsmi/py-interface/amdsmi_wrapper.py @@ -815,17 +815,17 @@ amdsmi_vbios_info_t = struct_amdsmi_vbios_info_t # values for enumeration 'amdsmi_cache_properties_type_t' amdsmi_cache_properties_type_t__enumvalues = { - 1: 'CACHE_PROPERTIES_ENABLED', - 2: 'CACHE_PROPERTIES_DATA_CACHE', - 4: 'CACHE_PROPERTIES_INST_CACHE', - 8: 'CACHE_PROPERTIES_CPU_CACHE', - 16: 'CACHE_PROPERTIES_SIMD_CACHE', + 1: 'AMDSMI_CACHE_PROPERTIES_ENABLED', + 2: 'AMDSMI_CACHE_PROPERTIES_DATA_CACHE', + 4: 'AMDSMI_CACHE_PROPERTIES_INST_CACHE', + 8: 'AMDSMI_CACHE_PROPERTIES_CPU_CACHE', + 16: 'AMDSMI_CACHE_PROPERTIES_SIMD_CACHE', } -CACHE_PROPERTIES_ENABLED = 1 -CACHE_PROPERTIES_DATA_CACHE = 2 -CACHE_PROPERTIES_INST_CACHE = 4 -CACHE_PROPERTIES_CPU_CACHE = 8 -CACHE_PROPERTIES_SIMD_CACHE = 16 +AMDSMI_CACHE_PROPERTIES_ENABLED = 1 +AMDSMI_CACHE_PROPERTIES_DATA_CACHE = 2 +AMDSMI_CACHE_PROPERTIES_INST_CACHE = 4 +AMDSMI_CACHE_PROPERTIES_CPU_CACHE = 8 +AMDSMI_CACHE_PROPERTIES_SIMD_CACHE = 16 amdsmi_cache_properties_type_t = ctypes.c_uint32 # enum class struct_amdsmi_gpu_cache_info_t(Structure): pass @@ -835,9 +835,9 @@ class struct_cache_(Structure): struct_cache_._pack_ = 1 # source:False struct_cache_._fields_ = [ + ('cache_properties', ctypes.c_uint32), ('cache_size', ctypes.c_uint32), ('cache_level', ctypes.c_uint32), - ('properties', ctypes.c_uint32), ('max_num_cu_shared', ctypes.c_uint32), ('num_cache_instance', ctypes.c_uint32), ('reserved', ctypes.c_uint32 * 3), @@ -2308,6 +2308,11 @@ 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', + 'AMDSMI_CACHE_PROPERTIES_CPU_CACHE', + 'AMDSMI_CACHE_PROPERTIES_DATA_CACHE', + 'AMDSMI_CACHE_PROPERTIES_ENABLED', + 'AMDSMI_CACHE_PROPERTIES_INST_CACHE', + 'AMDSMI_CACHE_PROPERTIES_SIMD_CACHE', 'AMDSMI_CARD_FORM_FACTOR_OAM', 'AMDSMI_CARD_FORM_FACTOR_PCIE', 'AMDSMI_CARD_FORM_FACTOR_UNKNOWN', 'AMDSMI_CNTR_CMD_START', 'AMDSMI_CNTR_CMD_STOP', 'AMDSMI_COARSE_GRAIN_GFX_ACTIVITY', @@ -2424,29 +2429,27 @@ __all__ = \ 'AMDSMI_VRAM_VENDOR__WINBOND', 'AMDSMI_XGMI_STATUS_ERROR', 'AMDSMI_XGMI_STATUS_MULTIPLE_ERRORS', 'AMDSMI_XGMI_STATUS_NO_ERRORS', 'AMD_APU', 'AMD_CPU', - 'AMD_CPU_CORE', 'AMD_GPU', 'CACHE_PROPERTIES_CPU_CACHE', - 'CACHE_PROPERTIES_DATA_CACHE', 'CACHE_PROPERTIES_ENABLED', - 'CACHE_PROPERTIES_INST_CACHE', 'CACHE_PROPERTIES_SIMD_CACHE', - 'CLK_TYPE_DCEF', 'CLK_TYPE_DCLK0', 'CLK_TYPE_DCLK1', - 'CLK_TYPE_DF', 'CLK_TYPE_FIRST', 'CLK_TYPE_GFX', 'CLK_TYPE_MEM', - 'CLK_TYPE_PCIE', 'CLK_TYPE_SOC', 'CLK_TYPE_SYS', 'CLK_TYPE_VCLK0', - 'CLK_TYPE_VCLK1', 'CLK_TYPE__MAX', 'COMPUTE_PARTITION_CPX', - 'COMPUTE_PARTITION_DPX', 'COMPUTE_PARTITION_INVALID', - 'COMPUTE_PARTITION_QPX', 'COMPUTE_PARTITION_SPX', - 'COMPUTE_PARTITION_TPX', 'CONTAINER_DOCKER', 'CONTAINER_LXC', - 'FW_ID_ASD', 'FW_ID_CP_CE', 'FW_ID_CP_ME', 'FW_ID_CP_MEC1', - 'FW_ID_CP_MEC2', 'FW_ID_CP_MEC_JT1', 'FW_ID_CP_MEC_JT2', - 'FW_ID_CP_MES', 'FW_ID_CP_PFP', 'FW_ID_CP_PM4', 'FW_ID_DFC', - 'FW_ID_DMCU', 'FW_ID_DMCU_ERAM', 'FW_ID_DMCU_ISR', - 'FW_ID_DRV_CAP', 'FW_ID_FIRST', 'FW_ID_IMU_DRAM', - 'FW_ID_IMU_IRAM', 'FW_ID_ISP', 'FW_ID_MC', 'FW_ID_MES_KIQ', - 'FW_ID_MES_STACK', 'FW_ID_MES_THREAD1', 'FW_ID_MES_THREAD1_STACK', - 'FW_ID_MMSCH', 'FW_ID_PM', 'FW_ID_PPTABLE', 'FW_ID_PSP_BL', - 'FW_ID_PSP_DBG', 'FW_ID_PSP_INTF', 'FW_ID_PSP_KEYDB', - 'FW_ID_PSP_SOC', 'FW_ID_PSP_SOSDRV', 'FW_ID_PSP_SPL', - 'FW_ID_PSP_SYSDRV', 'FW_ID_PSP_TOC', 'FW_ID_REG_ACCESS_WHITELIST', - 'FW_ID_RLC', 'FW_ID_RLCV_LX7', 'FW_ID_RLC_P', - 'FW_ID_RLC_RESTORE_LIST_CNTL', 'FW_ID_RLC_RESTORE_LIST_GPM_MEM', + 'AMD_CPU_CORE', 'AMD_GPU', 'CLK_TYPE_DCEF', 'CLK_TYPE_DCLK0', + 'CLK_TYPE_DCLK1', 'CLK_TYPE_DF', 'CLK_TYPE_FIRST', 'CLK_TYPE_GFX', + 'CLK_TYPE_MEM', 'CLK_TYPE_PCIE', 'CLK_TYPE_SOC', 'CLK_TYPE_SYS', + 'CLK_TYPE_VCLK0', 'CLK_TYPE_VCLK1', 'CLK_TYPE__MAX', + 'COMPUTE_PARTITION_CPX', 'COMPUTE_PARTITION_DPX', + 'COMPUTE_PARTITION_INVALID', 'COMPUTE_PARTITION_QPX', + 'COMPUTE_PARTITION_SPX', 'COMPUTE_PARTITION_TPX', + 'CONTAINER_DOCKER', 'CONTAINER_LXC', 'FW_ID_ASD', 'FW_ID_CP_CE', + 'FW_ID_CP_ME', 'FW_ID_CP_MEC1', 'FW_ID_CP_MEC2', + 'FW_ID_CP_MEC_JT1', 'FW_ID_CP_MEC_JT2', 'FW_ID_CP_MES', + 'FW_ID_CP_PFP', 'FW_ID_CP_PM4', 'FW_ID_DFC', 'FW_ID_DMCU', + 'FW_ID_DMCU_ERAM', 'FW_ID_DMCU_ISR', 'FW_ID_DRV_CAP', + 'FW_ID_FIRST', 'FW_ID_IMU_DRAM', 'FW_ID_IMU_IRAM', 'FW_ID_ISP', + 'FW_ID_MC', 'FW_ID_MES_KIQ', 'FW_ID_MES_STACK', + 'FW_ID_MES_THREAD1', 'FW_ID_MES_THREAD1_STACK', 'FW_ID_MMSCH', + 'FW_ID_PM', 'FW_ID_PPTABLE', 'FW_ID_PSP_BL', 'FW_ID_PSP_DBG', + 'FW_ID_PSP_INTF', 'FW_ID_PSP_KEYDB', 'FW_ID_PSP_SOC', + 'FW_ID_PSP_SOSDRV', 'FW_ID_PSP_SPL', 'FW_ID_PSP_SYSDRV', + 'FW_ID_PSP_TOC', 'FW_ID_REG_ACCESS_WHITELIST', 'FW_ID_RLC', + 'FW_ID_RLCV_LX7', 'FW_ID_RLC_P', 'FW_ID_RLC_RESTORE_LIST_CNTL', + 'FW_ID_RLC_RESTORE_LIST_GPM_MEM', 'FW_ID_RLC_RESTORE_LIST_SRM_MEM', 'FW_ID_RLC_SAVE_RESTORE_LIST', 'FW_ID_RLC_SRLG', 'FW_ID_RLC_SRLS', 'FW_ID_RLC_V', 'FW_ID_RLX6', 'FW_ID_RLX6_CORE1', 'FW_ID_RLX6_DRAM_BOOT', diff --git a/projects/amdsmi/src/amd_smi/amd_smi.cc b/projects/amdsmi/src/amd_smi/amd_smi.cc index 2a992742ff..77b7fbe202 100644 --- a/projects/amdsmi/src/amd_smi/amd_smi.cc +++ b/projects/amdsmi/src/amd_smi/amd_smi.cc @@ -445,20 +445,21 @@ amdsmi_status_t amdsmi_get_gpu_cache_info( info->num_cache_types = rsmi_info.num_cache_types; for (unsigned int i =0; i < rsmi_info.num_cache_types; i++) { + // convert from sysfs type to CRAT type(HSA Cache Affinity type) + info->cache[i].cache_properties = 0; + if (rsmi_info.cache[i].flags & HSA_CACHE_TYPE_DATA) + info->cache[i].cache_properties |= AMDSMI_CACHE_PROPERTIES_DATA_CACHE; + if (rsmi_info.cache[i].flags & HSA_CACHE_TYPE_INSTRUCTION) + info->cache[i].cache_properties |= AMDSMI_CACHE_PROPERTIES_INST_CACHE; + if (rsmi_info.cache[i].flags & HSA_CACHE_TYPE_CPU) + info->cache[i].cache_properties |= AMDSMI_CACHE_PROPERTIES_CPU_CACHE; + if (rsmi_info.cache[i].flags & HSA_CACHE_TYPE_HSACU) + info->cache[i].cache_properties |= AMDSMI_CACHE_PROPERTIES_SIMD_CACHE; + info->cache[i].cache_size = rsmi_info.cache[i].cache_size_kb; info->cache[i].cache_level = rsmi_info.cache[i].cache_level; info->cache[i].max_num_cu_shared = rsmi_info.cache[i].max_num_cu_shared; info->cache[i].num_cache_instance = rsmi_info.cache[i].num_cache_instance; - // convert from sysfs type to CRAT type(HSA Cache Affinity type) - info->cache[i].properties = 0; - if (rsmi_info.cache[i].flags & HSA_CACHE_TYPE_DATA) - info->cache[i].properties |= CACHE_PROPERTIES_DATA_CACHE; - if (rsmi_info.cache[i].flags & HSA_CACHE_TYPE_INSTRUCTION) - info->cache[i].properties |= CACHE_PROPERTIES_INST_CACHE; - if (rsmi_info.cache[i].flags & HSA_CACHE_TYPE_CPU) - info->cache[i].properties |= CACHE_PROPERTIES_CPU_CACHE; - if (rsmi_info.cache[i].flags & HSA_CACHE_TYPE_HSACU) - info->cache[i].properties |= CACHE_PROPERTIES_SIMD_CACHE; } return AMDSMI_STATUS_SUCCESS; From 02a42f3d4bc10a2ccc697e4c5a592d199595062b Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Wed, 14 Feb 2024 09:10:04 -0600 Subject: [PATCH 6/7] Added Monitor command to Guest Linux Signed-off-by: Maisam Arif Change-Id: I378a1fcf49d7a69b09b6c93d77a4b084144a5633 [ROCm/amdsmi commit: dd18c117e6a062d1479864349ec91c48e955807a] --- projects/amdsmi/amdsmi_cli/amdsmi_parser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_parser.py b/projects/amdsmi/amdsmi_cli/amdsmi_parser.py index f92e7e7de7..d29e691ad5 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_parser.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_parser.py @@ -994,8 +994,8 @@ core limit value" def _add_monitor_parser(self, subparsers, func): - if not(self.helpers.is_baremetal() and self.helpers.is_linux()): - # This subparser is only applicable to Baremetal Linux + if not(self.helpers.is_linux()): + # This subparser is only applicable to Linux return # Subparser help text From aff2fc02c4ca31d6ef5ba6f802866ed06417c59c Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Thu, 15 Feb 2024 16:19:51 -0600 Subject: [PATCH 7/7] 24.3.0 Version update Change-Id: I936c896117ad64d06ea919a8b7bd6ba4cc388592 Signed-off-by: Maisam Arif [ROCm/amdsmi commit: 61f8888488249df09e774c7e8afbbb72e7104b3f] --- projects/amdsmi/CMakeLists.txt | 2 +- projects/amdsmi/amdsmi_cli/README.md | 2 +- projects/amdsmi/docs/doxygen/Doxyfile | 2 +- projects/amdsmi/include/amd_smi/amdsmi.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/amdsmi/CMakeLists.txt b/projects/amdsmi/CMakeLists.txt index 799e7607a7..a22bb04d1d 100755 --- a/projects/amdsmi/CMakeLists.txt +++ b/projects/amdsmi/CMakeLists.txt @@ -28,7 +28,7 @@ find_program(GIT NAMES git) ## Setup the package version based on git tags. set(PKG_VERSION_GIT_TAG_PREFIX "amdsmi_pkg_ver") -get_package_version_number("24.2.0" ${PKG_VERSION_GIT_TAG_PREFIX} GIT) +get_package_version_number("24.3.0" ${PKG_VERSION_GIT_TAG_PREFIX} GIT) message("Package version: ${PKG_VERSION_STR}") set(${AMD_SMI_LIBS_TARGET}_VERSION_MAJOR "${CPACK_PACKAGE_VERSION_MAJOR}") set(${AMD_SMI_LIBS_TARGET}_VERSION_MINOR "${CPACK_PACKAGE_VERSION_MINOR}") diff --git a/projects/amdsmi/amdsmi_cli/README.md b/projects/amdsmi/amdsmi_cli/README.md index 75059eb8bd..966baae543 100644 --- a/projects/amdsmi/amdsmi_cli/README.md +++ b/projects/amdsmi/amdsmi_cli/README.md @@ -78,7 +78,7 @@ 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: 24.2.0.0 | ROCm version: 6.1.0 | Platform: Linux +AMD System Management Interface | Version: 24.3.0.0 | ROCm version: 6.1.0 | Platform: Linux Baremetal options: diff --git a/projects/amdsmi/docs/doxygen/Doxyfile b/projects/amdsmi/docs/doxygen/Doxyfile index f181c6d7c1..c6b85d5a86 100644 --- a/projects/amdsmi/docs/doxygen/Doxyfile +++ b/projects/amdsmi/docs/doxygen/Doxyfile @@ -48,7 +48,7 @@ PROJECT_NAME = AMD SMI # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = "24.2.0.0" +PROJECT_NUMBER = "24.3.0.0" # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/projects/amdsmi/include/amd_smi/amdsmi.h b/projects/amdsmi/include/amd_smi/amdsmi.h index bbc3ffe782..e62974313f 100644 --- a/projects/amdsmi/include/amd_smi/amdsmi.h +++ b/projects/amdsmi/include/amd_smi/amdsmi.h @@ -151,7 +151,7 @@ typedef enum { #define AMDSMI_LIB_VERSION_YEAR 24 //! Major version should be changed for every header change (adding/deleting APIs, changing names, fields of structures, etc.) -#define AMDSMI_LIB_VERSION_MAJOR 2 +#define AMDSMI_LIB_VERSION_MAJOR 3 //! Minor version should be updated for each API change, but without changing headers #define AMDSMI_LIB_VERSION_MINOR 0