Fix indexing problem with api support function

Also fix potential issue with evaluating functionality of
functions with multiple sub-variants.

Change-Id: I9a09e52f3d3f3181e72578ed1f3bfd0d85516aa3


[ROCm/rocm_smi_lib commit: 1d8e16bff2]
This commit is contained in:
Chris Freehill
2020-03-11 21:14:56 -05:00
parent 06149e94bb
commit 4e2d769dcc
2 ha cambiato i file con 37 aggiunte e 5 eliminazioni
+7 -1
Vedi File
@@ -3071,7 +3071,13 @@ rsmi_func_iter_value_get(rsmi_func_id_iter_handle_t handle,
case SUBVARIANT_ITER:
sub_var_itr = reinterpret_cast<SubVariantIt *>(handle->func_id_iter);
value->id = *(*sub_var_itr);
// The sub-variant refers to monitors types. We store those as the exist
// in the file name. For example, for temp2_crit, 2 is stored (crit is the
// variant). These are 1-based values. But the RSMI user expects a 0-based
// value, so we will convert it to RSMI-space by subracting 1:
assert(*(*sub_var_itr) > 0);
value->id = *(*sub_var_itr) - 1;
break;
default:
@@ -56,6 +56,7 @@
#include "rocm_smi/rocm_smi_main.h"
#include "rocm_smi/rocm_smi_monitor.h"
#include "rocm_smi/rocm_smi_utils.h"
#include "rocm_smi/rocm_smi_exception.h"
namespace amd {
namespace smi {
@@ -385,9 +386,30 @@ void Monitor::fillSupportedFuncs(SupportedFuncMap *supported_funcs) {
// dependency monitors. The main assumption here is that
// variant_<sensor_i>'s sensor-based dependencies have the same index i;
// in other words, variant_i is not dependent on a sensor j, j != i
do {
ret = get_supported_sensors(mon_root + "/", *dep, &intersect);
if (ret == -1) {
// Initialize intersect with the available monitors for the first
// mandatory dependency.
ret = get_supported_sensors(mon_root + "/", *dep, &intersect);
std::string dep_path;
if (ret == -1) {
// In this case, the dependency is not sensor-specific, so just
// see if the file exists.
dep_path = mon_root + "/" + *dep;
if (!FileExists(dep_path.c_str())) {
mand_depends_met = false;
}
} else if (ret == -2) {
throw amd::smi::rsmi_exception(RSMI_STATUS_INTERNAL_EXCEPTION,
"Failed to parse monitor file name: " + dep_path);
}
dep++;
while (mand_depends_met && dep != it->second.mandatory_depends.end()) {
ret = get_supported_sensors(mon_root + "/", *dep, &sensors_i);
if (ret == 0) {
intersect = get_intersection(&sensors_i, &intersect);
} else if (ret == -1) {
// In this case, the dependency is not sensor-specific, so just
// see if the file exists.
std::string dep_path = mon_root + "/" + *dep;
@@ -395,9 +417,13 @@ void Monitor::fillSupportedFuncs(SupportedFuncMap *supported_funcs) {
mand_depends_met = false;
break;
}
} else if (ret == -2) {
throw amd::smi::rsmi_exception(RSMI_STATUS_INTERNAL_EXCEPTION,
"Failed to parse monitor file name: " + dep_path);
}
dep++;
} while (dep != it->second.mandatory_depends.end());
}
if (!mand_depends_met) {
it++;