clWaitForFirstEvent workaround

Hello, I am posting to inform everyone I published a hopefully stand-alone class to implement some sort of wait-till-first-event functionality for OpenCL.

Let me be clear: I’m not very sold on it myself. In particular, there’s no way to cancel a wait even though those could be trivially added.

This sure needs some additional work but since I have little experience in OpenCL (or mostly the context in which CL is used, not to mention I have access to a single machine) I would like to hear some opinions on what you would need most.

At the end of the day, I couldn’t figure out a way to use clWaitForEvents reliably, nor a way to set up a callback system without relying on polling. The code is C++ (11), RAII style with exceptions. It uses multiple threads and mutex+condition variable synchronization. It has been tested to work as expected on my system.

I’d say the only slightly surprising thing is the use of a ScopedFuncCall object. Those are exactly what you think they are: a function call to be performed when the object goes out of scope. Fairly dangerous for nontrivial operations but they allow me to avoid catch() blocks which I consider ugly.

Opinions/suggestions welcome.

add another event to the list that is only triggered when you want to cancel a wait (or add en event to the list of events to wait on asynchronously)

That does not need an extra event to be added.
Shall an event removal degrade the list of waited events to empty, do you think it is necessary to have the event return a result code or just forget about it completely?

[b]Updating one month later, in an attempt to spur some more discussion.

[/b]I have deployed the above linked code.
Feedback from performance users seems to suggest the above method is considerably slower than a native call. Unsurprisingly.

There are a few ways I could manage this issue but the core thing is I cannot envision a proper way to sleep until one event triggers. So far I’m considering assigning a thread to each device or providing pipelined work.

Opinions and suggestions welcome.