diff --git a/src/inference/src/os/cpu_map_info.hpp b/src/inference/src/os/cpu_map_info.hpp index b1360bc571f..9121b706f7d 100644 --- a/src/inference/src/os/cpu_map_info.hpp +++ b/src/inference/src/os/cpu_map_info.hpp @@ -157,14 +157,13 @@ 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>& system_info_table, - int& _processors, - int& _numa_nodes, - int& _sockets, - int& _cores, - std::vector>& _proc_type_table); +void parse_processor_info_macos(const std::vector>& system_info_table, + int& _processors, + int& _numa_nodes, + int& _sockets, + int& _cores, + std::vector>& _proc_type_table); #endif } // namespace ov diff --git a/src/inference/src/os/mac/mac_system_conf.cpp b/src/inference/src/os/mac/mac_system_conf.cpp index 04b9a77c7d6..092cd0f33cd 100644 --- a/src/inference/src/os/mac/mac_system_conf.cpp +++ b/src/inference/src/os/mac/mac_system_conf.cpp @@ -7,6 +7,7 @@ #include #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,17 +29,16 @@ CPU::CPU() { } } - if (!parse_processor_info_macos(system_info_table, _processors, _numa_nodes, _sockets, _cores, _proc_type_table)) { - _org_proc_type_table = _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>& system_info_table, - int& _processors, - int& _numa_nodes, - int& _sockets, - int& _cores, - std::vector>& _proc_type_table) { +void parse_processor_info_macos(const std::vector>& system_info_table, + int& _processors, + int& _numa_nodes, + int& _sockets, + int& _cores, + std::vector>& _proc_type_table) { _processors = 0; _numa_nodes = 0; _sockets = 0; @@ -51,7 +51,7 @@ int parse_processor_info_macos(const std::vector(it->second); } @@ -63,63 +63,50 @@ int parse_processor_info_macos(const std::vector(it->second); } + _proc_type_table.resize(1, std::vector(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& item) { return item.first == "hw.optional.arm64"; }); - if (it == system_info_table.end()) { - _proc_type_table.resize(1, std::vector(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& 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(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(), - [&](const std::pair& item) { - return item.first == "hw.perflevel1.physicalcpu"; - }); + it = std::find_if(system_info_table.begin(), + system_info_table.end(), + [&](const std::pair& item) { + return item.first == "hw.perflevel1.physicalcpu"; + }); - if (it == system_info_table.end()) { - return 0; + if (it != system_info_table.end()) { + _proc_type_table[0][EFFICIENT_CORE_PROC] = it->second; + } } else { - _proc_type_table[0][EFFICIENT_CORE_PROC] = it->second; + _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 diff --git a/src/inference/tests/unit/cpu_map_parser/parser_macos.cpp b/src/inference/tests/unit/cpu_map_parser/parser_macos.cpp index 59fe8aef0ac..9b550ee9a04 100644 --- a/src/inference/tests/unit/cpu_map_parser/parser_macos.cpp +++ b/src/inference/tests/unit/cpu_map_parser/parser_macos.cpp @@ -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