Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed and updated OpenCL-VA interoperability #18410

Merged
merged 1 commit into from Sep 25, 2020

Conversation

mshabunin
Copy link
Contributor

@mshabunin mshabunin commented Sep 24, 2020

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
@@ -137,7 +141,13 @@ Context& initializeContextFromVA(VADisplay display, bool tryInterop)
contextInitialized = true;

cl_platform_id platform = platforms[found];
std::string platformName = PlatformInfo(platform).name();
Copy link
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
Copy link
Contributor

Odianosen25 commented Sep 26, 2020

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
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
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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