Skip to content

Commit

Permalink
fix for review #2
Browse files Browse the repository at this point in the history
  • Loading branch information
allnes committed Mar 13, 2024
1 parent d8284d4 commit 3ddae2c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 23 deletions.
20 changes: 8 additions & 12 deletions src/plugins/intel_cpu/src/compiled_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,6 @@ CompiledModel::CompiledModel(const std::shared_ptr<ov::Model>& model,
std::vector<Task> 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<arm_compute::IScheduler> acl_scheduler = std::make_shared<ACLScheduler>();
std::call_once(flag_once, [&]() {
arm_compute::Scheduler::set(std::static_pointer_cast<arm_compute::IScheduler>(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) {
Expand All @@ -95,8 +85,14 @@ CompiledModel::CompiledModel(const std::shared_ptr<ov::Model>& model,
};
do {
for (auto&& task : tasks) {
task = [this, &initScheduler] {
initScheduler();
task = [this] {
#if defined(OV_CPU_WITH_ACL)
std::shared_ptr<arm_compute::IScheduler> acl_scheduler = std::make_shared<ACLScheduler>();
static std::once_flag flag_once;
std::call_once(flag_once, [&]() {
arm_compute::Scheduler::set(std::static_pointer_cast<arm_compute::IScheduler>(acl_scheduler));
});
#endif
CompiledModel::get_graph();
};
}
Expand Down
15 changes: 4 additions & 11 deletions src/plugins/intel_cpu/src/nodes/executors/acl/acl_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<void(void)>& config) {
void configureThreadSafe(const std::function<void(void)>& config) {
// Issue: CVS-123514
std::lock_guard<arm_compute::Mutex> _lock {getConfigurationMutex()};
static arm_compute::Mutex mtx_config;
mtx_config.lock();
config();
mtx_config.unlock();
}

} // namespace intel_cpu
Expand Down

0 comments on commit 3ddae2c

Please sign in to comment.