From 99f0468803192ab914faf8cf003e4c8245f2b5aa Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Wed, 5 Jun 2024 23:18:16 -0500 Subject: [PATCH] Corrected voltage curve cli output in N/A case Signed-off-by: Maisam Arif Change-Id: I77e0888d94ba489eb4820cdd6c20e9f7de04241f [ROCm/amdsmi commit: 2197a393f4d486141bfddb880c63441fbca04b6d] --- projects/amdsmi/CHANGELOG.md | 2 +- projects/amdsmi/amdsmi_cli/amdsmi_commands.py | 70 +++++++++---------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/projects/amdsmi/CHANGELOG.md b/projects/amdsmi/CHANGELOG.md index c065447491..14c9492c5d 100644 --- a/projects/amdsmi/CHANGELOG.md +++ b/projects/amdsmi/CHANGELOG.md @@ -66,7 +66,7 @@ The file structure referenced to dpm_policy changed to soc_pstate and we have ch Previously on devices without a FRU we would not populate the product name in the `amdsmi_board_info_t` structure, now we will fallback to using the name listed according to the pciids file if available. - **Updated CLI voltage curve command output**. -The output for `amd-smi metric --voltage-curve` now splits the frequency and voltage output by curve point or outputs N/A if not applicable +The output for `amd-smi metric --voltage-curve` now splits the frequency and voltage output by curve point or outputs N/A for each curve point if not applicable ```shell GPU: 0 diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py index 109d7daae4..0729b6f0de 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py @@ -1792,46 +1792,46 @@ class AMDSMICommands(): values_dict["fan"] = fan_dict if "voltage_curve" in current_platform_args: if args.voltage_curve: + # Populate N/A values per voltage point + voltage_point_dict = {} + for point in range(amdsmi_interface.AMDSMI_NUM_VOLTAGE_CURVE_POINTS): + voltage_point_dict[f'point_{point}_frequency'] = "N/A" + voltage_point_dict[f'point_{point}_voltage'] = "N/A" + try: od_volt = amdsmi_interface.amdsmi_get_gpu_od_volt_info(args.gpu) logging.debug(f"OD Voltage info: {od_volt}") - - # Populate N/A values per voltage point - voltage_point_dict = {} - for point in range(amdsmi_interface.AMDSMI_NUM_VOLTAGE_CURVE_POINTS): - voltage_point_dict[f'point_{point}_frequency'] = "N/A" - voltage_point_dict[f'point_{point}_voltage'] = "N/A" - - # Populate voltage point values - for point in range(amdsmi_interface.AMDSMI_NUM_VOLTAGE_CURVE_POINTS): - if isinstance(od_volt, dict): - logging.debug(f"point_{point} frequency: {od_volt['curve.vc_points'][point].frequency}") - logging.debug(f"point_{point} voltage: {od_volt['curve.vc_points'][point].voltage}") - frequency = int(od_volt["curve.vc_points"][point].frequency / 1000000) - voltage = int(od_volt["curve.vc_points"][point].voltage) - else: - frequency = "N/A" - voltage = "N/A" - - if frequency == 0: - frequency = "N/A" - - if voltage == 0: - voltage = "N/A" - - if frequency != "N/A": - frequency = self.helpers.unit_format(self.logger, frequency, "Mhz") - - if voltage != "N/A": - voltage = self.helpers.unit_format(self.logger, voltage, "mV") - - voltage_point_dict[f'point_{point}_frequency'] = frequency - voltage_point_dict[f'point_{point}_voltage'] = voltage - - values_dict['voltage_curve'] = voltage_point_dict except amdsmi_exception.AmdSmiLibraryException as e: - values_dict['voltage_curve'] = "N/A" + od_volt = "N/A" # Value not used, but needs to not be a dict logging.debug("Failed to get voltage curve for gpu %s | %s", gpu_id, e.get_error_info()) + + # Populate voltage point values + for point in range(amdsmi_interface.AMDSMI_NUM_VOLTAGE_CURVE_POINTS): + if isinstance(od_volt, dict): + logging.debug(f"point_{point} frequency: {od_volt['curve.vc_points'][point].frequency}") + logging.debug(f"point_{point} voltage: {od_volt['curve.vc_points'][point].voltage}") + frequency = int(od_volt["curve.vc_points"][point].frequency / 1000000) + voltage = int(od_volt["curve.vc_points"][point].voltage) + else: + frequency = "N/A" + voltage = "N/A" + + if frequency == 0: + frequency = "N/A" + + if voltage == 0: + voltage = "N/A" + + if frequency != "N/A": + frequency = self.helpers.unit_format(self.logger, frequency, "Mhz") + + if voltage != "N/A": + voltage = self.helpers.unit_format(self.logger, voltage, "mV") + + voltage_point_dict[f'point_{point}_frequency'] = frequency + voltage_point_dict[f'point_{point}_voltage'] = voltage + + values_dict['voltage_curve'] = voltage_point_dict if "overdrive" in current_platform_args: if args.overdrive: try: