Skip to content

OCL: avoid unnecessary loading/initializing OpenCL subsystem#10180

Merged
opencv-pushbot merged 1 commit intoopencv:masterfrom
alalek:ocl_avoid_unnecessary_initialization
Nov 29, 2017
Merged

OCL: avoid unnecessary loading/initializing OpenCL subsystem#10180
opencv-pushbot merged 1 commit intoopencv:masterfrom
alalek:ocl_avoid_unnecessary_initialization

Conversation

@alalek
Copy link
Copy Markdown
Member

@alalek alalek commented Nov 28, 2017

If there are no OpenCL/UMat methods calls from application.

OpenCL subsystem is initialized:

  • haveOpenCL() is called from application
  • useOpenCL() is called from application
  • access to OpenCL allocator: UMat is created (empty UMat is ignored) or UMat <-> Mat conversions are called

Don't call OpenCL functions if OPENCV_OPENCL_RUNTIME=disabled
(independent from OpenCL linkage type)

If there are no OpenCL/UMat methods calls from application.

OpenCL subsystem is initialized:
- haveOpenCL() is called from application
- useOpenCL() is called from application
- access to OpenCL allocator: UMat is created (empty UMat is ignored) or UMat <-> Mat conversions are called

Don't call OpenCL functions if OPENCV_OPENCL_RUNTIME=disabled
(independent from OpenCL linkage type)
@vpisarev vpisarev self-assigned this Nov 29, 2017
@vpisarev
Copy link
Copy Markdown
Contributor

@alalek, looks like there are many changes where good old cv::ocl::useOpenCL() is replaced with cv::ocl::isOpenCLActivated(). Can we somehow provide better backward compatibility, i.e. adjust cv::ocl::useOpenCL() to suit the same purpose as cv::ocl::isOpenCLActivated()?

@alalek
Copy link
Copy Markdown
Member Author

alalek commented Nov 29, 2017

provide better backward compatibility

According the current semantic of useOpenCL() external applications should continue to use useOpenCL().

We just need to replace calls inside library itself only.

The difference is that isOpenCLActivated() doesn't try to load/initialize OpenCL runtime and returns 'false' in cases when OpenCL is available/allowed theoretically (but it is not loaded yet because application doesn't try to use UMat or other OpenCL calls - see description).

@vpisarev
Copy link
Copy Markdown
Contributor

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants