Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

Fix performance regression on EMR (#28871)

Sun Xiaoxiaa5868390e01c
diff --git a/src/inference/dev_api/openvino/runtime/system_conf.hpp b/src/inference/dev_api/openvino/runtime/system_conf.hpp
index 617e4eeff11..b6d2e0ad063 100644
--- a/src/inference/dev_api/openvino/runtime/system_conf.hpp
+++ b/src/inference/dev_api/openvino/runtime/system_conf.hpp
@@ -295,14 +295,6 @@ OPENVINO_RUNTIME_API void reserve_available_cpus(const std::vector<std::vector<i
*/
OPENVINO_RUNTIME_API void set_cpu_used(const std::vector<int>& cpu_ids, const int used);
-/**
- * @brief Get socket id by current numa node id
- * @ingroup ov_dev_api_system_conf
- * @param[in] numa_node_id numa node id
- * @return socket id
- */
-OPENVINO_RUNTIME_API int get_socket_by_numa_node(int numa_node_id);
-
/**
* @brief Get original socket id by current socket id, the input socket id is recalculated after filtering (like
* numactl), while the original socket id is the original id before filtering
diff --git a/src/inference/dev_api/openvino/runtime/threading/cpu_streams_executor_internal.hpp b/src/inference/dev_api/openvino/runtime/threading/cpu_streams_executor_internal.hpp
index a233b230f7e..5469e6c0288 100644
--- a/src/inference/dev_api/openvino/runtime/threading/cpu_streams_executor_internal.hpp
+++ b/src/inference/dev_api/openvino/runtime/threading/cpu_streams_executor_internal.hpp
@@ -42,6 +42,7 @@ void get_cur_stream_info(const int stream_id,
int& concurrency,
int& core_type,
int& numa_node_id,
+ int& socket_id,
int& max_threads_per_core);
/**
diff --git a/src/inference/src/dev/threading/cpu_streams_executor.cpp b/src/inference/src/dev/threading/cpu_streams_executor.cpp
index f307943925a..43afdeb6e22 100644
--- a/src/inference/src/dev/threading/cpu_streams_executor.cpp
+++ b/src/inference/src/dev/threading/cpu_streams_executor.cpp
@@ -104,10 +104,11 @@ struct CPUStreamsExecutor::Impl {
const int concurrency,
const int core_type,
const int numa_node_id,
+ const int socket_id,
const int max_threads_per_core) {
auto stream_processors = _impl->_config.get_stream_processor_ids();
- _numaNodeId = std::max(0, numa_node_id);
- _socketId = get_socket_by_numa_node(_numaNodeId);
+ _numaNodeId = numa_node_id;
+ _socketId = socket_id;
if (stream_type == STREAM_WITHOUT_PARAM) {
_taskArena.reset(new custom::task_arena{custom::task_arena::constraints{}
.set_max_concurrency(concurrency)
@@ -159,6 +160,7 @@ struct CPUStreamsExecutor::Impl {
int concurrency;
int cpu_core_type;
int numa_node_id;
+ int socket_id;
int max_threads_per_core;
StreamCreateType stream_type;
const auto org_proc_type_table = get_org_proc_type_table();
@@ -173,6 +175,7 @@ struct CPUStreamsExecutor::Impl {
concurrency,
cpu_core_type,
numa_node_id,
+ socket_id,
max_threads_per_core);
if (concurrency <= 0) {
return;
@@ -182,6 +185,7 @@ struct CPUStreamsExecutor::Impl {
concurrency,
cpu_core_type,
numa_node_id,
+ socket_id,
max_threads_per_core);
}
#endif
diff --git a/src/inference/src/dev/threading/cpu_streams_executor_internal.cpp b/src/inference/src/dev/threading/cpu_streams_executor_internal.cpp
index 8e5842f6132..3bd06f1f16a 100644
--- a/src/inference/src/dev/threading/cpu_streams_executor_internal.cpp
+++ b/src/inference/src/dev/threading/cpu_streams_executor_internal.cpp
@@ -21,6 +21,7 @@ void get_cur_stream_info(const int stream_id,
int& concurrency,
int& core_type,
int& numa_node_id,
+ int& socket_id,
int& max_threads_per_core) {
int stream_total = 0;
size_t stream_info_id = 0;
@@ -36,6 +37,7 @@ void get_cur_stream_info(const int stream_id,
concurrency = streams_info_table[stream_info_id][THREADS_PER_STREAM];
core_type = streams_info_table[stream_info_id][PROC_TYPE];
numa_node_id = streams_info_table[stream_info_id][STREAM_NUMA_NODE_ID];
+ socket_id = streams_info_table[stream_info_id][STREAM_SOCKET_ID];
max_threads_per_core = 1;
if (core_type == ALL_PROC) {
for (size_t i = stream_info_id + 1; i < streams_info_table.size(); i++) {
diff --git a/src/inference/src/system_conf.cpp b/src/inference/src/system_conf.cpp
index b25c16da649..18c0d1d8240 100644
--- a/src/inference/src/system_conf.cpp
+++ b/src/inference/src/system_conf.cpp
@@ -285,10 +285,6 @@ void reserve_available_cpus(const std::vector<std::vector<int>> streams_info_tab
const int cpu_status) {}
void set_cpu_used(const std::vector<int>& cpu_ids, const int used) {}
-int get_socket_by_numa_node(int numa_node_id) {
- return -1;
-};
-
int get_org_socket_id(int socket_id) {
return -1;
}
@@ -352,16 +348,6 @@ void reserve_available_cpus(const std::vector<std::vector<int>> streams_info_tab
const int cpu_status) {}
void set_cpu_used(const std::vector<int>& cpu_ids, const int used) {}
-int get_socket_by_numa_node(int numa_node_id) {
- CPU& cpu = cpu_info();
- for (size_t i = 0; i < cpu._proc_type_table.size(); i++) {
- if (cpu._proc_type_table[i][PROC_NUMA_NODE_ID] == numa_node_id) {
- return cpu._proc_type_table[i][PROC_SOCKET_ID];
- }
- }
- return -1;
-};
-
int get_org_socket_id(int socket_id) {
CPU& cpu = cpu_info();
auto iter = cpu._socketid_mapping_table.find(socket_id);
@@ -522,16 +508,6 @@ void set_cpu_used(const std::vector<int>& cpu_ids, const int used) {
}
}
-int get_socket_by_numa_node(int numa_node_id) {
- CPU& cpu = cpu_info();
- for (int i = 0; i < cpu._processors; i++) {
- if (cpu._cpu_mapping_table[i][CPU_MAP_NUMA_NODE_ID] == numa_node_id) {
- return cpu._cpu_mapping_table[i][CPU_MAP_SOCKET_ID];
- }
- }
- return -1;
-}
-
int get_number_of_logical_cpu_cores(bool bigCoresOnly) {
int logical_cores = parallel_get_max_threads();
# if (OV_THREAD == OV_THREAD_TBB || OV_THREAD == OV_THREAD_TBB_AUTO)
diff --git a/src/inference/tests/unit/cpu_stream_info_test.cpp b/src/inference/tests/unit/cpu_stream_info_test.cpp
index ea5b4636e46..7b6fe01fc52 100644
--- a/src/inference/tests/unit/cpu_stream_info_test.cpp
+++ b/src/inference/tests/unit/cpu_stream_info_test.cpp
@@ -63,6 +63,7 @@ public:
int test_concurrency;
int test_core_type;
int test_numa_node_id;
+ int test_socket_id = 0;
int test_max_threads_per_core;
get_cur_stream_info(i,
test_data._cpu_pinning,
@@ -72,6 +73,7 @@ public:
test_concurrency,
test_core_type,
test_numa_node_id,
+ test_socket_id,
test_max_threads_per_core);
test_stream_types.push_back(test_stream_type);
test_concurrencys.push_back(test_concurrency);
diff --git a/src/plugins/intel_cpu/src/compiled_model.cpp b/src/plugins/intel_cpu/src/compiled_model.cpp
index ddfb26d8d42..0f326426271 100644
--- a/src/plugins/intel_cpu/src/compiled_model.cpp
+++ b/src/plugins/intel_cpu/src/compiled_model.cpp
@@ -153,7 +153,7 @@ CompiledModel::GraphGuard::Lock CompiledModel::get_graph() const {
auto streamsExecutor = std::dynamic_pointer_cast<IStreamsExecutor>(m_task_executor);
if (nullptr != streamsExecutor) {
streamId = streamsExecutor->get_stream_id();
- socketId = streamsExecutor->get_socket_id();
+ socketId = std::max(0, streamsExecutor->get_socket_id());
}
auto graphLock = GraphGuard::Lock(m_graphs[streamId % m_graphs.size()]);
if (!graphLock._graph.IsReady()) {
diff --git a/src/plugins/intel_cpu/src/graph_context.cpp b/src/plugins/intel_cpu/src/graph_context.cpp
index d2a292c1b49..85512f9860a 100644
--- a/src/plugins/intel_cpu/src/graph_context.cpp
+++ b/src/plugins/intel_cpu/src/graph_context.cpp
@@ -29,7 +29,7 @@ GraphContext::GraphContext(Config config,
m_memoryControl(m_auxiliaryNetworkMemoryControl->createMemoryControlUnit()) {
if (m_streamExecutor) {
m_cpuStreamExecutor = std::dynamic_pointer_cast<ov::threading::CPUStreamsExecutor>(m_streamExecutor);
- m_numaNodeId = m_cpuStreamExecutor ? m_cpuStreamExecutor->get_numa_node_id() : 0;
+ m_numaNodeId = m_cpuStreamExecutor ? std::max(0, m_cpuStreamExecutor->get_numa_node_id()) : 0;
auto nNumaNodes = get_num_numa_nodes();
if (m_numNumaNodes < nNumaNodes) {
m_numNumaNodes = nNumaNodes;