Is there a way to use C style function pointers in OpenCL?
In other words, I'd like to fill out a OpenCL struct with several values, as well as pointers to a OpenCL function. I'm not talking about going from a CPU function to a GPU function, I'm talking about going from a GPU function to a GPU function.
Is this possible?
--- EDIT ---
If not, it there a way around this? In CUDA we have object inheritance, and in 4.0 we even have virtual functions. About the only way I can find to implement a runtime dispatch like this is to resort to if statements, and that will get ugly really fast.
From the OpenCL 1.1 specification:
Section 6.8 (Restrictions) (a):
The usual work around I use for this is with macros. Evil, but currently inescapable. So I typically end up with something like:
I then either inject this into the kernel at compilation time or pass it as an argument to the OpenCL compiler. It's not quite runtime in the usual sense, but it can be runtime from the Host's perspective still, even if not the device.
AMD has future plans for hardware support for this, so there may be future extensions for them.