Compute Library
 19.11
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 95 of file Scheduler.cpp.

96 {
97  if(_scheduler_type == Type::CUSTOM)
98  {
99  if(_custom_scheduler == nullptr)
100  {
101  ARM_COMPUTE_ERROR("No custom scheduler has been setup. Call set(std::shared_ptr<IScheduler> &scheduler) before Scheduler::get()");
102  }
103  else
104  {
105  return *_custom_scheduler;
106  }
107  }
108  else
109  {
110  auto it = _schedulers.find(_scheduler_type);
111  if(it != _schedulers.end())
112  {
113  return *it->second;
114  }
115  else
116  {
117  ARM_COMPUTE_ERROR("Invalid Scheduler type");
118  }
119  }
120 }
#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 NEHistogram::configure(), NEDepthwiseConvolutionAssemblyDispatch::configure(), NEWinogradConvolutionLayer::configure(), main(), NEWinogradConvolutionLayer::prepare(), NELocallyConnectedLayer::prepare(), NEGEMM::prepare(), NEGEMMLowpMatrixMultiplyCore::prepare(), NEDeconvolutionLayer::prepare(), ICPPSimpleFunction::run(), INESimpleFunction::run(), NESimpleAssemblyFunction::run(), NEFillBorder::run(), NEHistogram::run(), NEMeanStdDev::run(), NEGEMMLowpAssemblyMatrixMultiplyCore::run(), NEEqualizeHistogram::run(), NEHOGDescriptor::run(), NEDerivative::run(), NEConvertFullyConnectedWeights::run(), NEROIPoolingLayer::run(), NEMinMaxLocation::run(), NEHOGGradient::run(), NEGaussian5x5::run(), NERange::run(), NEUpsampleLayer::run(), NESobel5x5::run(), NESobel7x7::run(), NEPoolingLayer::run(), NEFastCorners::run(), NEFFT1D::run(), NEL2NormalizeLayer::run(), NEReductionOperation::run(), NEStackLayer::run(), NESpaceToDepthLayer::run(), NEIm2Col::run(), NEInstanceNormalizationLayer::run(), NENormalizationLayer::run(), NEScale::run(), NEWinogradConvolutionLayer::run(), NEPadLayer::run(), NECannyEdge::run(), NEConcatenateLayer::run(), NERNNLayer::run(), NEConvolutionLayerReshapeWeights::run(), NEBatchNormalizationLayer::run(), NEOpticalFlow::run(), CLHarrisCorners::run(), CPPBoxWithNonMaximaSuppressionLimit::run(), NEHarrisCorners::run(), CLHOGMultiDetection::run(), NEConvolutionSquare< matrix_size >::run(), NEHOGMultiDetection::run(), NEGaussianPyramidHalf::run(), NELocallyConnectedLayer::run(), NESoftmaxLayerGeneric< IS_LOG >::run(), NEFuseBatchNormalization::run(), NECropResize::run(), NEDirectConvolutionLayer::run(), NESpaceToBatchLayer::run(), NEGEMM::run(), NEDepthwiseConvolutionAssemblyDispatch::run(), NEGEMMLowpMatrixMultiplyCore::run(), NEGenerateProposalsLayer::run(), NELSTMLayer::run(), NEFullyConnectedLayer::run(), NEGEMMConvolutionLayer::run(), arm_compute::schedule_kernel_on_ctx(), 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 90 of file Scheduler.cpp.

91 {
92  return _scheduler_type;
93 }

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 78 of file Scheduler.cpp.

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

References Scheduler::CUSTOM.

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 122 of file Scheduler.cpp.

123 {
124  _custom_scheduler = std::move(scheduler);
125  set(Type::CUSTOM);
126 }
static void set(std::shared_ptr< IScheduler > scheduler)
Sets the user defined scheduler and makes it the active scheduler.
Definition: Scheduler.cpp:122

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 72 of file Scheduler.cpp.

73 {
75  _scheduler_type = t;
76 }
#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:78

References ARM_COMPUTE_ERROR_ON, and Scheduler::is_available().


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