I am trying to perform a gpu vs. cpu evaluation of cv::remap() on my computer. To do so, I was trying to average the time over max_count calls.
for(int count = 0; count < max_count; count++)
{
auto t0 = std::chrono::high_resolution_clock::now();
cv::remap(cv_im_gpu, cv_im_gpu_remap, map1_gpu, map2_gpu, CV_INTER_LINEAR);
auto t1 = std::chrono::high_resolution_clock::now();
time += t1 - t0;
}
average_time = time / max_count;
What I observed was that the first iteration took around 100ms (1024x768 pixel input image) and supsequent iterations took 0ms. Do I have to perform some kind of snychronization or what is the reason for this behaviour? Calling the same function with cv::Mat instead of cv::UMat works just as expected and every iteration contributes roughly the same amount of time.
I am running the code on a windows 7 plattform with an ATI 360m graphics card using OpenCV 3.1.0.
Thanks.
I fixed this by adding a clWaitForEvents(...) in the OpenCV code. Thank you.