Skip to content

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

Add tbb new interface set_core_types() call which support P cores and E cores binding on PTL (#31631)

Sun Xiaoxia58bf2f938f17
diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake
index 7390383afe5..6d18f4204f0 100644
--- a/cmake/dependencies.cmake
+++ b/cmake/dependencies.cmake
@@ -103,10 +103,10 @@ function(ov_download_tbb)
if(WIN32 AND X86_64)
# build oneTBB 2021.2.1 with Visual Studio 2019 (MSVC 14.21)
RESOLVE_DEPENDENCY(TBB
- ARCHIVE_WIN "oneapi-tbb-2021.2.5-win-pdb.zip"
+ ARCHIVE_WIN "oneapi-tbb-2021.2.6-win.zip"
TARGET_PATH "${TEMP}/${PLATFORM_SUBDIR}/tbb"
ENVIRONMENT "TBBROOT"
- SHA256 "8acb2bd35769aac20597bc0ce1f7608e993b48dee18ee1cc144a05406b6b2613"
+ SHA256 "3b0269ef46c9bcb06227bbe2929d3c091a2614aa9be050d38a787d03d5bdcddc"
USE_NEW_LOCATION TRUE)
elseif(ANDROID AND X86_64)
RESOLVE_DEPENDENCY(TBB
@@ -118,10 +118,10 @@ function(ov_download_tbb)
elseif(LINUX AND X86_64 AND OPENVINO_GNU_LIBC AND OV_LIBC_VERSION VERSION_GREATER_EQUAL 2.17)
# build oneTBB 2021.2.1 with gcc 4.8 (glibc 2.17)
RESOLVE_DEPENDENCY(TBB
- ARCHIVE_LIN "oneapi-tbb-2021.13.0-lin-release.tgz"
+ ARCHIVE_LIN "oneapi-tbb-2021.13.1-lin.tgz"
TARGET_PATH "${TEMP}/${PLATFORM_SUBDIR}/tbb"
ENVIRONMENT "TBBROOT"
- SHA256 "fd2e889323cd5458be750eefdc026ce6791c723fae60b146c2511a5caeaf01c5"
+ SHA256 "80a0ba2aa6a45f882944e2afa6dfb4f3691373b43c3424f6749200a564a68dc7"
USE_NEW_LOCATION TRUE)
elseif(YOCTO_AARCH64)
RESOLVE_DEPENDENCY(TBB
diff --git a/src/inference/src/dev/threading/cpu_streams_executor.cpp b/src/inference/src/dev/threading/cpu_streams_executor.cpp
index 0d32610094f..1fbab9ba5f2 100644
--- a/src/inference/src/dev/threading/cpu_streams_executor.cpp
+++ b/src/inference/src/dev/threading/cpu_streams_executor.cpp
@@ -109,22 +109,39 @@ struct CPUStreamsExecutor::Impl {
auto stream_processors = _impl->_config.get_stream_processor_ids();
_numaNodeId = numa_node_id;
_socketId = socket_id;
+# if (TBB_INTERFACE_VERSION < 12000)
+ const auto tbb_version = tbb::TBB_runtime_interface_version();
+# else
+ const auto tbb_version = TBB_runtime_interface_version();
+# endif
if (stream_type == STREAM_WITHOUT_PARAM) {
- _taskArena.reset(new custom::task_arena{custom::task_arena::constraints{}
- .set_max_concurrency(concurrency)
- .set_max_threads_per_core(max_threads_per_core)});
+ int version_major = tbb_version / 10;
+ int version_patch = tbb_version % 10;
+ bool support_core_types = false;
+ if ((version_major == TBB_VERSION_MAJOR_CORE_TYPES_WINDOWS &&
+ version_patch >= TBB_VERSION_PATCH_CORE_TYPES_WINDOWS) ||
+ (version_major == TBB_VERSION_MAJOR_CORE_TYPES_LINUX &&
+ version_patch >= TBB_VERSION_PATCH_CORE_TYPES_LINUX)) {
+ support_core_types = true;
+ }
+ const auto core_types = custom::info::core_types();
+ if (support_core_types && core_types.size() >= MIN_CORE_TYPES_FOR_PTL) {
+ _taskArena.reset(new custom::task_arena{
+ custom::task_arena::constraints{}
+ .set_max_concurrency(concurrency)
+ .set_max_threads_per_core(max_threads_per_core)
+ .set_core_types({core_types.end() - MIN_CORE_TYPES_FOR_PTL + 1, core_types.end()})});
+ } else {
+ _taskArena.reset(new custom::task_arena{custom::task_arena::constraints{}
+ .set_max_concurrency(concurrency)
+ .set_max_threads_per_core(max_threads_per_core)});
+ }
} else if (stream_type == STREAM_WITH_NUMA_ID) {
// Numa node id has used different mapping methods in TBBBind since oneTBB 2021.4.0
# if USE_TBBBIND_2_5
auto real_numa_node_id = _numaNodeId;
# else
auto real_numa_node_id = get_org_numa_id(_numaNodeId);
- int tbb_version;
-# if (TBB_INTERFACE_VERSION < 12000)
- tbb_version = tbb::TBB_runtime_interface_version();
-# else
- tbb_version = TBB_runtime_interface_version();
-# endif
if (tbb_version >= 12040) {
real_numa_node_id = _numaNodeId;
}
@@ -134,9 +151,14 @@ struct CPUStreamsExecutor::Impl {
.set_max_concurrency(concurrency)
.set_max_threads_per_core(max_threads_per_core)});
} else if (stream_type == STREAM_WITH_CORE_TYPE) {
- const auto real_core_type = (core_type == MAIN_CORE_PROC || core_type == HYPER_THREADING_PROC)
- ? custom::info::core_types().back()
- : custom::info::core_types().front();
+ const auto core_types = custom::info::core_types();
+ auto real_core_type = (core_type == MAIN_CORE_PROC || core_type == HYPER_THREADING_PROC)
+ ? core_types.back()
+ : core_types.front();
+ // core_types=[LPECore, Ecore, Pcore]
+ if (core_type == EFFICIENT_CORE_PROC && core_types.size() >= MIN_CORE_TYPES_FOR_PTL) {
+ real_core_type = *(core_types.end() - MIN_CORE_TYPES_FOR_PTL + 1);
+ }
_taskArena.reset(new custom::task_arena{custom::task_arena::constraints{}
.set_core_type(real_core_type)
.set_max_concurrency(concurrency)
diff --git a/src/inference/src/dev/threading/parallel_custom_arena.hpp b/src/inference/src/dev/threading/parallel_custom_arena.hpp
index a4c1b9fe998..6ac3864c0fc 100644
--- a/src/inference/src/dev/threading/parallel_custom_arena.hpp
+++ b/src/inference/src/dev/threading/parallel_custom_arena.hpp
@@ -11,6 +11,7 @@
#pragma once
#include "openvino/core/parallel.hpp"
+#include "openvino/runtime/common.hpp"
#if (OV_THREAD == OV_THREAD_TBB || OV_THREAD == OV_THREAD_TBB_AUTO)
@@ -28,6 +29,12 @@
// In this case, tbbbind static library is needed.
# define USE_TBBBIND_2_5 TBBBIND_2_5_AVAILABLE
+constexpr int MIN_CORE_TYPES_FOR_PTL = 3;
+constexpr int TBB_VERSION_MAJOR_CORE_TYPES_WINDOWS = 1202;
+constexpr int TBB_VERSION_PATCH_CORE_TYPES_WINDOWS = 6;
+constexpr int TBB_VERSION_MAJOR_CORE_TYPES_LINUX = 1213;
+constexpr int TBB_VERSION_PATCH_CORE_TYPES_LINUX = 1;
+
namespace custom {
using numa_node_id = int;
@@ -53,6 +60,23 @@ struct constraints {
core_type = id;
return *this;
}
+ constraints& set_core_types(const std::vector<core_type_id>& ids) {
+ if (ids.empty()) {
+ core_type = -1;
+ } else if (ids.size() == 1) {
+ core_type = ids[0];
+ } else {
+ // Set a marker bit to indicate multiple core type format
+ core_type = (1 << core_type_id_bits);
+
+ for (core_type_id id : ids) {
+ OPENVINO_ASSERT((0 <= id) && (id < static_cast<core_type_id>(core_type_id_bits)), "Wrong core type id");
+ core_type |= (1 << id);
+ }
+ }
+
+ return *this;
+ }
constraints& set_max_threads_per_core(int threads_number) {
max_threads_per_core = threads_number;
return *this;
@@ -61,6 +85,8 @@ struct constraints {
numa_node_id numa_id = tbb::task_arena::automatic;
int max_concurrency = tbb::task_arena::automatic;
core_type_id core_type = tbb::task_arena::automatic;
+ // Upper 4 bits reserved for format marker (single vs multiple core types)
+ static constexpr size_t core_type_id_bits = sizeof(core_type_id) * CHAR_BIT - 4;
int max_threads_per_core = tbb::task_arena::automatic;
};