Is it possible to call a function in CUDA through a traditional C-like function pointer?
Function pointers are not supported on current hardware.
Note that host function pointers should work (since it’s just C code). So you can definitely execute a host function through a pointer, and you might be able to execute a global function via a pointer (haven’t tried it – might require you to use the driver API).
But device function pointers are not supported. Currently all device functions are inlined.
But a global function is not going to run on the device right?
Global functions cross the host/device gap. You initiate them from the host, but they run on the device.
Oh well I would need to call this function from the device so I guess that would not serve my purpose.
So I’m trying to breath new life into this this thread by asking what’s gonna happen on this front with the upcoming architecture?
Will Fermi-cards support function pointers?
From the whitepaper:
"Fermi and the PTX 2.0 ISA also add support for C++ virtual functions, function pointers, and
â€˜newâ€™ and â€˜deleteâ€™ operators for dynamic object allocation and de-allocation. C++ exception
handling operations â€˜tryâ€™ and â€˜catchâ€™ are also supported."