could OpenACC accelerator OpenCV program

I have a question whether OpenACC could accelerator OpenCV program . If yes,do you have any code sample? what I should do, please kindly advise me.

Thanks a lot

Hi Teslalady,

I’ve never used OpenCV but it looks to be a C++ template library. Do you want to use OpenACC to accelerate the OpenCV library code? or are you asking if a user program that uses OpenACC could also use OpenCV?

For C++ in general, right now you can only accelerate “C-like” code. However, we are in the processes of allow more C++ style-constucts to be used. Things like auto adding the “routine” directive on C++ class member routines and allowing access to the “this” pointer. However, there’s still a general problem with deep-copies that yet to be solved. Hence, if you want to add OpenACC into OpenCV, I’d wait for the 14.4 release to try.

As for using OpenACC in user code, that should fine now, but you wouldn’t be able to put any OpenCV constructs directly into a compute region or a data clause. Though again, this is a general restriction we have with C++, not something specific to OpenCV.

  • Mat

hi , i am using PGI 14.3 , and i have a program uses OpenCv function , and i want to accelerate my program usign OpenAcc. but i donot know how to do . becides, i also have other program named testmain , and testmain have files [testmain.cpp test.h test.cpp], and how to Compile in PGI? I hope to get your answer

Hi longzhixi123,

As I indicated above, I have not worked with OpenCV before so don’t know the specifics about using it. However, from what I can tell it appears that a user would just include the OpenCV header files and then use it like any other class. Hence, the first thing to do is just compile your test program with PGI’s C++ compiler, pgcpp. If you are using Linux, it may be preferable to use our GNU Compatible compiler, pgc++.

Next, I would then try getting a feel of how OpenACC works independent of using it in the context of OpenCV. Admittedly, C++ examples are lagging, but you can find a wealth of information about OpenACC on the internet or start by reviewing the links from this page:

Next, you can begin adding OpenACC to your test program. However, you wont be able to directly use any class member data object in an OpenACC data clause or compute region, at least not yet. This support is still in development.

Instead, you will need to translate this data to a local variable (using a local pointer often works provided you can access the class’ data member’s directly). Effectively, the code you’re accelerating needs to be “C-like”.

  • Mat