OpenCL TAPI mixed performance
I'm getting mixed results when using the OpenCL transparent API in terms of performance, so I wrote a simple test application for measuring the execution time of a few OpenCV methods. I'm testing the methods Sobel
, mean
and sum
with 5000x5000 matrices on CPU and GPU. The methods are called 10 times, with an additional call before starting the measurement as advised in another Q&A post. The code is found here
pastebin.com/wa0yvu30
The following results were obtained on the same machine, using a GTX 980 GPU with the latest drivers on both Linux and Windows, built with OpenCV 3.2:
OpenCL devices:
GeForce GTX 980
Ubuntu Windows
sobel on cpu: 224ms 234ms
sobel on gpu: 44ms 593ms
mean on cpu: 85ms 78ms
mean on gpu: 399ms 500ms
sum on cpu: 86ms 78ms
sum on gpu: 7ms 15ms
The CPU results are perfectly comparable. On Linux the GPU results from Sobel
and sum
are reasonable, I guess. The speedup is 5x to 10x. On Windows however the Sobel
performance is very poor and sum
is two times slower. What could be the reason for this?
Also note that on both systems the performance of mean
is very poor, which is why I'm currently using sum
as a workaround for now. Is this because the OpenCV functions must be explicitly optimized for OpenCL and mean
just didn't get the attention yet? If so, is the current state of OpenCV support documented somewhere or do we have to write tests like this?
Mean is just a heavy computational algorithm, which is known in literature, median can partially solve that for you. As to GPUs being more efficient in linux, that is due to the backend ... Windows is simply an OS that bloats everything up :D or somehow your GPU is incorrectly configured there...
The operations mean and sum should be almost identical (see CPU results for reference). The "backend" is the NVidia GPU driver, which provides almost identical performance on Windows and Linux (see popular benchmarks). I doubt that the GPU "is somehow configured incorrectly", but I'm open to suggestions.