OpenCV  4.5.5-dev
Open Source Computer Vision
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
cv::ocl::OpenCLExecutionContext Class Reference

#include <opencv2/core/ocl.hpp>

Public Member Functions

 OpenCLExecutionContext ()=default
 
 OpenCLExecutionContext (const OpenCLExecutionContext &)=default
 
 OpenCLExecutionContext (OpenCLExecutionContext &&)=default
 
 ~OpenCLExecutionContext ()=default
 
void bind () const
 
OpenCLExecutionContext cloneWithNewQueue (const ocl::Queue &q) const
 
OpenCLExecutionContext cloneWithNewQueue () const
 
bool empty () const
 
ContextgetContext () const
 
DevicegetDevice () const
 
QueuegetQueue () const
 
OpenCLExecutionContextoperator= (const OpenCLExecutionContext &)=default
 
OpenCLExecutionContextoperator= (OpenCLExecutionContext &&)=default
 
void release ()
 
void setUseOpenCL (bool flag)
 
bool useOpenCL () const
 

Static Public Member Functions

static OpenCLExecutionContext create (const std::string &platformName, void *platformID, void *context, void *deviceID)
 Creates OpenCL execution context OpenCV will check if available OpenCL platform has platformName name, then assign context to OpenCV. The deviceID device will be used as target device and a new command queue will be created. More...
 
static OpenCLExecutionContext create (const Context &context, const Device &device, const ocl::Queue &queue)
 Creates OpenCL execution context. More...
 
static OpenCLExecutionContext create (const Context &context, const Device &device)
 
static OpenCLExecutionContextgetCurrent ()
 
static OpenCLExecutionContextgetCurrentRef ()
 

Protected Attributes

std::shared_ptr< Impl > p
 

Constructor & Destructor Documentation

◆ OpenCLExecutionContext() [1/3]

cv::ocl::OpenCLExecutionContext::OpenCLExecutionContext ( )
default

◆ ~OpenCLExecutionContext()

cv::ocl::OpenCLExecutionContext::~OpenCLExecutionContext ( )
default

◆ OpenCLExecutionContext() [2/3]

cv::ocl::OpenCLExecutionContext::OpenCLExecutionContext ( const OpenCLExecutionContext )
default

◆ OpenCLExecutionContext() [3/3]

cv::ocl::OpenCLExecutionContext::OpenCLExecutionContext ( OpenCLExecutionContext &&  )
default

Member Function Documentation

◆ bind()

void cv::ocl::OpenCLExecutionContext::bind ( ) const

Bind this OpenCL execution context to current thread.

Context can't be empty.

Note
clFinish is not called for queue of previous execution context

◆ cloneWithNewQueue() [1/2]

OpenCLExecutionContext cv::ocl::OpenCLExecutionContext::cloneWithNewQueue ( const ocl::Queue q) const

Creates new execution context with same OpenCV context and device

Parameters
qOpenCL queue

◆ cloneWithNewQueue() [2/2]

OpenCLExecutionContext cv::ocl::OpenCLExecutionContext::cloneWithNewQueue ( ) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ create() [1/3]

static OpenCLExecutionContext cv::ocl::OpenCLExecutionContext::create ( const std::string &  platformName,
void *  platformID,
void *  context,
void *  deviceID 
)
static

Creates OpenCL execution context OpenCV will check if available OpenCL platform has platformName name, then assign context to OpenCV. The deviceID device will be used as target device and a new command queue will be created.

Note
On success, ownership of one reference of the context and device is taken. The caller should additionally call clRetainContext and/or clRetainDevice to increase the reference count if it wishes to continue using them.
Parameters
platformNamename of OpenCL platform to attach, this string is used to check if platform is available to OpenCV at runtime
platformIDID of platform attached context was created for (cl_platform_id)
contextOpenCL context to be attached to OpenCV (cl_context)
deviceIDOpenCL device (cl_device_id)

◆ create() [2/3]

static OpenCLExecutionContext cv::ocl::OpenCLExecutionContext::create ( const Context context,
const Device device,
const ocl::Queue queue 
)
static

Creates OpenCL execution context.

Parameters
contextnon-empty OpenCL context
devicenon-empty OpenCL device (must be a part of context)
queuenon-empty OpenCL queue for provided context and device

◆ create() [3/3]

static OpenCLExecutionContext cv::ocl::OpenCLExecutionContext::create ( const Context context,
const Device device 
)
static

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ empty()

bool cv::ocl::OpenCLExecutionContext::empty ( ) const
inline

◆ getContext()

Context& cv::ocl::OpenCLExecutionContext::getContext ( ) const

Get associated ocl::Context

◆ getCurrent()

static OpenCLExecutionContext& cv::ocl::OpenCLExecutionContext::getCurrent ( )
static

Get OpenCL execution context of current thread.

Initialize OpenCL execution context if it is empty

  • create new
  • reuse context of the main thread (threadID = 0)

◆ getCurrentRef()

static OpenCLExecutionContext& cv::ocl::OpenCLExecutionContext::getCurrentRef ( )
static

Get OpenCL execution context of current thread (can be empty)

◆ getDevice()

Device& cv::ocl::OpenCLExecutionContext::getDevice ( ) const

Get the single default associated ocl::Device

◆ getQueue()

Queue& cv::ocl::OpenCLExecutionContext::getQueue ( ) const

Get the single ocl::Queue that is associated with the ocl::Context and the single default ocl::Device

◆ operator=() [1/2]

OpenCLExecutionContext& cv::ocl::OpenCLExecutionContext::operator= ( const OpenCLExecutionContext )
default

◆ operator=() [2/2]

OpenCLExecutionContext& cv::ocl::OpenCLExecutionContext::operator= ( OpenCLExecutionContext &&  )
default

◆ release()

void cv::ocl::OpenCLExecutionContext::release ( )

◆ setUseOpenCL()

void cv::ocl::OpenCLExecutionContext::setUseOpenCL ( bool  flag)

◆ useOpenCL()

bool cv::ocl::OpenCLExecutionContext::useOpenCL ( ) const

Member Data Documentation

◆ p

std::shared_ptr<Impl> cv::ocl::OpenCLExecutionContext::p
protected

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