Compute Library
 23.08
ICLSimpleFunction Class Reference

Basic interface for functions which have a single OpenCL kernel. More...

#include <ICLSimpleFunction.h>

Collaboration diagram for ICLSimpleFunction:
[legend]

Public Member Functions

 ICLSimpleFunction (CLRuntimeContext *ctx=nullptr)
 Constructor. More...
 
 ICLSimpleFunction (const ICLSimpleFunction &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 ICLSimpleFunction (ICLSimpleFunction &&)=default
 Default move constructor. More...
 
ICLSimpleFunctionoperator= (const ICLSimpleFunction &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
ICLSimpleFunctionoperator= (ICLSimpleFunction &&)=default
 Default move assignment operator. More...
 
 ~ICLSimpleFunction ()
 Default destructor. More...
 
void run () override final
 Run the kernels contained in the function. More...
 
- Public Member Functions inherited from IFunction
virtual ~IFunction ()=default
 Destructor. More...
 
virtual void prepare ()
 Prepare the function for executing. More...
 

Detailed Description

Basic interface for functions which have a single OpenCL kernel.

Definition at line 39 of file ICLSimpleFunction.h.

Constructor & Destructor Documentation

◆ ICLSimpleFunction() [1/3]

ICLSimpleFunction ( CLRuntimeContext ctx = nullptr)

Constructor.

Parameters
[in]ctxRuntime context to be used by the function

Definition at line 34 of file ICLSimpleFunction.cpp.

35  : _kernel(),
36  _border_handler(std::make_unique<CLFillBorderKernel>()),
37  _ctx(ctx)
38 {
39 }

◆ ICLSimpleFunction() [2/3]

ICLSimpleFunction ( const ICLSimpleFunction )
delete

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

◆ ICLSimpleFunction() [3/3]

Default move constructor.

◆ ~ICLSimpleFunction()

~ICLSimpleFunction ( )
default

Default destructor.

Member Function Documentation

◆ operator=() [1/2]

ICLSimpleFunction& operator= ( const ICLSimpleFunction )
delete

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

◆ operator=() [2/2]

ICLSimpleFunction& operator= ( ICLSimpleFunction &&  )
default

Default move assignment operator.

◆ run()

void run ( )
finaloverridevirtual

Run the kernels contained in the function.

For CPU kernels:

  • Multi-threading is used for the kernels which are parallelisable.
  • By default std::thread::hardware_concurrency() threads are used.
Note
CPPScheduler::set_num_threads() can be used to manually set the number of threads

For OpenCL kernels:

  • All the kernels are enqueued on the queue associated with CLScheduler.
  • The queue is then flushed.
Note
The function will not block until the kernels are executed. It is the user's responsibility to wait.
Will call prepare() on first run if hasn't been done

Implements IFunction.

Definition at line 43 of file ICLSimpleFunction.cpp.

44 {
45  ARM_COMPUTE_ERROR_ON_MSG(!_kernel, "The child class didn't set the CL kernel or function isn't configured");
46  schedule_kernel_on_ctx(_ctx, _border_handler.get(), false);
47  schedule_kernel_on_ctx(_ctx, _kernel.get());
48 }

References ARM_COMPUTE_ERROR_ON_MSG, and arm_compute::schedule_kernel_on_ctx().

Referenced by CLFFTConvolutionLayer::prepare(), CLDirectDeconvolutionLayer::prepare(), and CLLSTMLayer::run().


The documentation for this class was generated from the following files:
arm_compute::schedule_kernel_on_ctx
void schedule_kernel_on_ctx(CLRuntimeContext *ctx, ICLKernel *kernel, bool flush=true)
Schedules a kernel using the context if not nullptr else uses the legacy scheduling flow.
Definition: CLHelpers.cpp:143
ARM_COMPUTE_ERROR_ON_MSG
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
Definition: Error.h:457