diff --git a/src/plugins/intel_cpu/src/compiled_model.cpp b/src/plugins/intel_cpu/src/compiled_model.cpp index 2223c042c2e238..19fb00f2f10187 100644 --- a/src/plugins/intel_cpu/src/compiled_model.cpp +++ b/src/plugins/intel_cpu/src/compiled_model.cpp @@ -77,16 +77,6 @@ CompiledModel::CompiledModel(const std::shared_ptr& model, std::vector tasks; tasks.resize(streams); m_graphs.resize(streams); - auto initScheduler = [&]() { -#if defined(OV_CPU_WITH_ACL) - static std::once_flag flag_once; - std::shared_ptr acl_scheduler = std::make_shared(); - std::call_once(flag_once, [&]() { - arm_compute::Scheduler::set(std::static_pointer_cast(acl_scheduler)); - }); -#endif - }; - if (m_cfg.streamExecutorConfig.get_streams() != 0) { auto all_graphs_ready = [&] { return std::all_of(m_graphs.begin(), m_graphs.end(), [&](Graph& graph) { @@ -95,8 +85,14 @@ CompiledModel::CompiledModel(const std::shared_ptr& model, }; do { for (auto&& task : tasks) { - task = [this, &initScheduler] { - initScheduler(); + task = [this] { +#if defined(OV_CPU_WITH_ACL) + std::shared_ptr acl_scheduler = std::make_shared(); + static std::once_flag flag_once; + std::call_once(flag_once, [&]() { + arm_compute::Scheduler::set(std::static_pointer_cast(acl_scheduler)); + }); +#endif CompiledModel::get_graph(); }; } diff --git a/src/plugins/intel_cpu/src/nodes/executors/acl/acl_utils.hpp b/src/plugins/intel_cpu/src/nodes/executors/acl/acl_utils.hpp index c8a3aeec198ff6..d36048d2bb9085 100644 --- a/src/plugins/intel_cpu/src/nodes/executors/acl/acl_utils.hpp +++ b/src/plugins/intel_cpu/src/nodes/executors/acl/acl_utils.hpp @@ -110,25 +110,18 @@ inline arm_compute::DataLayout getAclDataLayoutByMemoryDesc(MemoryDescCPtr desc) return arm_compute::DataLayout::UNKNOWN; } -/** -* @brief Return static mutex for lock ComputeLibrary configuration -* @return static arm_compute::Mutex -*/ -static arm_compute::Mutex & getConfigurationMutex() { - static arm_compute::Mutex mtx_config; - return mtx_config; -} - /** * @brief run thread-safe configure for ComputeLibrary configuration function. * Arm Compute Library 23.08 does not officially support thread-safe configure() calls. * For example, calling configure for Eltwise operations from multiple streams leads to a data race and seg fault. * @param config ComputeLibrary configuration function */ -inline void configureThreadSafe(const std::function& config) { +void configureThreadSafe(const std::function& config) { // Issue: CVS-123514 - std::lock_guard _lock {getConfigurationMutex()}; + static arm_compute::Mutex mtx_config; + mtx_config.lock(); config(); + mtx_config.unlock(); } } // namespace intel_cpu