36 : _num_threads(omp_get_max_threads())
47 const unsigned int num_cores = omp_get_max_threads();
48 _num_threads = (num_threads == 0) ? num_cores : num_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);
71 kernel->
run_op(tensors, max_window, info);
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 num_threads = std::min(_num_threads, static_cast<unsigned int>(workloads.size()));
102 #pragma omp parallel firstprivate(info) num_threads(num_threads) 104 const int tid = omp_get_thread_num();
106 workloads[tid](
info);
const Window & window() const
The maximum window the kernel can be executed on.
void schedule_op(ICPPKernel *kernel, const Hints &hints, const Window &window, ITensorPack &tensors) override
Multithread the execution of the passed kernel if possible.
OMPScheduler()
Constructor.
Common interface for all kernels implemented in C++.
void set_num_threads(unsigned int num_threads) override
Sets the number of threads the scheduler will use to run the kernels.
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 validate() const
Will validate all the window's dimensions' values when asserts are enabled.
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).
Copyright (c) 2017-2021 Arm Limited.
Split the workload dynamically using a bucket system.
StrategyHint strategy() const
Return the prefered strategy to use to split workload.
virtual bool is_parallelisable() const
Indicates whether or not the kernel is parallelisable.
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
void schedule(ICPPKernel *kernel, const Hints &hints) override
Multithread the execution of the passed kernel if possible.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
Information about executing thread and CPU.
unsigned int num_threads() const override
Returns the number of threads that the OMPScheduler has in its pool.
unsigned int split_dimension() const
Return the prefered split dimension.
Describe a multidimensional execution window.