opencv - why it's so slow in data exchanging between CPU and GPU memory? -


it's first time using opencl on arm(cpu:qualcomm snapdragon msm8930, gpu:adreno(tm)305).

i find using opencl effective, data exchanging between cpu , gpu takes time, as can't imaging.

here 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 small image this, upload option takes 10ms, , download option takes 20ms! takes long.

can tell me situation normal? or goes wrong here?

thank in advance!

added:

my messuring method

clock_t start,end; start=clock(); mat_ocl.upload(mat); end = clock(); __android_log_print(android_log_info,"tag","upload time = %f s",(double)(end-start)/clocks_per_sec); 

actually, i'm not using opencl exactly, ocl module in opencv(although says equal). when reading opencv documents, find it's tell transform cv::mat cv::ocl::oclmat (which data uploading cpu gpu)to gpu calculation, haven't found memory mapping method in ocl module documents.

provide exact measuring methods , results.

from experience of opencl development under arm platforms (not qcom, though), can shouldn't expect of read-write operations. memory bus 64bit, plus ddr3 isn't fast.

use shared memory advantage - go mapping/unmapping instead of read/write.

p. s. actual operation time measured, using cl_event profiling:

cl_ulong gettimenanoseconds(cl_event event) {     cl_ulong start = 0, end = 0;      cl_int ret = clwaitforevents(1, &event);     if (ret != cl_success)         throw(ret);      ret = clgeteventprofilinginfo(               event,               cl_profiling_command_start,               sizeof(cl_ulong),               &start,               null);     if (ret != cl_success)         throw(ret);      ret = clgeteventprofilinginfo(               event,               cl_profiling_command_end,               sizeof(cl_ulong),               &end,               null);     if (ret != cl_success)         throw(ret);      return (end - start); } 

Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -