Skip to content

Commit

Permalink
fix for review
Browse files Browse the repository at this point in the history
  • Loading branch information
allnes committed Mar 11, 2024
1 parent d735623 commit ab7e990
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
24 changes: 11 additions & 13 deletions src/plugins/intel_cpu/src/compiled_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,6 @@ using namespace ov::threading;
namespace ov {
namespace intel_cpu {

static void initScheduler() {
#if defined(OV_CPU_WITH_ACL)
static std::mutex _mtx;
std::lock_guard<std::mutex> _lock{_mtx};
static std::once_flag flag_once;
std::shared_ptr<arm_compute::IScheduler> acl_scheduler = std::make_unique<ACLScheduler>();
std::call_once(flag_once, [&]() {
arm_compute::Scheduler::set(std::static_pointer_cast<arm_compute::IScheduler>(acl_scheduler));
});
#endif
}

struct ImmediateSerialExecutor : public ov::threading::ITaskExecutor {
void run(ov::threading::Task task) override {
std::lock_guard<std::mutex> l{_mutex};
Expand Down Expand Up @@ -89,6 +77,16 @@ 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 @@ -97,7 +95,7 @@ CompiledModel::CompiledModel(const std::shared_ptr<ov::Model>& model,
};
do {
for (auto&& task : tasks) {
task = [this] {
task = [this, &initScheduler] {
initScheduler();
CompiledModel::get_graph();
};
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/intel_cpu/src/nodes/executors/acl/acl_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ inline arm_compute::DataLayout getAclDataLayoutByMemoryDesc(MemoryDescCPtr desc)

/**
* @brief Return static mutex for lock ComputeLibrary configuration
* @return static std::mutex
* @return static arm_compute::Mutex
*/
static arm_compute::Mutex & getConfigurationMutex() {
static arm_compute::Mutex mtx_config;
Expand All @@ -125,7 +125,7 @@ static arm_compute::Mutex & getConfigurationMutex() {
* 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(std::function<void(void)> config) {
inline void configureThreadSafe(const std::function<void(void)>& config) {
// Issue: CVS-123514
std::lock_guard<arm_compute::Mutex> _lock {getConfigurationMutex()};
config();
Expand Down

0 comments on commit ab7e990

Please sign in to comment.