Compute Library
 22.11
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.

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

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 }
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
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
#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:51
void init(std::string kernel_path, cl::Context context, cl::Device device)
Initialises the kernel library.

◆ ~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.

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

57 {
58  return _gpu_scheduler;
59 }

◆ kernel_library()

CLKernelLibrary & kernel_library ( )

Definition at line 45 of file CLRuntimeContext.cpp.

References CLKernelLibrary::get().

46 {
47  return CLKernelLibrary::get();
48 }
static CLKernelLibrary & get()
Access the KernelLibrary singleton.

◆ 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.

References ARM_COMPUTE_ERROR_ON_NULLPTR, and RuntimeContext::scheduler().

51 {
53  _gpu_scheduler = scheduler;
54 }
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:157
IScheduler * scheduler() override
Scheduler accessor.

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