Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

fix stoi issue for specific platform (#28437)

Wanglei Shen51bb5c194d03
diff --git a/src/inference/src/os/lin/lin_system_conf.cpp b/src/inference/src/os/lin/lin_system_conf.cpp
index 5ff1131185f..6a6f02799ca 100644
--- a/src/inference/src/os/lin/lin_system_conf.cpp
+++ b/src/inference/src/os/lin/lin_system_conf.cpp
@@ -516,8 +516,7 @@ void parse_cache_info_linux(const std::vector<std::vector<std::string>> system_i
if ((system_info_table[n][2].size() > 0) || (system_info_table[n][1].size() > 0)) {
info_index = system_info_table[n][2].size() > 0 ? 2 : 1;
if (-1 == _cpu_mapping_table[n][CPU_MAP_SOCKET_ID]) {
- std::string::size_type pos = 0;
- std::string::size_type endpos = 0;
+ std::string::size_type pos = 0, endpos = 0, endpos1 = 0;
std::string sub_str;
int core_1;
@@ -531,7 +530,10 @@ void parse_cache_info_linux(const std::vector<std::vector<std::string>> system_i
}
while (1) {
- if ((endpos = system_info_table[n][info_index].find('-', pos)) != std::string::npos) {
+ endpos = system_info_table[n][info_index].find('-', pos);
+ endpos1 = system_info_table[n][info_index].find(',', pos);
+
+ if (endpos < endpos1) {
sub_str = system_info_table[n][info_index].substr(pos, endpos - pos);
core_1 = std::stoi(sub_str);
sub_str = system_info_table[n][info_index].substr(endpos + 1);
@@ -549,8 +551,8 @@ void parse_cache_info_linux(const std::vector<std::vector<std::string>> system_i
return;
};
}
- } else if (pos != std::string::npos) {
- sub_str = system_info_table[n][info_index].substr(pos);
+ } else {
+ sub_str = system_info_table[n][info_index].substr(pos, endpos1 - pos);
core_1 = std::stoi(sub_str);
_cpu_mapping_table[core_1][CPU_MAP_SOCKET_ID] = _sockets;
_cpu_mapping_table[core_1][CPU_MAP_NUMA_NODE_ID] =
@@ -559,11 +561,10 @@ void parse_cache_info_linux(const std::vector<std::vector<std::string>> system_i
if (_processors == 0) {
return;
};
- endpos = pos;
}
- if ((pos = system_info_table[n][2].find(',', endpos)) != std::string::npos) {
- pos++;
+ if (endpos1 != std::string::npos) {
+ pos = endpos1 + 1;
} else {
break;
}
diff --git a/src/inference/tests/unit/cpu_map_parser/cache_parser_linux.cpp b/src/inference/tests/unit/cpu_map_parser/cache_parser_linux.cpp
index 8eece188e4c..beedd33a342 100644
--- a/src/inference/tests/unit/cpu_map_parser/cache_parser_linux.cpp
+++ b/src/inference/tests/unit/cpu_map_parser/cache_parser_linux.cpp
@@ -1275,6 +1275,41 @@ LinuxCpuMapTestCase cache_1sockets_14cores_hyperthreading_1 = {
},
{},
};
+LinuxCpuMapTestCase cache_1sockets_14cores = {
+ 9,
+ 1,
+ 1,
+ 9,
+ {{9, 1, 8, 0, 0, 0}},
+ {
+ {0, 0, 0, 0, MAIN_CORE_PROC, 0, -1},
+ {6, 0, 0, 1, EFFICIENT_CORE_PROC, 1, -1},
+ {7, 0, 0, 2, EFFICIENT_CORE_PROC, 1, -1},
+ {8, 0, 0, 3, EFFICIENT_CORE_PROC, 1, -1},
+ {9, 0, 0, 4, EFFICIENT_CORE_PROC, 1, -1},
+ {10, 0, 0, 5, EFFICIENT_CORE_PROC, 2, -1},
+ {11, 0, 0, 6, EFFICIENT_CORE_PROC, 2, -1},
+ {12, 0, 0, 7, EFFICIENT_CORE_PROC, 2, -1},
+ {13, 0, 0, 8, EFFICIENT_CORE_PROC, 2, -1},
+ },
+ {
+ {"0", "0", "0,6-13"},
+ {"", "", ""},
+ {"", "", ""},
+ {"", "", ""},
+ {"", "", ""},
+ {"", "", ""},
+ {"6", "6-9", "0,6-13"},
+ {"7", "6-9", "0,6-13"},
+ {"8", "6-9", "0,6-13"},
+ {"9", "6-9", "0,6-13"},
+ {"10", "10-13", "0,6-13"},
+ {"11", "10-13", "0,6-13"},
+ {"12", "10-13", "0,6-13"},
+ {"13", "10-13", "0,6-13"},
+ },
+ {},
+};
LinuxCpuMapTestCase cache_1sockets_10cores_hyperthreading = {
12,
1,
@@ -1475,6 +1510,7 @@ INSTANTIATE_TEST_SUITE_P(CPUMap,
cache_1sockets_16cores_hyperthreading,
cache_1sockets_14cores_hyperthreading,
cache_1sockets_14cores_hyperthreading_1,
+ cache_1sockets_14cores,
cache_1sockets_10cores_hyperthreading,
cache_1sockets_8cores_hyperthreading,
cache_1sockets_8cores_hyperthreading_1,