OpenCL 1.1 specification says:
cl_int clEnqueueBarrier(cl_command_queue command_queue)
clEnqueueBarrier is a synchronization point that ensures that all queued commands in command_queue have finished execution before the next batch of commands can begin execution.
cl_int clFinish(cl_command_queue command_queue)
Blocks until all previously queued OpenCL commands in command_queue are issued to the associated device and have completed. clFinish does not return until all queued commands in command_queue have been processed and completed. clFinish is also a synchronization point.
Should have to do something with the in-order or out-of-order execution, but I can't see the difference. Are they ever needed if I have in-order execution? At the moment I do something like:
...
for(...){
clEnqueuNDRangeKernel(...);
clFlush(command_queue);
clFinish(command_queue);
}
...
on an Nvidia GPU. Any relevant comment is appreciated.