[SWDEV-496639] Align amd-smi xgmi statistics

The xgmi read and write values were displayed in KB. The numbers became
unreadable due to misalignment. So, converted read and write values to
readable units using helper function. Updated Changelog.

Signed-off-by: Bindhiya Kanangot Balakrishnan <Bindhiya.KanangotBalakrishnan@amd.com>
Change-Id: I4c90a1de8a58c29cbdf43fe3480a1546f3946673
Этот коммит содержится в:
Bindhiya Kanangot Balakrishnan
2024-11-19 09:37:43 -06:00
коммит произвёл Maisam Arif
родитель d323ecff97
Коммит 288b11df37
3 изменённых файлов: 36 добавлений и 6 удалений
+20
Просмотреть файл
@@ -19,6 +19,26 @@ Full documentation for amd_smi_lib is available at [https://rocm.docs.amd.com/pr
- `amd-smi static --bus` and `amd-smi STATIC --BUS` will produce identical results.
- `amd-smi static -b` and `amd-smi static -B` will still return different results (-b for bus and -B for board).
- **Converted xgmi read and write from KB's to readable units**.
- With this change `amd-smi xgmi` will now display the statistics in dynamically selected readable units.
- Example output is shown below.
```shell
$ amd-smi xgmi
LINK METRIC TABLE:
bdf bit_rate max_bandwidth link_type 0000:05:00.0 0000:26:00.0 0000:46:00.0 0000:65:00.0 0000:85:00.0 0000:a6:00.0 0000:c6:00.0 0000:e5:00.0
GPU0 0000:05:00.0 32 Gb/s 512 Gb/s XGMI
Read N/A 1.123 PB 1.123 PB 1.123 PB 1.123 PB 1.123 PB 1.123 PB 1.123 PB
Write N/A 229.1 MB 229.1 MB 229.1 MB 229.1 MB 229.1 MB 229.1 MB 229.1 MB
GPU1 0000:26:00.0 32 Gb/s 512 Gb/s XGMI
Read 1.123 PB N/A 1.123 PB 1.123 PB 1.123 PB 1.123 PB 1.123 PB 1.123 PB
Write 229.1 MB N/A 229.1 MB 229.1 MB 229.1 MB 229.1 MB 229.1 MB 229.1 MB
GPU2 0000:46:00.0 32 Gb/s 512 Gb/s XGMI
Read 1.123 PB 1.123 PB N/A 1.123 PB 1.123 PB 1.123 PB 1.123 PB 1.123 PB
Write 229.1 MB 229.1 MB N/A 229.1 MB 229.1 MB 229.1 MB 229.1 MB 229.1 MB
...
```
### Resolved issues
### Upcoming changes
+4 -4
Просмотреть файл
@@ -5298,8 +5298,8 @@ class AMDSMICommands():
data_unit = 'KB'
if self.logger.is_human_readable_format():
dest_link_dict['read'] = f"{read} {data_unit}"
dest_link_dict['write'] = f"{write} {data_unit}"
dest_link_dict['read'] = self.helpers.convert_bytes_to_readable(read * 1024, True)
dest_link_dict['write'] = self.helpers.convert_bytes_to_readable(write * 1024, True)
elif self.logger.is_json_format():
dest_link_dict['read'] = {"value" : read,
"unit" : data_unit}
@@ -5350,8 +5350,8 @@ class AMDSMICommands():
tabular_output.append(tabular_output_dict)
# Create Read and Write rows and add to tabular_output
read_output_dict = {"RW" : "Read"}
write_output_dict = {"RW" : "Write"}
read_output_dict = {"RW" : " Read"}
write_output_dict = {"RW" : " Write"}
for key, value in xgmi_dict.items():
if key == "link_metrics":
for link_key, link_value in value.items():
+12 -2
Просмотреть файл
@@ -779,10 +779,20 @@ class AMDSMIHelpers():
return False, profile_presets.values()
def convert_bytes_to_readable(self, bytes_input):
def convert_bytes_to_readable(self, bytes_input, format_length=None):
for unit in ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB"]:
if abs(bytes_input) < 1024:
return f"{bytes_input:3.1f} {unit}"
if format_length is not None:
if bytes_input < 10:
return f"{bytes_input:4.3f} {unit}"
elif bytes_input < 100:
return f"{bytes_input:4.2f} {unit}"
elif bytes_input < 1000:
return f"{bytes_input:4.1f} {unit}"
else:
return f"{bytes_input:4.0f} {unit}"
else:
return f"{bytes_input:3.1f} {unit}"
bytes_input /= 1024
return f"{bytes_input:.1f} YB"