Compute Library
 19.08
SingleThreadScheduler Class Reference

Pool of threads to automatically split a kernel's execution among several threads. More...

#include <SingleThreadScheduler.h>

Collaboration diagram for SingleThreadScheduler:
[legend]

Public Member Functions

void set_num_threads (unsigned int num_threads) override
 Sets the number of threads the scheduler will use to run the kernels. More...
 
unsigned int num_threads () const override
 Returns the number of threads that the SingleThreadScheduler has, which is always 1. More...
 
void schedule (ICPPKernel *kernel, const Hints &hints) override
 Runs the kernel in the same thread as the caller synchronously. More...
 
- Public Member Functions inherited from IScheduler
 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...
 
CPUInfocpu_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 SingleThreadSchedulerget ()
 Access the scheduler singleton. More...
 

Additional Inherited Members

- Public Types inherited from IScheduler
enum  StrategyHint { STATIC, DYNAMIC }
 Strategies available to split a workload. More...
 
using Workload = std::function< void(const ThreadInfo &)>
 Signature for the workloads to execute. More...
 

Detailed Description

Pool of threads to automatically split a kernel's execution among several threads.

Definition at line 32 of file SingleThreadScheduler.h.

Member Function Documentation

◆ get()

SingleThreadScheduler & get ( )
static

Access the scheduler singleton.

Returns
The scheduler

Definition at line 32 of file SingleThreadScheduler.cpp.

33 {
34  static SingleThreadScheduler scheduler;
35  return scheduler;
36 }

Referenced by Scheduler::get().

◆ num_threads()

unsigned int num_threads ( ) const
overridevirtual

Returns the number of threads that the SingleThreadScheduler has, which is always 1.

Returns
Number of threads available in SingleThreadScheduler.

Implements IScheduler.

Definition at line 61 of file SingleThreadScheduler.cpp.

62 {
63  return 1;
64 }

Referenced by SingleThreadScheduler::set_num_threads().

◆ schedule()

void schedule ( ICPPKernel kernel,
const Hints hints 
)
overridevirtual

Runs the kernel in the same thread as the caller synchronously.

Parameters
[in]kernelKernel to execute.
[in]hintsHints for the scheduler.

Implements IScheduler.

Definition at line 44 of file SingleThreadScheduler.cpp.

45 {
46  ARM_COMPUTE_UNUSED(hints);
47  ThreadInfo info;
48  info.cpu_info = &_cpu_info;
49  kernel->run(kernel->window(), info);
50 }
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:160

References ARM_COMPUTE_UNUSED, arm_compute::test::validation::info, ICPPKernel::run(), and IKernel::window().

◆ set_num_threads()

void set_num_threads ( unsigned int  num_threads)
overridevirtual

Sets the number of threads the scheduler will use to run the kernels.

Parameters
[in]num_threadsThis is ignored for this scheduler as the number of threads is always one.

Implements IScheduler.

Definition at line 38 of file SingleThreadScheduler.cpp.

39 {
42 }
unsigned int num_threads() const override
Returns the number of threads that the SingleThreadScheduler has, which is always 1.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:337
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:160

References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_UNUSED, and SingleThreadScheduler::num_threads().


The documentation for this class was generated from the following files: