Can someone explain the working of the asynchronous calls in OpenCL..? Say I have clEnqueueWriteBuffer() with no wait for events, so this is an asynch call. If I havean NDRangeKernel() after this.. How will the kernel know that the buffer has been written by clEnqueueWriteBuffer and that it can start execution..?
Also after the kernel execution if there is clEnqueueReadBuffer, how will the host come to know that the kernel has finished execution and that it can read the results?
Again if there isclEnqueueReadBuffer after the NDRangeKernel, How does the clEnqueueReadBuffer come to know that the NDRangeKernel has completed? (Assume that I have not generated any event in the NDRangeKernel so as to specify inclEnqueueReadBuffer to wait for)
If you make a non-blocking clEnqueueWriteBuffer() call and do not specify the event, it won't be possible for your application to query the status of the command. You will not know when or if the command was executed.
You have to understand that the enque calls put the commands in the queue and not necessarily execute when you call the API.You canmake sure you have the buffer ready to be read bymaking a blocking call or using an event to query the status. Or your commands in the command queue will be submitted when you call clFlush() or clFinish(). Hope that's clear.
if your queue is in-order (which is default), commands submited to the queue will be executed one by one.
But in order to wait for the results (e.g. for some final clEnqueueRead) you would need to wait for completition of the submitted sequence: remember that func call (without explicit blocking) means just placing the call in the queue. So if you don't have some event to wait on, the only option would be clFinish.