Skip to content

Commit

Permalink
add additional checks for bad cache information in VM (openvinotoolki…
Browse files Browse the repository at this point in the history
…t#21059)

* add additional checks for bad cache information in VM

* update implementation
  • Loading branch information
wangleis authored Nov 26, 2023
1 parent 91660b1 commit 72cb4e4
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
20 changes: 20 additions & 0 deletions src/inference/src/os/lin/lin_system_conf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,16 @@ void parse_cache_info_linux(const std::vector<std::vector<std::string>> system_i
_processors = system_info_table.size();
_cpu_mapping_table.resize(_processors, std::vector<int>(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;
Expand All @@ -367,6 +377,10 @@ void parse_cache_info_linux(const std::vector<std::vector<std::string>> 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;
Expand Down Expand Up @@ -460,13 +474,19 @@ void parse_cache_info_linux(const std::vector<std::vector<std::string>> 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);
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] = _cpu_mapping_table[core_1][CPU_MAP_SOCKET_ID];
update_proc_map_info(core_1);
if (_processors == 0) {
return;
};
endpos = pos;
}

Expand Down
25 changes: 24 additions & 1 deletion src/inference/tests/unit/cpu_map_parser/cache_parser_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}

Expand All @@ -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) {}

Expand Down

0 comments on commit 72cb4e4

Please sign in to comment.