Update get_frequencies to handle failures.

Show an optional debug log (RSMI_DEBUG_BITFIELD=2) to
the user in the following scenarios:
1. If more than one current frequency is found
2. If frequencies are not read in increasing order of
   their value
If current frequency is not available, index for it is
set to -1, values will not have * next to it in the
output. This will also be handled in rocm_smi.py.

Signed-off-by: Divya Shikre <DivyaUday.Shikre@amd.com>
Change-Id: I477ec065f7513c8045d6392f12ef6cb835a6b8f6


[ROCm/amdsmi commit: afe996c2ed]
This commit is contained in:
Divya Shikre authored and Divya Uday Shikre committed 2022-05-11 15:33:15 -04:00
1 parent 3cbd1652de
commit f4e33b90c9
3 files changed
+45 -9

No files matched your search

@@ -1453,6 +1453,9 @@ def showCurrentClocks(deviceList, clk_defined=None, concise=False):
ret = rocmsmi.rsmi_dev_gpu_clk_freq_get(device, rsmi_clk_names_dict[clk_defined], byref(freq))
if rsmi_ret_ok(ret, device, clk_defined, True):
levl = freq.current
if levl >= freq.num_supported:
printLog(device, '%s current clock frequency not found' % (clk_defined), None)
continue
fr = freq.frequency[levl] / 1000000
if concise: # in case function is used for concise output, no need to print.
return '{:.0f}Mhz'.format(fr)
@@ -1466,6 +1469,9 @@ def showCurrentClocks(deviceList, clk_defined=None, concise=False):
ret = rocmsmi.rsmi_dev_gpu_clk_freq_get(device, rsmi_clk_names_dict[clk_type], byref(freq))
if rsmi_ret_ok(ret, device, clk_type, True):
levl = freq.current
if levl >= freq.num_supported:
printLog(device, '%s current clock frequency not found' % (clk_type), None)
continue
fr = freq.frequency[levl] / 1000000
if PRINT_JSON:
printLog(device, '%s clock speed:' % (clk_type), '(%sMhz)' % (str(fr)[:-2]))
@@ -1479,6 +1485,9 @@ def showCurrentClocks(deviceList, clk_defined=None, concise=False):
ret = rocmsmi.rsmi_dev_pci_bandwidth_get(device, byref(bw))
if rsmi_ret_ok(ret, device, 'PCIe', True):
current_f = bw.transfer_rate.current
if current_f >= bw.transfer_rate.num_supported:
printLog(device, 'PCIe current clock frequency not found', None )
continue
fr = '{:.1f}GT/s x{}'.format(bw.transfer_rate.frequency[current_f] / 1000000000,
bw.lanes[current_f])
printLog(device, 'pcie clock level', '{} ({})'.format(current_f, fr))