Hello, I'm using Odroid-XU3.And I installed Opencv 3.0.0-rc1 on odroid-xu3 ubuntu 14.04.
I have two question.
First, In procedure installing opencv, there's no opencl sdk directory option.I just check 'WITH_OPENCL' and etc.But, Using OpenCL function is successful. Why??????
Second, I tested OpenCV with OpenCL.I referenced the website http://www.learnopencv.com/opencv-tra...However, With OpenCL running time is 400ms and without OpenCL running time is 152ms.I want to solve the weird problem.
Please help meThank you
Hi zz5414,
I'm not so sure about your first question, but perhaps someone else on here can help with that.
Regarding the performance you're seeing with OpenCL enabled...
The OpenCL layer in OpenCV has been developed with desktop GPUs in mind. And indeed on desktops you would expect to see a performance improvement when using CL linked to a suitable GPU. As you probably know however, OpenCL is not "performance portable". What is optimal for one platform is not necessarily optimal for another, and in fact in some circumstances where particular architectural features of a particular GPU are targeted you can find performance on other architectures quite a bit lower. In theory, you could optimise the kernels being used more for Mali, but unfortunately this is only part of the problem.
A fundamental aspect of OpenCV is that it's based on a synchronous architecture. This means that you make a call into an OpenCV API and you wait for the result. When you're using the OpenCL layer this means that you have sync points between the CPU and GPU before and after each call. Moving between processors in this way is always going to be highly sub-optimal. A much better approach - and indeed a necessary one if you want to get the best out of a mobile architecture - is to have a graph framework where you can queue a collection of work for the GPU that can then work independently until it has finished. Whilst the jobs run there is no need for any interaction with the CPU. This also makes it possible to pipeline the workload amongst all available processors.
So I'm afraid it's not a straightforward fix. This is a known issue with OpenCV and it's true generally across all mobile platforms.
One thing you should look into is enabling NEON extensions with OpenCV. I believe there is a switch in the build system to do this. That can yield some measure of better performance.
If you're interested in looking at OpenCL on Mali - and it's certainly possible to create you're own non-synchronous chain of kernels running very optimally - then I'd recommend looking at the malideveloper site here: http://malideveloper.arm.com/develop-for-mali/opencl-renderscript-tutorials/
I appreciate that doesn't solve your problem, but I hope it's useful nevertheless.
Tim
Regarding your first question, can you give more information about what you mean?
You say you enable OpenCL when building OpenCV... and that it builds fine and runs... and that it indeed runs using OpenCL.
Can I ask what your question actually is here, if the above is true?
Or are you asking more generally about the OpenCL SDK itself? Please note that the SDK we provide is a collection of sample codes that you can run on an already OpenCL enabled platform. It is not a 'driver SDK' and is not needed to get the platform working with OpenCL.
Please let me know if that didn't answer your question.
Kind Regards,
Michael McGeagh
Thanks to your answer!
In addition to my first question, when compile opencv3 using cmake, result is below.
There's no OPENCL_ROOT_DIR. (I can't select Mali OpenCL SDK library to use opencv)
But, the function for example ocl::setUseOpenCL(true) is perpectly running.
However, when ocl::setUseOpenCL(true) is executed, cvtColor that opencv function is slower than normal.
I'm Sorry due to a lack of English proficiency.
Once again, Thank you for your answer.
Hi,
Looks like everything is working as expected: you don't need to link against the Mali OpenCL SDK to get OpenCL support in OpenCV.
Like Tim explained, the reason it's slower is that the API is synchronous which is not suitable for GPUs. Moreover the OpenCL kernels have been written for a scalar architecture whereas Mali is vector based.
I'll implement OpenCL function needed.
Thanks!
HeeJin Park