diff --git a/src/inference/src/os/lin/lin_system_conf.cpp b/src/inference/src/os/lin/lin_system_conf.cpp index 6d8bb4afad2..2cfb12a7826 100644 --- a/src/inference/src/os/lin/lin_system_conf.cpp +++ b/src/inference/src/os/lin/lin_system_conf.cpp @@ -353,6 +353,16 @@ void parse_cache_info_linux(const std::vector> system_i _processors = system_info_table.size(); _cpu_mapping_table.resize(_processors, std::vector(CPU_MAP_TABLE_SIZE, -1)); + auto clean_up_output = [&]() { + _processors = 0; + _cores = 0; + _numa_nodes = 0; + _sockets = 0; + _cpu_mapping_table.clear(); + _proc_type_table.clear(); + return; + }; + auto update_proc_map_info = [&](const int nproc) { if (-1 == _cpu_mapping_table[nproc][CPU_MAP_CORE_ID]) { int core_1 = 0; @@ -367,6 +377,10 @@ void parse_cache_info_linux(const std::vector> system_i core_1 = std::stoi(sub_str); sub_str = system_info_table[nproc][0].substr(endpos + 1); core_2 = std::stoi(sub_str); + if ((core_1 != nproc) && (core_2 != nproc)) { + clean_up_output(); + return; + } _cpu_mapping_table[core_1][CPU_MAP_PROCESSOR_ID] = core_1; _cpu_mapping_table[core_2][CPU_MAP_PROCESSOR_ID] = core_2; @@ -460,6 +474,9 @@ void parse_cache_info_linux(const std::vector> system_i _cpu_mapping_table[m][CPU_MAP_SOCKET_ID] = _sockets; _cpu_mapping_table[m][CPU_MAP_NUMA_NODE_ID] = _cpu_mapping_table[m][CPU_MAP_SOCKET_ID]; update_proc_map_info(m); + if (_processors == 0) { + return; + }; } } else if (pos != std::string::npos) { sub_str = system_info_table[n][2].substr(pos); @@ -467,6 +484,9 @@ void parse_cache_info_linux(const std::vector> system_i _cpu_mapping_table[core_1][CPU_MAP_SOCKET_ID] = _sockets; _cpu_mapping_table[core_1][CPU_MAP_NUMA_NODE_ID] = _cpu_mapping_table[core_1][CPU_MAP_SOCKET_ID]; update_proc_map_info(core_1); + if (_processors == 0) { + return; + }; endpos = pos; } 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 7dab5dc907f..9e9be376e27 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 @@ -1172,6 +1172,28 @@ LinuxCpuMapTestCase cache_1sockets_6cores_hyperthreading = { }, {}, }; +LinuxCpuMapTestCase cache_VM_cache_0 = { + 0, + 0, + 0, + 0, + {}, + {}, + { + {{"0-31"}, {"0-31"}, {"0-31"}}, {{"0-31"}, {"0-31"}, {"0-31"}}, {{"0-31"}, {"0-31"}, {"0-31"}}, + {{"0-31"}, {"0-31"}, {"0-31"}}, {{"0-31"}, {"0-31"}, {"0-31"}}, {{"0-31"}, {"0-31"}, {"0-31"}}, + {{"0-31"}, {"0-31"}, {"0-31"}}, {{"0-31"}, {"0-31"}, {"0-31"}}, {{"0-31"}, {"0-31"}, {"0-31"}}, + {{"0-31"}, {"0-31"}, {"0-31"}}, {{"0-31"}, {"0-31"}, {"0-31"}}, {{"0-31"}, {"0-31"}, {"0-31"}}, + {{"0-31"}, {"0-31"}, {"0-31"}}, {{"0-31"}, {"0-31"}, {"0-31"}}, {{"0-31"}, {"0-31"}, {"0-31"}}, + {{"0-31"}, {"0-31"}, {"0-31"}}, {{"0-31"}, {"0-31"}, {"0-31"}}, {{"0-31"}, {"0-31"}, {"0-31"}}, + {{"0-31"}, {"0-31"}, {"0-31"}}, {{"0-31"}, {"0-31"}, {"0-31"}}, {{"0-31"}, {"0-31"}, {"0-31"}}, + {{"0-31"}, {"0-31"}, {"0-31"}}, {{"0-31"}, {"0-31"}, {"0-31"}}, {{"0-31"}, {"0-31"}, {"0-31"}}, + {{"0-31"}, {"0-31"}, {"0-31"}}, {{"0-31"}, {"0-31"}, {"0-31"}}, {{"0-31"}, {"0-31"}, {"0-31"}}, + {{"0-31"}, {"0-31"}, {"0-31"}}, {{"0-31"}, {"0-31"}, {"0-31"}}, {{"0-31"}, {"0-31"}, {"0-31"}}, + {{"0-31"}, {"0-31"}, {"0-31"}}, {{"0-31"}, {"0-31"}, {"0-31"}}, + }, + {}, +}; TEST_P(LinuxCpuMapCacheParserTests, LinuxCache) {} @@ -1192,7 +1214,8 @@ INSTANTIATE_TEST_SUITE_P(CPUMap, cache_1sockets_14cores_hyperthreading_1, cache_1sockets_10cores_hyperthreading, cache_1sockets_8cores_hyperthreading, - cache_1sockets_6cores_hyperthreading)); + cache_1sockets_6cores_hyperthreading, + cache_VM_cache_0)); TEST_P(LinuxGetCpuMapFromCoresTests, LinuxCore) {}