I am writing a OpenCL program in which multiple kernels are being called on multiple devices. After I have enqueued all of the kernels I would like to wait until any of them has finished and then enqueue work for that device afterwords.
For instance, I have devices A and B and each of them have a kernel. If A finishes first, I want to enqueue a new kernel in it after doing some work. If B finishes first I want to enqueue a new kernel for it after doing some work. I'm looking for something like a clWaitForAnyEvent
which will return after any event passed in has finished.
Looking at the spec, I see a clWaitForEvents
method, but it seems that it will wait for all of the event to finish before continuing, and I want to continue after one event (and need to know which event finished).
The options I can think of right now are:
Busy-wait using
clGetEventInfo
to test for event completion.Multi-thread having one thread for each event (will only need a few threads, but am using the CPU as one of the devices)
Missed something in the specification and there is actually a method that does this for me.
Any suggestions of how to proceed or something that I am missing?
Thanks!