Compute Library
 21.05
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 }
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352

References ARM_COMPUTE_ERROR, and Scheduler::CUSTOM.

Referenced by CpuDepthwiseConvolutionAssemblyDispatch::configure(), CpuPoolingAssemblyDispatch::configure(), NEWinogradConvolutionLayer::configure(), NEConvolutionLayer::get_convolution_method(), main(), NEWinogradConvolutionLayer::prepare(), NEGEMM::prepare(), NEGEMMLowpMatrixMultiplyCore::prepare(), NEQLSTMLayer::prepare(), ICPPSimpleFunction::run(), INESimpleFunction::run(), CpuConvertFullyConnectedWeights::run(), CpuDequantization::run(), NEFillBorder::run(), CpuScale::run(), CpuQuantization::run(), CpuConcatenate::run(), CpuMul::run(), CpuPoolingAssemblyDispatch::run(), NEROIPoolingLayer::run(), NELogicalAnd::run(), NESpaceToDepthLayer::run(), CpuSoftmaxGeneric< IS_LOG >::run(), CpuDepthwiseConvolutionAssemblyDispatch::run(), CPPBoxWithNonMaximaSuppressionLimit::run(), CpuPooling::run(), NEConvolutionLayerReshapeWeights::run(), NEFFT1D::run(), NEStackLayer::run(), NEL2NormalizeLayer::run(), NERange::run(), NEMaxUnpoolingLayer::run(), NEReductionOperation::run(), NENormalizationLayer::run(), NEInstanceNormalizationLayer::run(), NEWinogradConvolutionLayer::run(), NEPadLayer::run(), NECropResize::run(), NEFuseBatchNormalization::run(), CpuDirectConvolution::run(), CpuComplexMul::run(), NEBatchNormalizationLayer::run(), NESpaceToBatchLayer::run(), NEGEMM::run(), NEGenerateProposalsLayer::run(), NESynthetizeFunctionWithZeroConstantKernelBorder< K >::run(), NELogicalOr::run(), NEGEMMLowpMatrixMultiplyCore::run(), NELogicalNot::run(), NEQLSTMLayer::run(), NEGEMMConvolutionLayer::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 }
static void set(std::shared_ptr< IScheduler > scheduler)
Sets the user defined scheduler and makes it the active scheduler.
Definition: Scheduler.cpp:126

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 }
#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
static bool is_available(Type t)
Returns true if the given scheduler type is supported.
Definition: Scheduler.cpp:77

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: