From fca52ec7ca5b53ea04f71a05b2b704bf6c3422be Mon Sep 17 00:00:00 2001 From: Chris Freehill Date: Fri, 11 Sep 2020 17:32:54 -0500 Subject: [PATCH] Make sure all sensor labels have valid mappings There may not be label files for some sensors on older devices. We need to make sure there is a valid dummy mapping in these cases. Change-Id: Id6a8b71e554552be84a0e42a477070b504151e7f [ROCm/amdsmi commit: b015052a0765e81a090f766571bc68e2d61da6c1] --- projects/amdsmi/src/rocm_smi_monitor.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/projects/amdsmi/src/rocm_smi_monitor.cc b/projects/amdsmi/src/rocm_smi_monitor.cc index d4d288cc76..f7ca2631c2 100755 --- a/projects/amdsmi/src/rocm_smi_monitor.cc +++ b/projects/amdsmi/src/rocm_smi_monitor.cc @@ -323,22 +323,26 @@ Monitor::setTempSensorLabelMap(void) { } auto add_temp_sensor_entry = [&](uint32_t file_index) { ret = readMonitor(kMonTempLabel, file_index, &type_str); - rsmi_temperature_type_t t_type = kTempSensorNameMap.at(type_str); + rsmi_temperature_type_t t_type; // If readMonitor fails, there is no label file for the file_index. // In that case, map the type to file index 0, which is not supported // and will fail appropriately later when we check for support. if (ret) { - temp_type_index_map_.insert({t_type, 0}); index_temp_type_map_.insert({file_index, RSMI_TEMP_TYPE_INVALID}); } else { - temp_type_index_map_.insert({t_type, file_index}); + t_type = kTempSensorNameMap.at(type_str); + temp_type_index_map_[t_type] = file_index; index_temp_type_map_.insert({file_index, t_type}); } index_temp_type_map_.insert({file_index, t_type}); return 0; }; + for (uint32_t t = RSMI_TEMP_TYPE_FIRST; t <= RSMI_TEMP_TYPE_LAST; ++t) { + temp_type_index_map_.insert( + {static_cast(t), RSMI_TEMP_TYPE_INVALID}); + } for (uint32_t i = 1; i <= RSMI_TEMP_TYPE_LAST + 1; ++i) { ret = add_temp_sensor_entry(i); if (ret) {