Skip to content

Commit

Permalink
[ARM CPU] ACL TBB scheduler (openvinotoolkit#17445)
Browse files Browse the repository at this point in the history
  • Loading branch information
allnes authored Jul 19, 2023
1 parent c867c23 commit 510f578
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 16 deletions.
6 changes: 0 additions & 6 deletions src/plugins/intel_cpu/src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,6 @@ void Config::readProperties(const std::map<std::string, std::string> &prop) {
streamExecutorConfig._streams_changed = true;
}

#if defined(OPENVINO_ARCH_ARM) || defined(OPENVINO_ARCH_ARM64)
// TODO: multi-stream execution has functional issues on ARM target
streamExecutorConfig._streams = 1;
streamExecutorConfig._streams_changed = true;
#endif

CPU_DEBUG_CAP_ENABLE(applyDebugCapsProperties());
updateProperties();
}
Expand Down
43 changes: 43 additions & 0 deletions src/plugins/intel_cpu/src/nodes/executors/acl/acl_ie_scheduler.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright (C) 2020-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#include "acl_ie_scheduler.hpp"

#include "arm_compute/core/CPP/ICPPKernel.h"
#include "arm_compute/core/Error.h"
#include "arm_compute/core/Helpers.h"
#include <ie_parallel.hpp>

namespace ov {
namespace intel_cpu {

using namespace arm_compute;

ACLScheduler::ACLScheduler() = default;

unsigned int ACLScheduler::num_threads() const { return parallel_get_num_threads(); }

void ACLScheduler::set_num_threads(unsigned int num_threads) {}

void ACLScheduler::schedule(ICPPKernel *kernel, const Hints &hints) {
ITensorPack tensors;
schedule_common(kernel, hints, kernel->window(), tensors);
}

void ACLScheduler::schedule_op(ICPPKernel *kernel, const Hints &hints, const Window &window, ITensorPack &tensors) {
schedule_common(kernel, hints, window, tensors);
}

void ACLScheduler::run_workloads(std::vector<arm_compute::IScheduler::Workload> &workloads) {
InferenceEngine::parallel_for(workloads.size(), [&] (int wid) {
ThreadInfo info;
info.cpu_info = &cpu_info();
info.num_threads = parallel_get_num_threads();
info.thread_id = wid;
workloads[wid](info);
});
}

} // namespace intel_cpu
} // namespace ov
28 changes: 28 additions & 0 deletions src/plugins/intel_cpu/src/nodes/executors/acl/acl_ie_scheduler.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (C) 2020-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#pragma once

#include <arm_compute/runtime/Scheduler.h>
#include <arm_compute/core/CPP/ICPPKernel.h>
#include <arm_compute/core/ITensorPack.h>

namespace ov {
namespace intel_cpu {

using namespace arm_compute;

class ACLScheduler final : public IScheduler {
public:
ACLScheduler();
~ACLScheduler() override = default;
std::uint32_t num_threads() const override;
void set_num_threads(unsigned int num_threads) override;
void schedule(ICPPKernel *kernel, const Hints &hints) override;
void schedule_op(ICPPKernel *kernel, const Hints &hints, const Window &window, ITensorPack &tensors) override;
protected:
void run_workloads(std::vector<Workload> &workloads) override;
};
} // namespace intel_cpu
} // namespace ov
9 changes: 9 additions & 0 deletions src/plugins/intel_cpu/src/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
#include <cpu/x64/cpu_isa_traits.hpp>
#include <itt.h>

#if defined(OV_CPU_WITH_ACL)
#include "nodes/executors/acl/acl_ie_scheduler.hpp"
#include "arm_compute/runtime/CPP/CPPScheduler.h"
#endif

using namespace InferenceEngine;

#define IE_CPU_PLUGIN_THROW(...) IE_THROW(__VA_ARGS__) << "CPU plugin: "
Expand Down Expand Up @@ -142,6 +147,10 @@ Engine::Engine() :
specialSetup(new CPUSpecialSetup) {
_pluginName = "CPU";
extensionManager->AddExtension(std::make_shared<Extension>());
#if defined(OV_CPU_WITH_ACL)
acl_scheduler = std::make_unique<ACLScheduler>();
arm_compute::Scheduler::set(acl_scheduler);
#endif
}

Engine::~Engine() {
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/intel_cpu/src/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ class Engine : public InferenceEngine::IInferencePlugin {
const std::string deviceFullName;

std::shared_ptr<void> specialSetup;

#if defined(OV_CPU_WITH_ACL)
std::shared_ptr<arm_compute::IScheduler> acl_scheduler;
#endif
};

} // namespace intel_cpu
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,6 @@ std::vector<std::string> disabledTestPatterns() {
retVector.emplace_back(R"(.*HeteroSyntheticTest.*)");
retVector.emplace_back(R"(.*IEClassBasicTestP.*)");
#elif defined(OPENVINO_ARCH_ARM64) || defined(OPENVINO_ARCH_ARM)
{
// TODO: enable once streams / tput mode is supported
retVector.emplace_back(R"(OVClassConfigTestCPU.smoke_CpuExecNetworkCheck(Model|Core)StreamsHasHigherPriorityThanLatencyHint.*)");
retVector.emplace_back(R"(smoke_BehaviorTests/CorrectConfigCheck.canSetConfigAndCheckGetConfig.*CPU_THROUGHPUT_STREAMS=8.*)");
retVector.emplace_back(R"(smoke_BehaviorTests/CorrectConfigCheck.canSetConfigTwiceAndCheckGetConfig.*CPU_THROUGHPUT_STREAMS=8.*)");
retVector.emplace_back(R"(smoke_CPU_OVClassLoadNetworkAndCheckWithSecondaryPropertiesTest/OVClassLoadNetworkAndCheckSecondaryPropertiesTest.LoadNetworkAndCheckSecondaryPropertiesTest.*)");
retVector.emplace_back(R"(smoke_CPU_OVClassLoadNetworkAndCheckWithSecondaryPropertiesDoubleTest/OVClassLoadNetworkAndCheckSecondaryPropertiesTest.LoadNetworkAndCheckSecondaryPropertiesTest.*)");
retVector.emplace_back(R"(smoke_CPU_OVClassCompileModelAndCheckSecondaryPropertiesTest.*)");
retVector.emplace_back(R"(smoke_CPU_OVClassCompileModelAndCheckWithSecondaryPropertiesDoubleTest.*)");
}
// invalid test: checks u8 precision for runtime graph, while it should be f32
retVector.emplace_back(R"(smoke_NegativeQuantizedMatMulMultiplyFusion.*)");
// int8 specific
Expand Down

0 comments on commit 510f578

Please sign in to comment.