Compute Library
 19.11
SingleThreadScheduler Class Referencefinal

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

 SingleThreadScheduler ()=default
 Constructor. More...
 
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...
 

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.

Constructor & Destructor Documentation

◆ SingleThreadScheduler()

SingleThreadScheduler ( )
default

Constructor.

Member Function Documentation

◆ 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 55 of file SingleThreadScheduler.cpp.

56 {
57  return 1;
58 }

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 38 of file SingleThreadScheduler.cpp.

39 {
40  ARM_COMPUTE_UNUSED(hints);
41  ThreadInfo info;
42  info.cpu_info = &_cpu_info;
43  kernel->run(kernel->window(), info);
44 }
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152

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 32 of file SingleThreadScheduler.cpp.

33 {
36 }
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:466
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152

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


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