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 multiple streams in one core (#28245)
Sun Xiaoxia54f5cab715f0
diff --git a/src/inference/dev_api/openvino/runtime/threading/istreams_executor.hpp b/src/inference/dev_api/openvino/runtime/threading/istreams_executor.hppindex 42cd4430d1b..4ce7a76cbd7 100644--- a/src/inference/dev_api/openvino/runtime/threading/istreams_executor.hpp+++ b/src/inference/dev_api/openvino/runtime/threading/istreams_executor.hpp@@ -92,6 +92,7 @@ public:bool _cpu_reservation = false; //!< Whether to reserve current cores which will not be used by other plugin.//!< If it is true, cpu_pinning defaults to true.bool _cpu_pinning = false; //!< Whether to bind threads to cores.+ bool _cores_limit = true; //!< Whether to limit the number of streams and threads by the number of cpu coresstd::vector<std::vector<int>> _streams_info_table = {};std::vector<std::vector<int>> _stream_processor_ids;int _sub_streams = 0;@@ -133,6 +134,7 @@ public:ov::hint::SchedulingCoreType thread_preferred_core_type = ov::hint::SchedulingCoreType::ANY_CORE,bool cpu_reservation = false,bool cpu_pinning = false,+ bool cores_limit = true,std::vector<std::vector<int>> streams_info_table = {},std::vector<int> rank = {}): _name{std::move(name)},@@ -141,6 +143,7 @@ public:_thread_preferred_core_type(thread_preferred_core_type),_cpu_reservation{cpu_reservation},_cpu_pinning{cpu_pinning},+ _cores_limit{cores_limit},_streams_info_table{std::move(streams_info_table)},_rank{rank} {update_executor_config();diff --git a/src/inference/src/dev/threading/istreams_executor.cpp b/src/inference/src/dev/threading/istreams_executor.cppindex 52a71e11637..5563232ca87 100644--- a/src/inference/src/dev/threading/istreams_executor.cpp+++ b/src/inference/src/dev/threading/istreams_executor.cpp@@ -204,15 +204,19 @@ void IStreamsExecutor::Config::update_executor_config() {num_cores = total_num_little_cores;}- _streams = _streams > 0 ? std::min(_streams, num_cores) : _streams;+ _streams = _streams > 0 ? (_cores_limit == true ? std::min(_streams, num_cores) : _streams) : _streams;if (_streams == 0) {set_config_zero_stream();return;}- _threads_per_stream =- _threads_per_stream > 0 ? std::min(num_cores, _streams * _threads_per_stream) / _streams : 0;+ _threads_per_stream = (_threads_per_stream > 0 && _cores_limit)+ ? std::min(num_cores, _streams * _threads_per_stream) / _streams+ : 0;+ // _threads_per_stream = 0: not use tbb to create threadsif (_threads_per_stream == 0) {+ _cpu_reservation = false;+ _cpu_pinning = false;return;}diff --git a/src/inference/tests/unit/executor_config_test.cpp b/src/inference/tests/unit/executor_config_test.cppindex 5675f045e6e..5da183d5257 100644--- a/src/inference/tests/unit/executor_config_test.cpp+++ b/src/inference/tests/unit/executor_config_test.cpp@@ -23,6 +23,7 @@ struct ExecutorConfigTestCase {int _threads_per_stream;ov::hint::SchedulingCoreType _core_type;bool _cpu_pinning;+ bool _cores_limit;std::vector<std::vector<int>> _streams_info_table_in;std::vector<std::vector<int>> _streams_info_table;std::vector<std::vector<int>> _stream_processors;@@ -47,11 +48,16 @@ public:test_data._core_type,false,test_data._cpu_pinning,+ test_data._cores_limit,test_data._streams_info_table_in};ASSERT_EQ(test_data._cpu_pinning, config.get_cpu_pinning());ASSERT_EQ(test_data._streams_info_table, config.get_streams_info_table());ASSERT_EQ(test_data._stream_processors, config.get_stream_processor_ids());+ if (!test_data._cores_limit) {+ ASSERT_EQ(test_data._num_streams, config.get_streams());+ ASSERT_EQ(0, config.get_threads_per_stream());+ }}};@@ -80,6 +86,7 @@ ExecutorConfigTestCase _1sockets_streams_4_threads_1 = {1, // param[in]: the number of threads per streamov::hint::SchedulingCoreType::ANY_CORE, // param[in]: specified cpu core typefalse, // param[in]: specified cpu pinning+ true, // param[in]: specified cores limit{}, // param[in]: streams info table// param[out]: streams_info_table, {NUMBER_OF_STREAMS, PROC_TYPE, THREADS_PER_STREAM, STREAM_NUMA_NODE_ID,// STREAM_SOCKET_ID}@@ -112,6 +119,7 @@ ExecutorConfigTestCase _1sockets_streams_4_threads_0 = {0,ov::hint::SchedulingCoreType::ANY_CORE,false,+ true,{},{},{},@@ -139,6 +147,7 @@ ExecutorConfigTestCase _1sockets_streams_1_threads_12 = {12,ov::hint::SchedulingCoreType::ANY_CORE,false,+ true,{},{{1, ALL_PROC, 12, 0, 0},@@ -170,6 +179,7 @@ ExecutorConfigTestCase _1sockets_streams_1_threads_10 = {10,ov::hint::SchedulingCoreType::ANY_CORE,false,+ true,{},{{1, ALL_PROC, 10, 0, 0},@@ -201,6 +211,7 @@ ExecutorConfigTestCase _1sockets_streams_12_threads_1 = {1,ov::hint::SchedulingCoreType::ANY_CORE,false,+ true,{},{{6, MAIN_CORE_PROC, 1, 0, 0},@@ -231,6 +242,7 @@ ExecutorConfigTestCase _1sockets_streams_13_threads_1 = {1,ov::hint::SchedulingCoreType::ANY_CORE,false,+ true,{},{{6, MAIN_CORE_PROC, 1, 0, 0},@@ -261,6 +273,7 @@ ExecutorConfigTestCase _1sockets_streams_6_threads_1_core_e = {1,ov::hint::SchedulingCoreType::ECORE_ONLY,false,+ true,{},{{6, MAIN_CORE_PROC, 1, 0, 0},@@ -291,6 +304,7 @@ ExecutorConfigTestCase _1sockets_streams_5_threads_1_binding = {1,ov::hint::SchedulingCoreType::ANY_CORE,true,+ true,{},{{5, MAIN_CORE_PROC, 1, 0, 0},@@ -346,6 +360,7 @@ ExecutorConfigTestCase _2sockets_streams_36_threads_1 = {1,ov::hint::SchedulingCoreType::ANY_CORE,false,+ true,{},{{18, MAIN_CORE_PROC, 1, 0, 0},@@ -402,6 +417,7 @@ ExecutorConfigTestCase _2sockets_streams_4_threads_5 = {5,ov::hint::SchedulingCoreType::ANY_CORE,false,+ true,{},{{3, MAIN_CORE_PROC, 5, 0, 0},@@ -458,6 +474,7 @@ ExecutorConfigTestCase _2sockets_streams_1_threads_36 = {36,ov::hint::SchedulingCoreType::ANY_CORE,false,+ true,{},{{1, ALL_PROC, 36, -1, -1},@@ -515,6 +532,7 @@ ExecutorConfigTestCase _2sockets_streams_1_threads_30 = {30,ov::hint::SchedulingCoreType::ANY_CORE,false,+ true,{},{{1, ALL_PROC, 30, -1, -1},@@ -546,6 +564,7 @@ ExecutorConfigTestCase _pecore_streams_5_threads_2 = {2,ov::hint::SchedulingCoreType::ANY_CORE,false,+ true,{},{{4, MAIN_CORE_PROC, 2, 0, 0},@@ -576,6 +595,7 @@ ExecutorConfigTestCase _pecore_streams_5_threads_5 = {5,ov::hint::SchedulingCoreType::ANY_CORE,false,+ true,{},{{2, MAIN_CORE_PROC, 4, 0, 0},@@ -607,6 +627,7 @@ ExecutorConfigTestCase _pecore_streams_4_threads_5 = {5,ov::hint::SchedulingCoreType::ANY_CORE,false,+ true,{},{{1, MAIN_CORE_PROC, 5, 0, 0},@@ -638,6 +659,7 @@ ExecutorConfigTestCase _pecore_streams_4_threads_1 = {1,ov::hint::SchedulingCoreType::ANY_CORE,false,+ true,{},{{4, MAIN_CORE_PROC, 1, 0, 0},@@ -667,6 +689,7 @@ ExecutorConfigTestCase _pecore_streams_5_threads_10 = {10,ov::hint::SchedulingCoreType::ANY_CORE,false,+ true,{},{{2, MAIN_CORE_PROC, 4, 0, 0},@@ -698,6 +721,7 @@ ExecutorConfigTestCase _pecore_streams_26_threads_1 = {1,ov::hint::SchedulingCoreType::ANY_CORE,false,+ true,{},{{8, MAIN_CORE_PROC, 1, 0, 0},@@ -729,6 +753,7 @@ ExecutorConfigTestCase _pecore_streams_26_threads_1_p = {1,ov::hint::SchedulingCoreType::PCORE_ONLY,false,+ true,{},{{8, MAIN_CORE_PROC, 1, 0, 0},@@ -759,6 +784,7 @@ ExecutorConfigTestCase _pecore_streams_26_threads_1_e = {1,ov::hint::SchedulingCoreType::ECORE_ONLY,false,+ true,{},{{8, EFFICIENT_CORE_PROC, 1, 0, 0},@@ -788,6 +814,7 @@ ExecutorConfigTestCase _pecore_streams_1_threads_0 = {0,ov::hint::SchedulingCoreType::ANY_CORE,false,+ true,{},{},{},@@ -815,6 +842,7 @@ ExecutorConfigTestCase _pecore_streams_1_threads_1_p = {1,ov::hint::SchedulingCoreType::PCORE_ONLY,false,+ true,{},{{1, MAIN_CORE_PROC, 1, 0, 0},@@ -844,6 +872,7 @@ ExecutorConfigTestCase _pecore_streams_1_threads_1_e = {1,ov::hint::SchedulingCoreType::ECORE_ONLY,false,+ true,{},{{1, EFFICIENT_CORE_PROC, 1, 0, 0},@@ -873,6 +902,7 @@ ExecutorConfigTestCase _pecore_streams_1_threads_16_p = {16,ov::hint::SchedulingCoreType::PCORE_ONLY,false,+ true,{},{{1, ALL_PROC, 16, 0, 0},@@ -904,6 +934,7 @@ ExecutorConfigTestCase _pecore_streams_1_threads_18_p = {18,ov::hint::SchedulingCoreType::PCORE_ONLY,false,+ true,{},{{1, ALL_PROC, 16, 0, 0},@@ -935,6 +966,7 @@ ExecutorConfigTestCase _pecore_streams_1_threads_10_p = {10,ov::hint::SchedulingCoreType::PCORE_ONLY,false,+ true,{},{{1, ALL_PROC, 10, 0, 0},@@ -966,6 +998,7 @@ ExecutorConfigTestCase _pecore_streams_10_threads_1_e = {1,ov::hint::SchedulingCoreType::ECORE_ONLY,false,+ true,{},{{8, EFFICIENT_CORE_PROC, 1, 0, 0},@@ -995,6 +1028,7 @@ ExecutorConfigTestCase _pecore_streams_10_threads_1_binding = {2,ov::hint::SchedulingCoreType::ANY_CORE,true,+ true,{},{{4, MAIN_CORE_PROC, 2, 0, 0},@@ -1026,6 +1060,7 @@ ExecutorConfigTestCase _pecore_streams_info_table_1 = {8,ov::hint::SchedulingCoreType::PCORE_ONLY,false,+ true,{{2, MAIN_CORE_PROC, 2, 0, 0},{2, EFFICIENT_CORE_PROC, 2, 0, 0},@@ -1059,6 +1094,7 @@ ExecutorConfigTestCase _pecore_streams_info_table_2 = {8,ov::hint::SchedulingCoreType::PCORE_ONLY,false,+ true,{{5, MAIN_CORE_PROC, 2, 0, 0},{2, EFFICIENT_CORE_PROC, 2, 0, 0},@@ -1091,6 +1127,7 @@ ExecutorConfigTestCase _pecore_streams_info_table_3 = {8,ov::hint::SchedulingCoreType::PCORE_ONLY,true,+ true,{{2, MAIN_CORE_PROC, 2, 0, 0},{2, EFFICIENT_CORE_PROC, 2, 0, 0},@@ -1104,6 +1141,40 @@ ExecutorConfigTestCase _pecore_streams_info_table_3 = {{{0, 2}, {4, 6}, {16, 17}, {18, 19}, {1, 3}, {5, 7}},};+ExecutorConfigTestCase _streams_info_table_cores_limit_false_1 = {+ {+ {1, 1, 0, 0, 0, 0},+ },+ {+ {0, 0, 0, 0, MAIN_CORE_PROC, 0, -1},+ },+ 4,+ 0,+ ov::hint::SchedulingCoreType::PCORE_ONLY,+ false,+ false,+ {},+ {},+ {},+};++ExecutorConfigTestCase _streams_info_table_cores_limit_false_2 = {+ {+ {1, 1, 0, 0, 0, 0},+ },+ {+ {0, 0, 0, 0, MAIN_CORE_PROC, 0, -1},+ },+ 4,+ 1,+ ov::hint::SchedulingCoreType::PCORE_ONLY,+ false,+ false,+ {},+ {},+ {},+};+TEST_P(ExecutorConfigTest, ExecutorConfig) {}INSTANTIATE_TEST_SUITE_P(smoke_ExecutorConfig,@@ -1138,6 +1209,8 @@ INSTANTIATE_TEST_SUITE_P(smoke_ExecutorConfig,_pecore_streams_10_threads_1_binding,_pecore_streams_info_table_1,_pecore_streams_info_table_2,- _pecore_streams_info_table_3));+ _pecore_streams_info_table_3,+ _streams_info_table_cores_limit_false_1,+ _streams_info_table_cores_limit_false_2));#endif} // namespacediff --git a/src/plugins/intel_cpu/src/compiled_model.cpp b/src/plugins/intel_cpu/src/compiled_model.cppindex 4e4c550e632..7c1eb44ab37 100644--- a/src/plugins/intel_cpu/src/compiled_model.cpp+++ b/src/plugins/intel_cpu/src/compiled_model.cpp@@ -132,6 +132,7 @@ CompiledModel::CompiledModel(const std::shared_ptr<ov::Model>& model,ov::hint::SchedulingCoreType::ANY_CORE,false,true,+ true,std::move(sub_streams_table),sub_cfg.streamsRankTable[i]};m_sub_compiled_models.push_back(diff --git a/src/plugins/intel_cpu/src/cpu_streams_calculation.cpp b/src/plugins/intel_cpu/src/cpu_streams_calculation.cppindex c62de65c304..e30dfe42fcb 100644--- a/src/plugins/intel_cpu/src/cpu_streams_calculation.cpp+++ b/src/plugins/intel_cpu/src/cpu_streams_calculation.cpp@@ -718,6 +718,7 @@ std::vector<std::vector<int>> generate_stream_info(const int streams,ov::hint::SchedulingCoreType::ANY_CORE,false,cpu_pinning,+ true,std::move(streams_info_table)};return proc_type_table;diff --git a/src/plugins/intel_gpu/src/plugin/compiled_model.cpp b/src/plugins/intel_gpu/src/plugin/compiled_model.cppindex 4a1f864940f..21344a40393 100644--- a/src/plugins/intel_gpu/src/plugin/compiled_model.cpp+++ b/src/plugins/intel_gpu/src/plugin/compiled_model.cpp@@ -34,7 +34,13 @@ std::shared_ptr<ov::threading::ITaskExecutor> create_task_executor(const std::shtrue});} else {return std::make_shared<ov::threading::CPUStreamsExecutor>(- ov::threading::IStreamsExecutor::Config{"Intel GPU plugin executor", config.get_property(ov::num_streams)});+ ov::threading::IStreamsExecutor::Config{"Intel GPU plugin executor",+ config.get_property(ov::num_streams),+ 0,+ ov::hint::SchedulingCoreType::ANY_CORE,+ false,+ false,+ false});}}} // namespace