23.11
|
C++11 implementation of a pool of threads to automatically split a kernel's execution among several threads. More...
#include <CPPScheduler.h>
Public Member Functions | |
CPPScheduler () | |
Constructor: create a pool of threads. More... | |
~CPPScheduler () | |
Default destructor. More... | |
void | set_num_threads (unsigned int num_threads) override |
Sets the number of threads the scheduler will use to run the kernels. More... | |
void | set_num_threads_with_affinity (unsigned int num_threads, BindFunc func) override |
Sets the number of threads the scheduler will use to run the kernels but also using a binding function to pin the threads to given logical cores. More... | |
unsigned int | num_threads () const override |
Returns the number of threads that the SingleThreadScheduler has in its pool. More... | |
void | schedule (ICPPKernel *kernel, const Hints &hints) override |
Runs the kernel in the same thread as the caller synchronously. More... | |
void | schedule_op (ICPPKernel *kernel, const Hints &hints, const Window &window, ITensorPack &tensors) override |
Runs the kernel in the same thread as the caller synchronously. More... | |
![]() | |
IScheduler () | |
Default constructor. More... | |
virtual | ~IScheduler ()=default |
Destructor. More... | |
virtual void | run_tagged_workloads (std::vector< Workload > &workloads, const char *tag) |
Execute all the passed workloads. More... | |
CPUInfo & | cpu_info () |
Get CPU info. More... | |
unsigned int | num_threads_hint () const |
Get a hint for the best possible number of execution threads. More... | |
Static Public Member Functions | |
static CPPScheduler & | get () |
Access the scheduler singleton. More... | |
Additional Inherited Members | |
![]() | |
enum | StrategyHint { STATIC, DYNAMIC } |
Strategies available to split a workload. More... | |
using | BindFunc = std::function< int(int, int)> |
Function to be used and map a given thread id to a logical core id. More... | |
using | Workload = std::function< void(const ThreadInfo &)> |
Signature for the workloads to execute. More... | |
![]() | |
static constexpr unsigned int | split_dimensions_all = std::numeric_limits<unsigned>::max() |
When arm_compute::ISchedular::Hints::_split_dimension is initialized with this value then the schedular is free to break down the problem space over as many dimensions as it wishes. More... | |
C++11 implementation of a pool of threads to automatically split a kernel's execution among several threads.
It has 2 scheduling modes: Linear or Fanout (please refer to the implementation for details) The mode is selected automatically based on the runtime environment. However it can be forced via an environment variable ARM_COMPUTE_CPP_SCHEDULER_MODE. e.g.: ARM_COMPUTE_CPP_SCHEDULER_MODE=linear # Force select the linear scheduling mode ARM_COMPUTE_CPP_SCHEDULER_MODE=fanout # Force select the fanout scheduling mode
Definition at line 42 of file CPPScheduler.h.
CPPScheduler | ( | ) |
Constructor: create a pool of threads.
Definition at line 435 of file CPPScheduler.cpp.
|
default |
Default destructor.
|
static |
Access the scheduler singleton.
Definition at line 429 of file CPPScheduler.cpp.
|
overridevirtual |
Returns the number of threads that the SingleThreadScheduler has in its pool.
Implements IScheduler.
Definition at line 455 of file CPPScheduler.cpp.
Referenced by CPPScheduler::set_num_threads(), and CPPScheduler::set_num_threads_with_affinity().
|
overridevirtual |
Runs the kernel in the same thread as the caller synchronously.
[in] | kernel | Kernel to execute. |
[in] | hints | Hints for the scheduler. |
Implements IScheduler.
Definition at line 552 of file CPPScheduler.cpp.
References IKernel::window().
Referenced by TEST_CASE().
|
overridevirtual |
Runs the kernel in the same thread as the caller synchronously.
[in] | kernel | Kernel to execute. |
[in] | hints | Hints for the scheduler. |
[in] | window | Window to use for kernel execution. |
[in] | tensors | Vector containing the tensors to operate on. |
Implements IScheduler.
Definition at line 547 of file CPPScheduler.cpp.
|
overridevirtual |
Sets the number of threads the scheduler will use to run the kernels.
[in] | num_threads | If set to 0, then one thread per CPU core available on the system will be used, otherwise the number of threads specified. |
Implements IScheduler.
Definition at line 441 of file CPPScheduler.cpp.
References CPPScheduler::num_threads(), and IScheduler::num_threads_hint().
Referenced by TEST_CASE().
|
overridevirtual |
Sets the number of threads the scheduler will use to run the kernels but also using a binding function to pin the threads to given logical cores.
[in] | num_threads | If set to 0, then one thread per CPU core available on the system will be used, otherwise the number of threads specified. |
[in] | func | Binding function to use. |
Reimplemented from IScheduler.
Definition at line 448 of file CPPScheduler.cpp.
References CPPScheduler::num_threads(), and IScheduler::num_threads_hint().