Skip to content

Fixed and updated OpenCL-VA interoperability - #18410

Merged
opencv-pushbot merged 1 commit into
opencv:masterfrom
mshabunin:fix-va-build
Sep 25, 2020
Merged

Fixed and updated OpenCL-VA interoperability#18410
opencv-pushbot merged 1 commit into
opencv:masterfrom
mshabunin:fix-va-build

Conversation

@mshabunin

@mshabunin mshabunin commented Sep 24, 2020

Copy link
Copy Markdown
Contributor

resolves #18307
supersedes #18318

  • added cl_va_api_media_sharing_intel.h to OpenCL headers
  • added ability to build with old and new header name (did not check with old file though)
  • simplified WITH_VA_INTEL handling
  • updated documentation
  • use clGePlatformInfo directly to read device name

How to enable the feature:

# prerequisite: libva-dev
cmake -DWITH_VA=ON -DWITH_VA_INTEL=ON ../opencv

Checked in --privileged Ubuntu 20.04 container with system libva2 and OpenCL runtime 20.37.17906:

# ../build/bin/example_va_intel_va_intel_interop ../opencv/samples/data/lena.jpg a b
libva info: VA-API version 1.7.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_7
libva info: va_openDriver() returns 0
VA display opened successfully
Interop ON : processing time, msec: 1.26111

Note: device name reading have been replaced due to an error with PlatformInfo constructor

Thread 1 "example_va_inte" received signal SIGSEGV, Segmentation fault.
0x00007ffff2fce128 in clGetDeviceIDs () from /lib/x86_64-linux-gnu/libOpenCL.so.1
(gdb) bt
#0  0x00007ffff2fce128 in clGetDeviceIDs () from /lib/x86_64-linux-gnu/libOpenCL.so.1
#1  0x00007ffff4649aff in OPENCL_FN_clGetDeviceIDs_switch_fn (p1=0x7ffff2fa18e0, p2=4294967295, p3=0, p4=0x0,
    p5=0x7fffffffe114)
    at /opencv/modules/core/src/opencl/runtime/autogenerated/opencl_core_impl.hpp:411
#2  0x00007ffff462bbd8 in cv::ocl::getDevices (devices=std::vector of length 0, capacity 0, platform=0x7ffff2fa18e0)
    at /opencv/modules/core/src/ocl.cpp:6521
#3  0x00007ffff462be21 in cv::ocl::PlatformInfo::Impl::Impl (this=0x55555644c1c0, id=0x555555902860)
    at /opencv/modules/core/src/ocl.cpp:6544
#4  0x00007ffff462c029 in cv::ocl::PlatformInfo::PlatformInfo (this=0x7fffffffe220, platform_id=0x555555902860)
    at /opencv/modules/core/src/ocl.cpp:6567
...

@mshabunin mshabunin added the backport is needed Label for maintainers. Authors of PR can ignore this label Sep 24, 2020
contextInitialized = true;

cl_platform_id platform = platforms[found];
std::string platformName = PlatformInfo(platform).name();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please replace platform => &platform.

With verbose replacements it is better to keep original code (to avoid replacement back):

#if 0  // code doesn't works due to ...
   original code
#else
  ... verbose code ...
#endif

@opencv-pushbot
opencv-pushbot merged commit c32e349 into opencv:master Sep 25, 2020
@Odianosen25

Odianosen25 commented Sep 26, 2020

Copy link
Copy Markdown
Contributor

Thanks for this @mshabunin, still couldn't figure out how to fix it.

Please also is there anyway to support if someone has OpenCL 2.2 installed? I think the the only issue was the version was not specified somewhere or something.

You guys are the best

@mshabunin

Copy link
Copy Markdown
Contributor Author

@Odianosen25 , OpenCL 2.2 should be backward compatible with 1.x. For example, I tested it with 2.1 runtime.

@Odianosen25

Copy link
Copy Markdown
Contributor

@mshabunin,

Thanks for the response, and yes it actually is. Just gives out a warning

In file included from /usr/include/CL/cl.h:20,
                 from /tmp/opencv-4.4.0/modules/core/include/opencv2/core/opencl/runtime/autogenerated/opencl_core.hpp:102,
                 from /tmp/opencv-4.4.0/modules/core/include/opencv2/core/opencl/runtime/opencl_core.hpp:68,
                 from /tmp/opencv-4.4.0/modules/core/src/dxt.cpp:44:
/usr/include/CL/cl_version.h:22:104: note: #pragma message: cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 220 (OpenCL 2.2)
   22 | #pragma message("cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 220 (OpenCL 2.2)")
      |                                                                                                        ^

But its no show stopper.

Kind regards

@mshabunin
mshabunin deleted the fix-va-build branch July 10, 2023 08:14
SavyaSanchi-Sharma pushed a commit to SavyaSanchi-Sharma/opencv that referenced this pull request Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot build OpenCV with Intel VA, asking for "CL/va_ext.h" file

4 participants