Compute Library
 20.02.1
CLRuntimeContext Class Reference

Runtime context. More...

#include <CLRuntimeContext.h>

Collaboration diagram for CLRuntimeContext:
[legend]

Public Member Functions

 CLRuntimeContext ()
 Default Constructor. More...
 
 ~CLRuntimeContext ()=default
 Destructor. More...
 
 CLRuntimeContext (const CLRuntimeContext &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 CLRuntimeContext (CLRuntimeContext &&)=default
 Default move constructor. More...
 
CLRuntimeContextoperator= (const CLRuntimeContext &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
CLRuntimeContextoperator= (CLRuntimeContext &&)=default
 Default move assignment operator. More...
 
void set_gpu_scheduler (CLScheduler *scheduler)
 CPU Scheduler setter. More...
 
CLSchedulergpu_scheduler ()
 
CLKernelLibrarykernel_library ()
 
CLCoreRuntimeContextcore_runtime_context ()
 
- Public Member Functions inherited from RuntimeContext
 RuntimeContext ()
 Default Constructor. More...
 
 ~RuntimeContext ()=default
 Destructor. More...
 
 RuntimeContext (const RuntimeContext &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 RuntimeContext (RuntimeContext &&)=default
 Default move constructor. More...
 
RuntimeContextoperator= (const RuntimeContext &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
RuntimeContextoperator= (RuntimeContext &&)=default
 Default move assignment operator. More...
 
void set_scheduler (IScheduler *scheduler)
 CPU Scheduler setter. More...
 
ISchedulerscheduler () override
 Scheduler accessor. More...
 
IAssetManagerasset_manager () override
 Asset manager accessor. More...
 
const DevicePropertiesproperties () override
 Device propertied accessor. More...
 
- Public Member Functions inherited from IRuntimeContext
virtual ~IRuntimeContext ()=default
 Destructor. More...
 

Detailed Description

Runtime context.

Definition at line 38 of file CLRuntimeContext.h.

Constructor & Destructor Documentation

◆ CLRuntimeContext() [1/3]

Default Constructor.

Definition at line 31 of file CLRuntimeContext.cpp.

32  : _gpu_owned_scheduler(support::cpp14::make_unique<CLScheduler>()), _gpu_scheduler(_gpu_owned_scheduler.get()), _symbols(), _core_context()
33 {
34  _symbols.load_default();
35  auto ctx_dev_err = create_opencl_context_and_device();
36  ARM_COMPUTE_ERROR_ON_MSG(std::get<2>(ctx_dev_err) != CL_SUCCESS, "Failed to create OpenCL context");
37  auto ctx = std::get<0>(ctx_dev_err);
38  auto dev = std::get<1>(ctx_dev_err);
39  cl::CommandQueue queue = cl::CommandQueue(ctx, dev);
40  _gpu_owned_scheduler->init(ctx, queue, dev, &_tuner);
41  const std::string cl_kernels_folder("./cl_kernels");
42  _kernel_lib.init(cl_kernels_folder, ctx, dev);
43  _core_context = CLCoreRuntimeContext(&_kernel_lib, _gpu_owned_scheduler->context(), _gpu_owned_scheduler->queue());
44 }
std::tuple< cl::Context, cl::Device, cl_int > create_opencl_context_and_device()
This function creates an OpenCL context and a device.
Definition: CLHelpers.cpp:88
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
Definition: Error.h:456
bool load_default()
Load symbols from any of the default OpenCL library names.
Definition: OpenCL.cpp:43
void init(std::string kernel_path, cl::Context context, cl::Device device)
Initialises the kernel library.

References ARM_COMPUTE_ERROR_ON_MSG, arm_compute::create_opencl_context_and_device(), CLKernelLibrary::init(), and CLSymbols::load_default().

◆ ~CLRuntimeContext()

~CLRuntimeContext ( )
default

Destructor.

◆ CLRuntimeContext() [2/3]

CLRuntimeContext ( const CLRuntimeContext )
delete

Prevent instances of this class from being copied (As this class contains pointers)

◆ CLRuntimeContext() [3/3]

Default move constructor.

Member Function Documentation

◆ core_runtime_context()

CLCoreRuntimeContext * core_runtime_context ( )

Definition at line 51 of file CLRuntimeContext.cpp.

52 {
53  return &_core_context;
54 }

Referenced by CLTensorAllocator::allocate(), and CLTensorAllocator::import_memory().

◆ gpu_scheduler()

CLScheduler * gpu_scheduler ( )

Definition at line 62 of file CLRuntimeContext.cpp.

63 {
64  return _gpu_scheduler;
65 }

Referenced by CLTensor::map(), arm_compute::schedule_kernel_on_ctx(), and CLTensor::unmap().

◆ kernel_library()

CLKernelLibrary & kernel_library ( )

Definition at line 46 of file CLRuntimeContext.cpp.

47 {
48  return _kernel_lib;
49 }

◆ operator=() [1/2]

CLRuntimeContext& operator= ( const CLRuntimeContext )
delete

Prevent instances of this class from being copied (As this class contains pointers)

◆ operator=() [2/2]

CLRuntimeContext& operator= ( CLRuntimeContext &&  )
default

Default move assignment operator.

◆ set_gpu_scheduler()

void set_gpu_scheduler ( CLScheduler scheduler)

CPU Scheduler setter.

Definition at line 56 of file CLRuntimeContext.cpp.

57 {
59  _gpu_scheduler = scheduler;
60 }
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161
IScheduler * scheduler() override
Scheduler accessor.

References ARM_COMPUTE_ERROR_ON_NULLPTR, and RuntimeContext::scheduler().


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