From 19bbfffbfce6825bbc8213c8365ddebc988dc106 Mon Sep 17 00:00:00 2001 From: Elena Sakhnovitch Date: Thu, 9 Jun 2022 19:52:38 -0400 Subject: [PATCH] [rocm_smi.py] Hiding unnecessary N/A lines Hiding not applicable/unsupported sensors under INFO Signed-off-by: Elena Sakhnovitch Change-Id: I89c80ca7c6365ef3a2dd751a575ddf90044c8a2e [ROCm/rocm_smi_lib commit: 0f88f59ddd0483f3f169f51c85109b53b74851eb] --- .../rocm-smi-lib/python_smi_tools/rocm_smi.py | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/projects/rocm-smi-lib/python_smi_tools/rocm_smi.py b/projects/rocm-smi-lib/python_smi_tools/rocm_smi.py index de014a77f3..f86870aa96 100755 --- a/projects/rocm-smi-lib/python_smi_tools/rocm_smi.py +++ b/projects/rocm-smi-lib/python_smi_tools/rocm_smi.py @@ -462,6 +462,26 @@ def printErrLog(device, err): logging.debug(errstr) +def printInfoLog(device, metricName, value): + """ Print out an info line to the SMI log + + @param device: DRM device identifier + @param metricName: Title of the item to print to the log + @param value: The item's value to print to the log + """ + global PRINT_JSON + + if not PRINT_JSON: + if value is not None: + logstr = 'GPU[%s]\t: %s: %s' % (device, metricName, value) + else: + logstr = 'GPU[%s]\t: %s' % (device, metricName) + if device is None: + logstr = logstr[13:] + + logging.info(logstr) + + def printEventList(device, delay, eventList): """ Print out notification events for a specified device @@ -1539,7 +1559,11 @@ def showCurrentTemps(deviceList): printLogSpacer(' Temperature ') for device in deviceList: for sensor in temp_type_lst: - printLog(device, 'Temperature (Sensor %s) (C)' % (sensor), getTemp(device, sensor)) + temp = getTemp(device, sensor) + if temp != 'N/A': + printLog(device, 'Temperature (Sensor %s) (C)' % (sensor), temp) + else: + printInfoLog(device, 'Temperature (Sensor %s) (C)' % (sensor), temp) printLogSpacer() @@ -1675,7 +1699,7 @@ def showGpuUse(deviceList): for ut_counter in util_counters: printLog(device, utilization_counter_name[ut_counter.type], ut_counter.val) else: - printLog(device, 'GFX Activity', 'N/A') + printInfoLog(device, 'GFX Activity', 'N/A') printLogSpacer()