24.02.1
|
Go to the documentation of this file.
36 : _num_threads(omp_get_max_threads())
47 const unsigned int num_cores = omp_get_max_threads();
54 schedule_common(kernel, hints, kernel->
window(), tensors);
61 "Dynamic scheduling is not supported in OMPScheduler");
63 const Window &max_window = window;
65 const unsigned int num_threads = std::min(num_iterations, _num_threads);
76 std::vector<IScheduler::Workload> workloads(num_windows);
77 for (
unsigned int t = 0;
t < num_windows;
t++)
80 workloads[
t] = [
t, &hints, &max_window, &num_windows, &kernel, &tensors](
const ThreadInfo &
info)
84 kernel->run_op(tensors, win,
info);
87 run_workloads(workloads);
90 #ifndef DOXYGEN_SKIP_THIS
91 void OMPScheduler::run_workloads(std::vector<arm_compute::IScheduler::Workload> &workloads)
93 const unsigned int amount_of_work =
static_cast<unsigned int>(workloads.size());
94 const unsigned int num_threads_to_use = std::min(_num_threads, amount_of_work);
96 if (num_threads_to_use < 1)
103 info.num_threads = num_threads_to_use;
104 #pragma omp parallel for firstprivate(info) num_threads(num_threads_to_use) default(shared) proc_bind(close) \
106 for (
unsigned int wid = 0; wid < amount_of_work; ++wid)
108 const int tid = omp_get_thread_num();
110 info.thread_id = tid;
111 workloads[wid](
info);
void set_num_threads(unsigned int num_threads) override
Sets the number of threads the scheduler will use to run the kernels.
StrategyHint strategy() const
Return the prefered strategy to use to split workload.
CPUInfo & cpu_info()
Get CPU info.
unsigned int num_threads() const override
Returns the number of threads that the OMPScheduler has in its pool.
constexpr size_t num_iterations(size_t dimension) const
Return the number of iterations needed to iterate through a given dimension.
OpenMP scheduler (Alternative to the CPPScheduler).
Window split_window(size_t dimension, size_t id, size_t total) const
Split a window into a set of sub windows along a given dimension.
virtual void run_op(ITensorPack &tensors, const Window &window, const ThreadInfo &info)
Execute the kernel on the passed window.
void schedule_op(ICPPKernel *kernel, const Hints &hints, const Window &window, ITensorPack &tensors) override
Multithread the execution of the passed kernel if possible.
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
@ DYNAMIC
Split the workload dynamically using a bucket system.
unsigned int split_dimension() const
Return the prefered split dimension.
Common interface for all kernels implemented in C++.
void validate() const
Will validate all the window's dimensions' values when asserts are enabled.
const Window & window() const
The maximum window the kernel can be executed on.
Information about executing thread and CPU.
Describe a multidimensional execution window.
Copyright (c) 2017-2024 Arm Limited.
void schedule(ICPPKernel *kernel, const Hints &hints) override
Multithread the execution of the passed kernel if possible.
virtual bool is_parallelisable() const
Indicates whether or not the kernel is parallelisable.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
OMPScheduler()
Constructor.