update parse_processor_info_macos for macOS ver 11 (#21517)
* update parse_processor_info_macos for wrong macos info * update default setting * update default setting * update for comment * fix typo * update test data * update init order
This commit is contained in:
parent
06a27e7b31
commit
04c9a52b7f
@ -157,9 +157,8 @@ void parse_processor_info_win(const char* base_ptr,
|
||||
* @param[out] _sockets total number for sockets in system
|
||||
* @param[out] _cores total number for physical CPU cores in system
|
||||
* @param[out] _proc_type_table summary table of number of processors per type
|
||||
* @return
|
||||
*/
|
||||
int parse_processor_info_macos(const std::vector<std::pair<std::string, uint64_t>>& system_info_table,
|
||||
void parse_processor_info_macos(const std::vector<std::pair<std::string, uint64_t>>& system_info_table,
|
||||
int& _processors,
|
||||
int& _numa_nodes,
|
||||
int& _sockets,
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "dev/threading/parallel_custom_arena.hpp"
|
||||
#include "openvino/core/except.hpp"
|
||||
#include "openvino/runtime/system_conf.hpp"
|
||||
#include "os/cpu_map_info.hpp"
|
||||
|
||||
@ -28,12 +29,11 @@ CPU::CPU() {
|
||||
}
|
||||
}
|
||||
|
||||
if (!parse_processor_info_macos(system_info_table, _processors, _numa_nodes, _sockets, _cores, _proc_type_table)) {
|
||||
parse_processor_info_macos(system_info_table, _processors, _numa_nodes, _sockets, _cores, _proc_type_table);
|
||||
_org_proc_type_table = _proc_type_table;
|
||||
}
|
||||
}
|
||||
|
||||
int parse_processor_info_macos(const std::vector<std::pair<std::string, uint64_t>>& system_info_table,
|
||||
void parse_processor_info_macos(const std::vector<std::pair<std::string, uint64_t>>& system_info_table,
|
||||
int& _processors,
|
||||
int& _numa_nodes,
|
||||
int& _sockets,
|
||||
@ -51,7 +51,7 @@ int parse_processor_info_macos(const std::vector<std::pair<std::string, uint64_t
|
||||
});
|
||||
|
||||
if (it == system_info_table.end()) {
|
||||
return -1;
|
||||
OPENVINO_THROW("Unable to get number of cpus from macOS!");
|
||||
} else {
|
||||
_processors = static_cast<int>(it->second);
|
||||
}
|
||||
@ -63,48 +63,35 @@ int parse_processor_info_macos(const std::vector<std::pair<std::string, uint64_t
|
||||
});
|
||||
|
||||
if (it == system_info_table.end()) {
|
||||
_processors = 0;
|
||||
return -1;
|
||||
_cores = _processors;
|
||||
} else {
|
||||
_cores = static_cast<int>(it->second);
|
||||
}
|
||||
|
||||
_proc_type_table.resize(1, std::vector<int>(PROC_TYPE_TABLE_SIZE, 0));
|
||||
|
||||
_numa_nodes = 1;
|
||||
_sockets = 1;
|
||||
|
||||
_proc_type_table[0][ALL_PROC] = _processors;
|
||||
_proc_type_table[0][MAIN_CORE_PROC] = _cores;
|
||||
_proc_type_table[0][HYPER_THREADING_PROC] = _processors - _cores;
|
||||
|
||||
it = std::find_if(system_info_table.begin(),
|
||||
system_info_table.end(),
|
||||
[&](const std::pair<std::string, uint64_t>& item) {
|
||||
return item.first == "hw.optional.arm64";
|
||||
});
|
||||
|
||||
if (it == system_info_table.end()) {
|
||||
_proc_type_table.resize(1, std::vector<int>(PROC_TYPE_TABLE_SIZE, 0));
|
||||
_proc_type_table[0][ALL_PROC] = _processors;
|
||||
_proc_type_table[0][MAIN_CORE_PROC] = _cores;
|
||||
_proc_type_table[0][HYPER_THREADING_PROC] = _processors - _cores;
|
||||
_proc_type_table[0][PROC_NUMA_NODE_ID] = 0;
|
||||
_proc_type_table[0][PROC_SOCKET_ID] = 0;
|
||||
} else {
|
||||
if (it != system_info_table.end()) {
|
||||
it = std::find_if(system_info_table.begin(),
|
||||
system_info_table.end(),
|
||||
[&](const std::pair<std::string, uint64_t>& item) {
|
||||
return item.first == "hw.perflevel0.physicalcpu";
|
||||
});
|
||||
|
||||
if (it == system_info_table.end()) {
|
||||
_processors = 0;
|
||||
_cores = 0;
|
||||
_numa_nodes = 0;
|
||||
_sockets = 0;
|
||||
return -1;
|
||||
} else {
|
||||
_proc_type_table.resize(1, std::vector<int>(PROC_TYPE_TABLE_SIZE, 0));
|
||||
_proc_type_table[0][ALL_PROC] = _processors;
|
||||
if (it != system_info_table.end()) {
|
||||
_proc_type_table[0][MAIN_CORE_PROC] = it->second;
|
||||
_proc_type_table[0][PROC_NUMA_NODE_ID] = 0;
|
||||
_proc_type_table[0][PROC_SOCKET_ID] = 0;
|
||||
}
|
||||
|
||||
it = std::find_if(system_info_table.begin(),
|
||||
system_info_table.end(),
|
||||
@ -112,14 +99,14 @@ int parse_processor_info_macos(const std::vector<std::pair<std::string, uint64_t
|
||||
return item.first == "hw.perflevel1.physicalcpu";
|
||||
});
|
||||
|
||||
if (it == system_info_table.end()) {
|
||||
return 0;
|
||||
} else {
|
||||
if (it != system_info_table.end()) {
|
||||
_proc_type_table[0][EFFICIENT_CORE_PROC] = it->second;
|
||||
}
|
||||
} else {
|
||||
_proc_type_table[0][EFFICIENT_CORE_PROC] = _cores / 2;
|
||||
_proc_type_table[0][MAIN_CORE_PROC] = _cores - _proc_type_table[0][EFFICIENT_CORE_PROC];
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace ov
|
||||
|
@ -52,7 +52,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
MacOSCpuMapTestCase test_case_arm = {
|
||||
MacOSCpuMapTestCase test_case_arm_1 = {
|
||||
8, // param[expected out]: total 8 logcial processors on this simulated platform
|
||||
1, // param[expected out]: total 1 numa nodes on this simulated platform
|
||||
1, // param[expected out]: total 1 sockets on this simulated platform
|
||||
@ -67,7 +67,32 @@ MacOSCpuMapTestCase test_case_arm = {
|
||||
}, // param[in]: The system information table of this simulated platform
|
||||
};
|
||||
|
||||
MacOSCpuMapTestCase test_case_x86 = {
|
||||
MacOSCpuMapTestCase test_case_arm_2 = {
|
||||
8,
|
||||
1,
|
||||
1,
|
||||
8,
|
||||
{{8, 4, 4, 0, 0, 0}},
|
||||
{
|
||||
{"hw.ncpu", 8},
|
||||
{"hw.physicalcpu", 8},
|
||||
{"hw.optional.arm64", 1},
|
||||
},
|
||||
};
|
||||
|
||||
MacOSCpuMapTestCase test_case_arm_3 = {
|
||||
8,
|
||||
1,
|
||||
1,
|
||||
8,
|
||||
{{8, 4, 4, 0, 0, 0}},
|
||||
{
|
||||
{"hw.ncpu", 8},
|
||||
{"hw.optional.arm64", 1},
|
||||
},
|
||||
};
|
||||
|
||||
MacOSCpuMapTestCase test_case_x86_1 = {
|
||||
12,
|
||||
1,
|
||||
1,
|
||||
@ -76,9 +101,21 @@ MacOSCpuMapTestCase test_case_x86 = {
|
||||
{{"hw.ncpu", 12}, {"hw.physicalcpu", 6}},
|
||||
};
|
||||
|
||||
MacOSCpuMapTestCase test_case_x86_2 = {
|
||||
12,
|
||||
1,
|
||||
1,
|
||||
12,
|
||||
{{12, 12, 0, 0, 0, 0}},
|
||||
{{"hw.ncpu", 12}},
|
||||
};
|
||||
|
||||
TEST_P(MacOSCpuMapParserTests, MacOS) {}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(CPUMap, MacOSCpuMapParserTests, testing::Values(test_case_arm, test_case_x86));
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
CPUMap,
|
||||
MacOSCpuMapParserTests,
|
||||
testing::Values(test_case_arm_1, test_case_arm_2, test_case_arm_3, test_case_x86_1, test_case_x86_2));
|
||||
|
||||
#endif
|
||||
} // namespace
|
||||
|
Loading…
Reference in New Issue
Block a user