52 return _gemm_heuristics;
57 _queue = std::move(queue);
78 _queue.enqueueMarker(&event);
84 if(_cl_tuner !=
nullptr)
92 return _is_initialised;
95 std::once_flag CLScheduler::_initialize_symbols;
113 const std::string cl_kernels_folder(
"./cl_kernels/");
114 cl::CommandQueue
queue = cl::CommandQueue(ctx, device);
116 init(ctx, queue, device, cl_tuner, gemm_h);
117 _cl_tuner = cl_tuner;
130 cl::CommandQueue
queue = cl::CommandQueue(ctx, dev);
132 init(ctx, queue, dev, cl_tuner, gemm_h);
136 _cl_tuner = cl_tuner;
141 _context = std::move(context);
148 _queue = std::move(queue);
150 _is_initialised =
true;
151 _cl_tuner = cl_tuner;
152 _gemm_heuristics = gemm_h;
153 _backend_type = cl_backend_type;
159 "The CLScheduler is not initialised yet! Please call the CLScheduler::get().default_init(), \ 160 or CLScheduler::get()::init() and CLKernelLibrary::get()::init() function before running functions!");
162 const bool inject_memory = !tensors.
empty();
165 if(_cl_tuner !=
nullptr)
171 inject_memory ? kernel.
run_op(tensors, kernel.
window(), _queue) : kernel.
run(kernel.
window(), _queue);
182 enqueue_common(kernel, pack, flush);
187 enqueue_common(kernel, tensors, flush);
void set_target(GPUTarget target)
Accessor to set target GPU to be used by the scheduler.
const Window & window() const
The maximum window the kernel can be executed on.
virtual void run(const Window &window, cl::CommandQueue &queue)
Enqueue the OpenCL kernel to process the given window on the passed OpenCL command queue...
static CLScheduler & get()
Access the scheduler singleton.
bool empty() const
Checks if pack is empty.
GPUTarget target() const
Get the target GPU.
void set_context(cl::Context context)
Accessor to set the CL context to be used by the scheduler.
void default_init_with_context(cl::Device &device, cl::Context &ctx, ICLTuner *cl_tuner=nullptr, CLGEMMHeuristicsHandle *gemm_h=nullptr)
Initialises the scheduler with context and device provided by the user.
void default_init(ICLTuner *cl_tuner=nullptr, CLGEMMHeuristicsHandle *gemm_h=nullptr, CLBackendType cl_backend_type=CLBackendType::Native)
Initialises the context and command queue used by the scheduler to default values and sets a default ...
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
virtual void tune_kernel_dynamic(ICLKernel &kernel)=0
Tune OpenCL kernel dynamically.
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
bool is_initialised() const
Manages all the OpenCL kernels compilation and caching, provides accessors for the OpenCL Context...
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.
void set_context(cl::Context context)
Sets the CL context used to create programs.
Common interface for all the OpenCL kernels.
CLGEMMHeuristicsHandle * gemm_heuristics() const
Accessor for the associated CLGEMMHeuristicsHandle.
Copyright (c) 2017-2021 Arm Limited.
Interface to enqueue OpenCL kernels and get/set the OpenCL CommandQueue and ICLTuner.
cl::Context & context()
Accessor for the associated CL context.
cl::Event enqueue_sync_event()
Enqueues a marker into the associated command queue and return the event.
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
void enqueue_op(ICLKernel &kernel, ITensorPack &tensors, bool flush=true)
Schedule the execution of the passed kernel if possible.
GPUTarget get_target_from_device(const cl::Device &device)
Helper function to get the GPU target from CL device.
void init(std::string kernel_path, cl::Context context, cl::Device device)
Initialises the kernel library.
void set_tuner(ICLTuner *tuner)
Accessor to set the CL tuner to be used by the scheduler.
cl::CommandQueue & queue()
Accessor for the associated CL command queue.
void enqueue(ICLKernel &kernel, bool flush=true)
Schedule the execution of the passed kernel if possible.
void set_queue(cl::CommandQueue queue)
Accessor to set the CL command queue to be used by the scheduler.
CLScheduler()
Constructor.
void sync()
Blocks until all commands in the associated command queue have finished.
Handle for loading and retrieving GEMM heuristics.
CLBackendType
List the possible OpenCL backends.
GPUTarget
Available GPU Targets.
virtual void tune_kernel_static(ICLKernel &kernel)=0
Tune OpenCL kernel statically.
Provides global access to a CL context and command queue.
Basic interface for tuning the OpenCL kernels.
void tune_kernel_static(ICLKernel &kernel)
Tunes OpenCL kernel.
virtual void run_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue)
Enqueue the OpenCL kernel to process the given window on the passed OpenCL command queue...
void init(cl::Context context, cl::CommandQueue queue, const cl::Device &device, ICLTuner *cl_tuner=nullptr, CLGEMMHeuristicsHandle *gemm_h=nullptr, CLBackendType cl_backend_type=CLBackendType::Native)
Initialises the context and command queue to be used by the scheduler.
bool opencl_is_available()
Check if OpenCL is available.
cl::Context & context()
Accessor for the associated CL context.