Compute Library
 23.08
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...
 
CLRuntimeContextoperator= (const CLRuntimeContext &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
void set_gpu_scheduler (CLScheduler *scheduler)
 CPU Scheduler setter. More...
 
CLSchedulergpu_scheduler ()
 
CLKernelLibrarykernel_library ()
 
- 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...
 
- 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/2]

Default Constructor.

Definition at line 31 of file CLRuntimeContext.cpp.

32  : _gpu_owned_scheduler(std::make_unique<CLScheduler>()), _gpu_scheduler(_gpu_owned_scheduler.get()), _symbols(), _backend_type()
33 {
34  _symbols.load_default();
35  auto ctx_dev_err = create_opencl_context_and_device(_backend_type);
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  CLKernelLibrary::get().init(cl_kernels_folder, ctx, dev);
43 }

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

◆ ~CLRuntimeContext()

~CLRuntimeContext ( )
default

Destructor.

◆ CLRuntimeContext() [2/2]

CLRuntimeContext ( const CLRuntimeContext )
delete

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

Member Function Documentation

◆ gpu_scheduler()

CLScheduler * gpu_scheduler ( )

Definition at line 56 of file CLRuntimeContext.cpp.

57 {
58  return _gpu_scheduler;
59 }

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

◆ kernel_library()

CLKernelLibrary & kernel_library ( )

Definition at line 45 of file CLRuntimeContext.cpp.

46 {
47  return CLKernelLibrary::get();
48 }

References CLKernelLibrary::get().

◆ operator=()

CLRuntimeContext& operator= ( const CLRuntimeContext )
delete

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

◆ set_gpu_scheduler()

void set_gpu_scheduler ( CLScheduler scheduler)

CPU Scheduler setter.

Definition at line 50 of file CLRuntimeContext.cpp.

51 {
53  _gpu_scheduler = scheduler;
54 }

References ARM_COMPUTE_ERROR_ON_NULLPTR, and RuntimeContext::scheduler().


The documentation for this class was generated from the following files:
arm_compute::create_opencl_context_and_device
std::tuple< cl::Context, cl::Device, cl_int > create_opencl_context_and_device(CLBackendType cl_backend_type)
This function creates an OpenCL context and a device.
Definition: CLHelpers.cpp:126
arm_compute::CLKernelLibrary::init
void init(std::string kernel_path, cl::Context context, cl::Device device)
Initialises the kernel library.
Definition: CLKernelLibrary.cpp:56
arm_compute::CLKernelLibrary::get
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
Definition: CLKernelLibrary.cpp:39
ARM_COMPUTE_ERROR_ON_NULLPTR
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161
ARM_COMPUTE_ERROR_ON_MSG
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
Definition: Error.h:457
arm_compute::CLSymbols::load_default
bool load_default()
Load symbols from any of the default OpenCL library names.
Definition: OpenCL.cpp:53
arm_compute::RuntimeContext::scheduler
IScheduler * scheduler() override
Scheduler accessor.
Definition: RuntimeContext.cpp:42