forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ARM CPU] Update TBB ACL Scheduler (openvinotoolkit#18885)
- Loading branch information
Showing
5 changed files
with
170 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
src/plugins/intel_cpu/src/nodes/executors/acl/acl_ie_scheduler.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// 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_custom(ICPPKernel *kernel, const Hints &hints, const Window &window, ITensorPack &tensors) { | ||
const Window & max_window = window; | ||
const unsigned int num_iterations = max_window.num_iterations_total(); | ||
const auto _num_threads = std::min(num_iterations, static_cast<unsigned int>(parallel_get_num_threads())); | ||
|
||
if (num_iterations == 0) { | ||
return; | ||
} | ||
|
||
std::function<void(const Window &window, const ThreadInfo &info)> main_run; | ||
if (tensors.empty()) { | ||
main_run = [&](const Window &window, const ThreadInfo &info) { | ||
kernel->run(window, info); | ||
}; | ||
} else { | ||
main_run = [&](const Window &window, const ThreadInfo &info) { | ||
kernel->run_op(tensors, window, info); | ||
}; | ||
} | ||
|
||
if (!kernel->is_parallelisable() || _num_threads == 1) { | ||
ThreadInfo info; | ||
info.cpu_info = &cpu_info(); | ||
main_run(max_window, info); | ||
} else { | ||
const auto num_windows = _num_threads; | ||
const auto hints_split_dimension = hints.split_dimension(); | ||
|
||
InferenceEngine::parallel_for(num_windows, [&](int wid) { | ||
Window win = max_window.split_window(hints_split_dimension, wid, num_windows); | ||
win.validate(); | ||
main_run(win, {wid, static_cast<int>(_num_threads), &cpu_info()}); | ||
}); | ||
} | ||
} | ||
|
||
void ACLScheduler::schedule(ICPPKernel *kernel, const Hints &hints) { | ||
ITensorPack tensors; | ||
schedule_custom(kernel, hints, kernel->window(), tensors); | ||
} | ||
|
||
void ACLScheduler::schedule_op(ICPPKernel *kernel, const Hints &hints, const Window &window, ITensorPack &tensors) { | ||
schedule_custom(kernel, hints, window, tensors); | ||
} | ||
|
||
void ACLScheduler::run_workloads(std::vector<arm_compute::IScheduler::Workload> &workloads) { | ||
InferenceEngine::parallel_for(workloads.size(), [&](int wid) { | ||
workloads[wid]({wid, static_cast<int>(parallel_get_num_threads()), &cpu_info()}); | ||
}); | ||
} | ||
|
||
} // namespace intel_cpu | ||
} // namespace ov |
31 changes: 31 additions & 0 deletions
31
src/plugins/intel_cpu/src/nodes/executors/acl/acl_ie_scheduler.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// 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> | ||
#include "support/Mutex.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; | ||
private: | ||
void schedule_custom(ICPPKernel *kernel, const Hints &hints, const Window &window, ITensorPack &tensors); | ||
}; | ||
} // namespace intel_cpu | ||
} // namespace ov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters