From 06d32ac405d2559860ade76b87a66d2d3ffc945d Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Thu, 22 Feb 2024 13:45:02 -0600 Subject: [PATCH] Align to Host left adjusted topology output Signed-off-by: Maisam Arif Change-Id: I8e56156200d5eface7f069ccf82a6b7503e1a48c [ROCm/amdsmi commit: 16c34e91ac14bc3bbe89c81e0a75c494b8b0ef49] --- projects/amdsmi/amdsmi_cli/amdsmi_commands.py | 30 +++++++++++++++---- projects/amdsmi/amdsmi_cli/amdsmi_logger.py | 4 +-- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py index 964fea4401..102bab41b6 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py @@ -2630,7 +2630,11 @@ class AMDSMICommands(): if args.access: tabular_output = [] for src_gpu_index, src_gpu in enumerate(args.gpu): - tabular_output_dict = {'gpu': amdsmi_interface.amdsmi_get_gpu_device_bdf(src_gpu)} + gpu_bdf = amdsmi_interface.amdsmi_get_gpu_device_bdf(src_gpu) + if self.logger.is_human_readable_format(): + tabular_output_dict = {'gpu' : f"{gpu_bdf} "} + else: + tabular_output_dict = {'gpu' : gpu_bdf} src_gpu_links = {} for dest_gpu in args.gpu: dest_gpu_id = self.helpers.get_gpu_id_from_device_handle(dest_gpu) @@ -2662,7 +2666,11 @@ class AMDSMICommands(): if args.weight: tabular_output = [] for src_gpu_index, src_gpu in enumerate(args.gpu): - tabular_output_dict = {'gpu': amdsmi_interface.amdsmi_get_gpu_device_bdf(src_gpu)} + gpu_bdf = amdsmi_interface.amdsmi_get_gpu_device_bdf(src_gpu) + if self.logger.is_human_readable_format(): + tabular_output_dict = {'gpu' : f"{gpu_bdf} "} + else: + tabular_output_dict = {'gpu' : gpu_bdf} src_gpu_weight = {} for dest_gpu in args.gpu: dest_gpu_id = self.helpers.get_gpu_id_from_device_handle(dest_gpu) @@ -2695,7 +2703,11 @@ class AMDSMICommands(): if args.hops: tabular_output = [] for src_gpu_index, src_gpu in enumerate(args.gpu): - tabular_output_dict = {'gpu': amdsmi_interface.amdsmi_get_gpu_device_bdf(src_gpu)} + gpu_bdf = amdsmi_interface.amdsmi_get_gpu_device_bdf(src_gpu) + if self.logger.is_human_readable_format(): + tabular_output_dict = {'gpu' : f"{gpu_bdf} "} + else: + tabular_output_dict = {'gpu' : gpu_bdf} src_gpu_hops = {} for dest_gpu in args.gpu: dest_gpu_id = self.helpers.get_gpu_id_from_device_handle(dest_gpu) @@ -2728,7 +2740,11 @@ class AMDSMICommands(): if args.link_type: tabular_output = [] for src_gpu_index, src_gpu in enumerate(args.gpu): - tabular_output_dict = {'gpu': amdsmi_interface.amdsmi_get_gpu_device_bdf(src_gpu)} + gpu_bdf = amdsmi_interface.amdsmi_get_gpu_device_bdf(src_gpu) + if self.logger.is_human_readable_format(): + tabular_output_dict = {'gpu' : f"{gpu_bdf} "} + else: + tabular_output_dict = {'gpu' : gpu_bdf} src_gpu_link_type = {} for dest_gpu in args.gpu: dest_gpu_id = self.helpers.get_gpu_id_from_device_handle(dest_gpu) @@ -2766,7 +2782,11 @@ class AMDSMICommands(): if args.numa_bw: tabular_output = [] for src_gpu_index, src_gpu in enumerate(args.gpu): - tabular_output_dict = {'gpu': amdsmi_interface.amdsmi_get_gpu_device_bdf(src_gpu)} + gpu_bdf = amdsmi_interface.amdsmi_get_gpu_device_bdf(src_gpu) + if self.logger.is_human_readable_format(): + tabular_output_dict = {'gpu' : f"{gpu_bdf} "} + else: + tabular_output_dict = {'gpu' : gpu_bdf} src_gpu_link_type = {} for dest_gpu in args.gpu: dest_gpu_id = self.helpers.get_gpu_id_from_device_handle(dest_gpu) diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_logger.py b/projects/amdsmi/amdsmi_cli/amdsmi_logger.py index 240aba67d1..b77ffe6187 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_logger.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_logger.py @@ -118,8 +118,8 @@ class AMDSMILogger(): table_values += value.rjust(12) elif key in ('throttle_status', 'pcie_replay'): table_values += value.rjust(13) - elif 'gpu_' in key: # handle topology tables - table_values += value.rjust(13) + elif 'gpu_' in key: # This is just for handling topology tables + table_values += value.ljust(13) else: table_values += value.rjust(10) return table_values.rstrip()