If somebody tries to use clEnquyeReadBuiffer immediately after Enqueuing kernel , will not this be a bad since, the copying operation will start immediately after the kernel just is enqueued, and not executed?
clEnqueueNDRangeKernel(
queue,
kernel,
1,
NULL,
globalws,
localws,
0,
NULL,
NULL);
//this will start immediately, since above call is async
clEnqueueReadBuffer(
queue,
bufferOut,
CL_FALSE,
0,
10 * sizeof(int),
out,
0,
0,
0);
clFinish(queue);
In the above although because of clFinish(queue), it is guaranteed that host will see the data only after the complete data is copied, but how is that guaranteeing that data it self is correct, (since the data copying was started immediately after enqueuing of kernel). Is there anything wrong in my understanding?