Why it's so slow in data exchanging between CPU and GPU memory?
It's my first time using openCL on ARM(CPU:Qualcomm Snapdragon MSM8930, GPU:Adreno(TM)305).
I find using openCL is really very effective, but data exchanging between CPU and GPU takes too much time, as much as I can't imaging.
Here is an example:
cv::Mat mat(640,480,CV_8UC3,cv::Scalar(0,0,0));
cv::ocl::oclMat mat_ocl;
//cpu->gpu
mat_ocl.upload(mat);
//gpu->cpu
mat = (cv::Mat)mat_ocl;
Just a small image like this, the upload option takes 10ms, and download option takes 20ms! That takes too long.
Can anyone could tell me is this situation normal? Or something goes wrong here?
Thank you in advance!
Did you test your code in a loop? Normally it takes some time to allocate memory on GPU. Once this is done it should be faster next time. So you should avoid reallocate the memory each time. I'm using OpenCV3 so I can't give you more help. Isn't there a funciton
mat_ocl.download(mat)
to transfer data back to CPU?Yes, I test the time cost in loops. so the time is actually average time. And I found the 1st uploading costs almost the same time with the 2nd or 3rd uploading, I dont know why. "mat_ocl.download(mat) " is equal to "mat = (Mat)mat_ocl", they are the same operation.
@rossi_lhf: I see you struggled with OpenCL as reported here http://answers.opencv.org/question/25... but you already seem to be up and running here. May I ask you what was the problem and how did you solve it? I would like to get the Embedded profile running...