Skip to content
Advertisement

Covariance matrix with opencl and opencv

I recently start to learn opencl and how to create kernel for OpenCV as well. I am still working with the basics.

I need to implement an opencl kernel for calculate the covariance matrix. This function don’t have any opencl kernel already implemented by opencv’s fundation.

Technically what I want to process is that :

JavaScript

I found OpenCV’s fundation have implemented an OpenCL kernel for both gemm and the function transpose.

So I tried to derivate an implementation from an exemple directly from OpenCV’s source.

I wrote this :

ocl.h :

JavaScript

ocl.cpp :

JavaScript

covarianceMatrix.cl :

JavaScript

If the size of the matrix is fewer than 6 is work perfectly :). Otherwise … not really. It can be check with this code :

JavaScript

I am still new in OpenCL and I am interrested to know what I did wrong.

Does someone already implemented an OpenCL kernel for process the covariance matrix with OpenCV ?

Thank in advance for any help.

Advertisement

Answer

I resign myself to write this code :

JavaScript

I suspect the GPU memory is updated everytime a function is call, that make that code slower rather than if it has been written in one Kernel. But it work efficiently.

I am still interested by another solution if maybe someone have an idea.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement