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
Support machines with more than 1024 cores (#26303)
Sun Xiaoxia2659786992f5
diff --git a/src/inference/src/dev/threading/thread_affinity.cpp b/src/inference/src/dev/threading/thread_affinity.cppindex f53941f270a..791e5a7fc70 100644--- a/src/inference/src/dev/threading/thread_affinity.cpp+++ b/src/inference/src/dev/threading/thread_affinity.cpp@@ -87,8 +87,9 @@ bool pin_thread_to_vacant_core(int thrIdx,}bool pin_current_thread_to_socket(int socket) {- const int sockets = ov::get_available_numa_nodes().size();- const int cores = ov::get_number_of_cpu_cores();+ auto proc_type_table = get_org_proc_type_table();+ const int sockets = proc_type_table.size() > 1 ? proc_type_table.size() - 1 : 1;+ const int cores = proc_type_table[0][MAIN_CORE_PROC];const int cores_per_socket = cores / sockets;int ncpus = 0;diff --git a/src/inference/src/os/lin/lin_system_conf.cpp b/src/inference/src/os/lin/lin_system_conf.cppindex 2dcf9eaa4d6..e30bcbbe8bc 100644--- a/src/inference/src/os/lin/lin_system_conf.cpp+++ b/src/inference/src/os/lin/lin_system_conf.cpp@@ -12,6 +12,7 @@#include <vector>#include "dev/threading/parallel_custom_arena.hpp"+#include "dev/threading/thread_affinity.hpp"#include "openvino/core/except.hpp"#include "openvino/runtime/system_conf.hpp"#include "os/cpu_map_info.hpp"@@ -114,10 +115,11 @@ CPU::CPU() {};auto check_valid_cpu = [&]() {- cpu_set_t mask;- CPU_ZERO(&mask);+ ov::threading::CpuSet mask;+ int ncpus = 0;+ std::tie(mask, ncpus) = ov::threading::get_process_mask();- if ((_processors == 0) || (sched_getaffinity(0, sizeof(cpu_set_t), &mask) == -1)) {+ if ((_processors == 0) || mask == nullptr) {return -1;}@@ -128,7 +130,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(i, 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]);diff --git a/src/inference/src/system_conf.cpp b/src/inference/src/system_conf.cppindex 6ebec87fecc..9de1eeb78e1 100644--- a/src/inference/src/system_conf.cpp+++ b/src/inference/src/system_conf.cpp@@ -327,26 +327,10 @@ int get_org_numa_id(int numa_node_id) {# ifndef _WIN32int get_number_of_cpu_cores(bool bigCoresOnly) {CPU& cpu = cpu_info();- unsigned numberOfProcessors = cpu._processors;unsigned totalNumberOfCpuCores = cpu._cores;OPENVINO_ASSERT(totalNumberOfCpuCores != 0, "Total number of cpu cores can not be 0.");- cpu_set_t usedCoreSet, currentCoreSet, currentCpuSet;- CPU_ZERO(¤tCpuSet);- CPU_ZERO(&usedCoreSet);- CPU_ZERO(¤tCoreSet);-- sched_getaffinity(0, sizeof(currentCpuSet), ¤tCpuSet);-- for (unsigned processorId = 0u; processorId < numberOfProcessors; processorId++) {- if (CPU_ISSET(processorId, ¤tCpuSet)) {- unsigned coreId = processorId % totalNumberOfCpuCores;- if (!CPU_ISSET(coreId, &usedCoreSet)) {- CPU_SET(coreId, &usedCoreSet);- CPU_SET(processorId, ¤tCoreSet);- }- }- }- int phys_cores = CPU_COUNT(¤tCoreSet);++ int phys_cores = totalNumberOfCpuCores;# if (OV_THREAD == OV_THREAD_TBB || OV_THREAD == OV_THREAD_TBB_AUTO)auto core_types = custom::info::core_types();if (bigCoresOnly && core_types.size() > 1) /*Hybrid CPU*/ {