Reputation: 9092
In OpenCL I can register a callback function to be called when an event has completed on the GPU using clSetEventCallback
.
But I get the cl_event
only immediatly after enqueuing the command on the queue. So there is a small possibility that at the time when clSetEventCallback
is called on the CPU, the event has already completed on the GPU.
If clSetEventCallback
is called on an event that is already completed, will the OpenCL driver call the callback anyways?
Upvotes: 0
Views: 689
Reputation: 699
OpenCL specification says that:
All callbacks registered for an event object must be called. All enqueued callbacks shall be called before the event object is destroyed. Callbacks must return promptly. The behavior of calling expensive system routines, OpenCL API calls to create contexts or command-queues, or blocking OpenCL operations from the following list below, in a callback is undefined.
It is a bit vague, but I think you can assume that a callback will be called even if an event is already completed by the time you call clSetEventCallback
. Otherwise it makes user's code unnecessary complicated.
Upvotes: 1