Compute Library
 23.08
Scheduler Class Reference

Configurable scheduler which supports multiple multithreading APIs and choosing between different schedulers at runtime. More...

#include <Scheduler.h>

Public Types

enum  Type { ST, CPP, OMP, CUSTOM }
 Scheduler type. More...
 

Static Public Member Functions

static void set (std::shared_ptr< IScheduler > scheduler)
 Sets the user defined scheduler and makes it the active scheduler. More...
 
static ISchedulerget ()
 Access the scheduler singleton. More...
 
static void set (Type t)
 Set the active scheduler. More...
 
static Type get_type ()
 Returns the type of the active scheduler. More...
 
static bool is_available (Type t)
 Returns true if the given scheduler type is supported. More...
 

Detailed Description

Configurable scheduler which supports multiple multithreading APIs and choosing between different schedulers at runtime.

Definition at line 35 of file Scheduler.h.

Member Enumeration Documentation

◆ Type

enum Type
strong

Scheduler type.

Enumerator
ST 

Single thread.

CPP 

C++11 threads.

OMP 

OpenMP.

CUSTOM 

Provided by the user.

Definition at line 39 of file Scheduler.h.

40  {
41  ST, /**< Single thread. */
42  CPP, /**< C++11 threads. */
43  OMP, /**< OpenMP. */
44  CUSTOM /**< Provided by the user. */
45  };

Member Function Documentation

◆ get()

IScheduler & get ( )
static

Access the scheduler singleton.

Returns
A reference to the scheduler object.

Definition at line 94 of file Scheduler.cpp.

95 {
96  if(_scheduler_type == Type::CUSTOM)
97  {
98  if(_custom_scheduler == nullptr)
99  {
100  ARM_COMPUTE_ERROR("No custom scheduler has been setup. Call set(std::shared_ptr<IScheduler> &scheduler) before Scheduler::get()");
101  }
102  else
103  {
104  return *_custom_scheduler;
105  }
106  }
107  else
108  {
109  if(_schedulers.empty())
110  {
111  _schedulers = init();
112  }
113 
114  auto it = _schedulers.find(_scheduler_type);
115  if(it != _schedulers.end())
116  {
117  return *it->second;
118  }
119  else
120  {
121  ARM_COMPUTE_ERROR("Invalid Scheduler type");
122  }
123  }
124 }

References ARM_COMPUTE_ERROR, and Scheduler::CUSTOM.

Referenced by CpuDepthwiseConv2dAssemblyDispatch::configure(), CpuPool2d::configure(), CpuWinogradConv2d::configure(), CpuConv2d::get_convolution_method(), CpuGemmAssemblyDispatch::has_opt_impl(), main(), CpuFullyConnected::prepare(), CpuGemmLowpMatrixMultiplyCore::prepare(), CpuGemmConv2d::prepare(), NEQLSTMLayer::prepare(), ICPPSimpleFunction::run(), CpuDequantize::run(), CpuQuantize::run(), CpuConvertFullyConnectedWeights::run(), INESimpleFunction::run(), CpuActivation::run(), CpuAddMulAdd::run(), CpuScale::run(), NEFillBorder::run(), CpuPool3d::run(), CpuSub::run(), CpuConcatenate::run(), CpuAdd::run(), CpuPool2d::run(), CpuDepthwiseConv2dAssemblyDispatch::run(), CpuMul::run(), NEROIPoolingLayer::run(), CpuMatMul::run(), CpuSoftmaxGeneric< IS_LOG >::run(), NESpaceToDepthLayer::run(), NELogicalAnd::run(), CpuGemmLowpOutputStage::run(), CPPBoxWithNonMaximaSuppressionLimit::run(), CpuDirectConv2d::run(), CpuDirectConv3d::run(), CpuWinogradConv2d::run(), NEStackLayer::run(), NEFFT1D::run(), NEL2NormalizeLayer::run(), NERange::run(), NENormalizationLayer::run(), NEReductionOperation::run(), NEInstanceNormalizationLayer::run(), NEPadLayer::run(), NECropResize::run(), CpuComplexMul::run(), NEFuseBatchNormalization::run(), NEBatchNormalizationLayer::run(), NESpaceToBatchLayer::run(), CpuGemm::run(), NEGenerateProposalsLayer::run(), CpuGemmLowpMatrixMultiplyCore::run(), NESynthetizeFunctionWithZeroConstantKernelBorder< K >::run(), NELogicalOr::run(), CpuGemmConv2d::run(), NELogicalNot::run(), NEQLSTMLayer::run(), arm_compute::utils::schedule_kernel_on_ctx(), CpuQueue::scheduler(), NEDeviceBackend::setup_backend_context(), and SchedulerClock< output_timestamps >::test_start().

◆ get_type()

Scheduler::Type get_type ( )
static

Returns the type of the active scheduler.

Returns
The current scheduler's type.

Definition at line 89 of file Scheduler.cpp.

90 {
91  return _scheduler_type;
92 }

Referenced by SchedulerClock< output_timestamps >::test_start().

◆ is_available()

bool is_available ( Type  t)
static

Returns true if the given scheduler type is supported.

False otherwise.

Parameters
[in]tthe type of the scheduler to check.
Returns
true if the given scheduler type is supported. False otherwise.

Definition at line 77 of file Scheduler.cpp.

78 {
79  if(t == Type::CUSTOM)
80  {
81  return _custom_scheduler != nullptr;
82  }
83  else
84  {
85  return _schedulers.find(t) != _schedulers.end();
86  }
87 }

References Scheduler::CUSTOM, and tf_frozen_model_extractor::t.

Referenced by Scheduler::set().

◆ set() [1/2]

void set ( std::shared_ptr< IScheduler scheduler)
static

Sets the user defined scheduler and makes it the active scheduler.

Parameters
[in]schedulerA shared pointer to a custom scheduler implemented by the user.

Definition at line 126 of file Scheduler.cpp.

127 {
128  _custom_scheduler = std::move(scheduler);
129  set(Type::CUSTOM);
130 }

References Scheduler::CUSTOM.

Referenced by SchedulerClock< output_timestamps >::test_start(), and SchedulerClock< output_timestamps >::test_stop().

◆ set() [2/2]

void set ( Type  t)
static

Set the active scheduler.

Only one scheduler can be enabled at any time.

Parameters
[in]tthe type of the scheduler to be enabled.

Definition at line 71 of file Scheduler.cpp.

72 {
74  _scheduler_type = t;
75 }

References ARM_COMPUTE_ERROR_ON, Scheduler::is_available(), and tf_frozen_model_extractor::t.


The documentation for this class was generated from the following files:
ARM_COMPUTE_ERROR
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:353
arm_compute::Scheduler::is_available
static bool is_available(Type t)
Returns true if the given scheduler type is supported.
Definition: Scheduler.cpp:77
arm_compute::Scheduler::Type::CUSTOM
@ CUSTOM
Provided by the user.
ARM_COMPUTE_ERROR_ON
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:467
arm_compute::Scheduler::set
static void set(std::shared_ptr< IScheduler > scheduler)
Sets the user defined scheduler and makes it the active scheduler.
Definition: Scheduler.cpp:126
tf_frozen_model_extractor.t
t
Definition: tf_frozen_model_extractor.py:49