Altera_Forum
Honored Contributor
12 years agoclSetEventCallback substitute
Hi,
I am trying to write a program where I get an asynchronous callback once a kernel has finished and I am stuck. May be a trivial thing (or not?) but I am running out of ideas. In OpenCL 1.1 and higher, one can call clSetEventCallback(), passing it an event and a user function that gets called once the associated kernel is done. However, Altera's OpenCL api is 1.0 and this function apparently doesn't exist. A second way I thought of is to call clEnqueueNativeKernel(), passing it a command ququeue and a user "kernel" function. As I understood it, a native kernel is just a normal C/C++ function that should get executed on the CPU. So what I had expected is that once it's the enqueued native kernel's time in the Queue, the driver would just call the function. However, this seems to be the wrong assumption because I get a "CL_INVALID_OPERATION" error and clGetDeviceInfo tells me that the FPGA cannot execute a native kernel (the CL_EXEC_NATIVE_KERNEL flag is 0 when asking for the execution capabilities). So one workaround would be to install the intel opencl sdk and open a second platform/device, create a queue there and order the kernels cross-platform through their event objects. But a) this really seems overkill and b) I am not even sure if that is supposed to work. So my question: is there any straight forward way how I can tell the OpenCL driver to call a C/C++ callback function on the host once some (non native) kernel finished? Thanks, Christoph