OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
fix CPU affinity check issues (#32596)
Wanglei Shen3da969d30dd8
diff --git a/src/inference/src/os/lin/lin_system_conf.cpp b/src/inference/src/os/lin/lin_system_conf.cppindex 165f666bcbf..d5a75556f03 100644--- a/src/inference/src/os/lin/lin_system_conf.cpp+++ b/src/inference/src/os/lin/lin_system_conf.cpp@@ -163,7 +163,7 @@ CPU::CPU() {numa_node_list.assign(_sockets, std::vector<int>());for (int i = 0; i < _processors; i++) {- if (CPU_ISSET(i, mask)) {+ if (CPU_ISSET(_cpu_mapping_table[i][CPU_MAP_PROCESSOR_ID], mask)) {valid_cpu_mapping_table.emplace_back(_cpu_mapping_table[i]);if (_cpu_mapping_table[i][CPU_MAP_CORE_TYPE] == MAIN_CORE_PROC) {phy_core_list.emplace_back(_cpu_mapping_table[i][CPU_MAP_CORE_ID]);@@ -340,33 +340,28 @@ void parse_node_info_linux(const std::vector<std::string> node_info_table,int core_1 = 0;int core_2 = 0;std::string::size_type pos = 0;- std::string::size_type endpos = 0;+ std::string::size_type endpos_1 = 0;+ std::string::size_type endpos_2 = 0;std::string sub_str = "";- if (((endpos = one_info.find('-', pos)) == std::string::npos) &&- ((endpos = one_info.find(',', pos)) != std::string::npos)) {- while (endpos != std::string::npos) {+ while (pos != std::string::npos) {+ endpos_1 = one_info.find(',', pos);+ endpos_2 = one_info.find('-', pos);+ if ((endpos_1 < endpos_2) || (endpos_1 == std::string::npos && endpos_2 == std::string::npos)) {sub_str = one_info.substr(pos);core_1 = std::stoi(sub_str);nodes_table.push_back({core_1, core_1, node_index});- endpos = one_info.find(',', pos);- pos = endpos + 1;+ } else if (endpos_2 != std::string::npos) {+ sub_str = one_info.substr(pos, endpos_2 - pos);+ core_1 = std::stoi(sub_str);+ sub_str = one_info.substr(endpos_2 + 1);+ core_2 = std::stoi(sub_str);+ nodes_table.push_back({core_1, core_2, node_index});}- } else {- while (endpos != std::string::npos) {- if ((endpos = one_info.find('-', pos)) != std::string::npos) {- sub_str = one_info.substr(pos, endpos - pos);- core_1 = std::stoi(sub_str);- sub_str = one_info.substr(endpos + 1);- core_2 = std::stoi(sub_str);- nodes_table.push_back({core_1, core_2, node_index});- pos = one_info.find(',', endpos);- if (pos == std::string::npos) {- break;- } else {- pos = pos + 1;- }- }+ if (endpos_1 == std::string::npos) {+ break;+ } else {+ pos = endpos_1 + 1;}}node_index++;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.cppindex 9a200e20c0f..da0b72d8834 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@@ -1705,6 +1705,32 @@ LinuxCpuMapTestCase cache_mock_1 = {{},};+LinuxCpuMapTestCase cache_mock_2 = {+ 5,+ 1,+ 1,+ 5,+ {{5, 5, 0, 0, 0, 0, 0}},+ {+ {0, 0, 0, 0, MAIN_CORE_PROC, 0, -1},+ {2, 0, 0, 1, MAIN_CORE_PROC, 1, -1},+ {3, 0, 0, 2, MAIN_CORE_PROC, 2, -1},+ {4, 0, 0, 3, MAIN_CORE_PROC, 3, -1},+ {7, 0, 0, 4, MAIN_CORE_PROC, 4, -1},+ },+ {+ {"0", "0", "0,2-4,7"},+ {"", "", ""},+ {"2", "2", "0,2-4,7"},+ {"3", "3", "0,2-4,7"},+ {"4", "4", "0,2-4,7"},+ {"", "", ""},+ {"", "", ""},+ {"7", "7", "0,2-4,7"},+ },+ {{"0,2-4,7"}},+};+TEST_P(LinuxCpuMapCacheParserTests, LinuxCache) {}INSTANTIATE_TEST_SUITE_P(CPUMap,@@ -1737,7 +1763,8 @@ INSTANTIATE_TEST_SUITE_P(CPUMap,cache_1sockets_4cores_2,cache_VM_cache_0,cache_mock_0,- cache_mock_1));+ cache_mock_1,+ cache_mock_2));TEST_P(LinuxGetCpuMapFromCoresTests, LinuxCore) {}