Skip to content

Commit 898ae4f

Browse files
dmitrii-galantsevcharis-poag-amd
authored andcommitted
[SWDEV-495169] Update ROCm SMI CLI and Error handling (#3)
Issues include: Update ROCm SMI displaying None or Not Supported to N/A Update ROCm SMI displaying err msg to instead log err Signed-off-by: Juan Castillo juan.castillo@amd.com Change-Id: I1a2ce6e4f329666b5666664a7d7b4475d6c1cbc7
1 parent fdc8d73 commit 898ae4f

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

python_smi_tools/rocm_smi.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1980,22 +1980,28 @@ def showAllConcise(deviceList):
19801980
+ getComputePartition(device, silent)
19811981
+ ", " + getPartitionId(device, silent))
19821982
sclk = showCurrentClocks([device], 'sclk', concise=silent)
1983+
if not sclk:
1984+
sclk = 'N/A'
19831985
mclk = showCurrentClocks([device], 'mclk', concise=silent)
1986+
if not mclk:
1987+
mclk = 'N/A'
19841988
(retCode, fanLevel, fanSpeed) = getFanSpeed(device, silent)
19851989
fan = str(fanSpeed) + '%'
19861990
if getPerfLevel(device, silent) != -1:
19871991
perf = getPerfLevel(device, silent)
19881992
else:
1989-
perf = 'Unsupported'
1993+
perf = 'N/A'
19901994
if getMaxPower(device, silent) != -1:
19911995
pwrCap = str(getMaxPower(device, silent)) + 'W'
19921996
else:
1993-
pwrCap = 'Unsupported'
1997+
pwrCap = 'N/A'
19941998
if getGpuUse(device, silent) != -1:
19951999
gpu_busy = str(getGpuUse(device, silent)) + '%'
19962000
else:
1997-
gpu_busy = 'Unsupported'
2001+
gpu_busy = 'N/A'
19982002
allocated_mem_percent = getAllocatedMemoryPercent(device)
2003+
if allocated_mem_percent['ret'] != rsmi_status_t.RSMI_STATUS_SUCCESS:
2004+
allocated_mem_percent['combined'] = 'N/A'
19992005

20002006
# Top Row - per device data
20012007
values['card%s' % (str(device))] = [device, getNodeId(device),

src/rocm_smi.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,9 @@ static rsmi_status_t get_dev_mon_value(amd::smi::MonitorTypes type,
368368
}
369369

370370
if (!amd::smi::IsInteger(val_str)) {
371-
std::cerr << "Expected integer value from monitor,"
372-
" but got \"" << val_str << "\"" << std::endl;
371+
std::ostringstream ss;
372+
ss << "Expected integer value from monitor, but got \"" << val_str << "\"";
373+
LOG_ERROR(ss);
373374
return RSMI_STATUS_UNEXPECTED_DATA;
374375
}
375376

@@ -397,8 +398,9 @@ static rsmi_status_t get_dev_mon_value(amd::smi::MonitorTypes type,
397398
}
398399

399400
if (!amd::smi::IsInteger(val_str)) {
400-
std::cerr << "Expected integer value from monitor,"
401-
" but got \"" << val_str << "\"" << std::endl;
401+
std::ostringstream ss;
402+
ss << "Expected integer value from monitor, but got \"" << val_str << "\"";
403+
LOG_ERROR(ss);
402404
return RSMI_STATUS_UNEXPECTED_DATA;
403405
}
404406

0 commit comments

Comments
 (0)