Compute Library
 20.02.1
GCScheduler Class Referencefinal

Provides global access to a OpenGL ES context and command queue. More...

#include <GCScheduler.h>

Public Member Functions

 GCScheduler ()
 Constructor. More...
 
 ~GCScheduler ()
 Destructor. More...
 
 GCScheduler (const GCScheduler &)=delete
 Prevent instances of this class from being copied. More...
 
GCScheduleroperator= (const GCScheduler &)=delete
 Prevent instances of this class from being copied. More...
 
void default_init ()
 Initialises the context and command queue used by the scheduler to default values and sets a default device and kernel path for the GCKernelLibrary. More...
 
void default_init_with_context (EGLDisplay display, EGLContext ctx)
 Initializes the context and display used by the Scheduler. More...
 
void dispatch (IGCKernel &kernel, bool flush=true)
 Schedule the execution of the passed kernel if possible. More...
 
void init (EGLDisplay dpy, EGLContext ctx)
 Initialises the display and context to be used by the scheduler. More...
 
void memory_barrier ()
 Defines a barrier ordering memory transactions. More...
 
GPUTarget get_target () const
 Get the target GPU. More...
 
void set_target (GPUTarget target)
 Accessor to set target GPU to be used by the scheduler. More...
 

Static Public Member Functions

static GCSchedulerget ()
 Access the scheduler singleton. More...
 

Detailed Description

Provides global access to a OpenGL ES context and command queue.

Definition at line 37 of file GCScheduler.h.

Constructor & Destructor Documentation

◆ GCScheduler() [1/2]

Constructor.

Definition at line 34 of file GCScheduler.cpp.

35  : _display(EGL_NO_DISPLAY), _context(EGL_NO_CONTEXT), _target(GPUTarget::MIDGARD)
36 {
37 }

References arm_compute::MIDGARD.

◆ ~GCScheduler()

Destructor.

Definition at line 39 of file GCScheduler.cpp.

40 {
41  eglDestroyContext(_display, _context);
42  eglTerminate(_display);
43 
44  _context = EGL_NO_CONTEXT;
45  _display = EGL_NO_DISPLAY;
46 }
EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay dpy, EGLContext ctx)
Definition: OpenGLES.cpp:217
EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy)
Definition: OpenGLES.cpp:269

References eglDestroyContext(), and eglTerminate().

◆ GCScheduler() [2/2]

GCScheduler ( const GCScheduler )
delete

Prevent instances of this class from being copied.

Member Function Documentation

◆ default_init()

void default_init ( )

Initialises the context and command queue used by the scheduler to default values and sets a default device and kernel path for the GCKernelLibrary.

Definition at line 48 of file GCScheduler.cpp.

49 {
50  setup_context();
51 
52  init(_display, _context);
53 }
void init(EGLDisplay dpy, EGLContext ctx)
Initialises the display and context to be used by the scheduler.
Definition: GCScheduler.cpp:63

References GCScheduler::init().

Referenced by GCDeviceBackend::initialize_backend(), and main().

◆ default_init_with_context()

void default_init_with_context ( EGLDisplay  display,
EGLContext  ctx 
)

Initializes the context and display used by the Scheduler.

Parameters
[in]displayDisplay to use
[in]ctxContext to use

Definition at line 55 of file GCScheduler.cpp.

56 {
57  _context = ctx;
58  _display = display;
59 
60  _target = get_target_from_device();
61 }
GPUTarget get_target_from_device(const cl::Device &device)
Helper function to get the GPU target from CL device.
Definition: CLHelpers.cpp:226

References arm_compute::get_target_from_device().

◆ dispatch()

void dispatch ( IGCKernel kernel,
bool  flush = true 
)

Schedule the execution of the passed kernel if possible.

Parameters
[in]kernelKernel to execute.
[in]flush(Optional) Specifies if the command queue will be flushed after running the kernel.

Definition at line 77 of file GCScheduler.cpp.

78 {
79  kernel.run(kernel.window());
80  if(flush)
81  {
83  }
84 }
#define ARM_COMPUTE_GL_CHECK(x)
Definition: OpenGLES.h:45
virtual void run(const Window &window)=0
Enqueue the OpenGL ES shader to process the given window.
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
void GL_APIENTRY glFlush(void)
Definition: OpenGLES.cpp:555

References ARM_COMPUTE_GL_CHECK, glFlush(), IGCKernel::run(), and IKernel::window().

Referenced by GCGEMM::prepare(), IGCSimpleFunction::run(), GCDropoutLayer::run(), GCConcatenateLayer::run(), GCConvolutionLayerReshapeWeights::run(), GCBatchNormalizationLayer::run(), GCNormalizationLayer::run(), GCDepthwiseConvolutionLayer3x3::run(), GCSoftmaxLayer::run(), GCPoolingLayer::run(), GCNormalizePlanarYUVLayer::run(), GCDirectConvolutionLayer::run(), GCFullyConnectedLayer::run(), GCGEMM::run(), and GCConvolutionLayer::run().

◆ get()

◆ get_target()

GPUTarget get_target ( ) const
inline

Get the target GPU.

Returns
The target GPU.

Definition at line 81 of file GCScheduler.h.

82  {
83  return _target;
84  }

Referenced by GCGEMM::configure().

◆ init()

void init ( EGLDisplay  dpy,
EGLContext  ctx 
)

Initialises the display and context to be used by the scheduler.

Parameters
[in]dpyThe EGL display connection
[in]ctxThe EGL rendering context

Definition at line 63 of file GCScheduler.cpp.

64 {
65  _target = get_target_from_device();
66 
67  GCKernelLibrary::get().init("./cs_shaders/", dpy, ctx);
68 }
GPUTarget get_target_from_device(const cl::Device &device)
Helper function to get the GPU target from CL device.
Definition: CLHelpers.cpp:226
static GCKernelLibrary & get()
Get the static instance of GCKernelLibrary.
void init(std::string shader_path="./", EGLDisplay dpy=EGL_NO_DISPLAY, EGLContext ctx=EGL_NO_CONTEXT)
Initialises the kernel library.

References GCKernelLibrary::get(), arm_compute::get_target_from_device(), and GCKernelLibrary::init().

Referenced by GCScheduler::default_init().

◆ memory_barrier()

void memory_barrier ( )

Defines a barrier ordering memory transactions.

Definition at line 86 of file GCScheduler.cpp.

87 {
88  ARM_COMPUTE_GL_CHECK(glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT));
89 }
#define ARM_COMPUTE_GL_CHECK(x)
Definition: OpenGLES.h:45
void GL_APIENTRY glMemoryBarrier(GLbitfield barriers)
Definition: OpenGLES.cpp:620

References ARM_COMPUTE_GL_CHECK, and glMemoryBarrier().

Referenced by GCGEMM::prepare(), IGCSimpleFunction::run(), GCNormalizationLayer::run(), GCSoftmaxLayer::run(), GCDepthwiseConvolutionLayer3x3::run(), GCPoolingLayer::run(), GCDirectConvolutionLayer::run(), GCFullyConnectedLayer::run(), GCGEMM::run(), and GCConvolutionLayer::run().

◆ operator=()

GCScheduler& operator= ( const GCScheduler )
delete

Prevent instances of this class from being copied.

◆ set_target()

void set_target ( GPUTarget  target)
inline

Accessor to set target GPU to be used by the scheduler.

Parameters
[in]targetThe target GPU.

Definition at line 89 of file GCScheduler.h.

90  {
91  _target = target;
92  }

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