Generating cuda code at run time Need functions pointers

I was experimenting some, and came to try generating op-codes for GPUs in code.

I tried something simple:

[codebox]typedef int (*FuncPtr)();

FuncPtr test = (FuncPtr)malloc(1);

kernel (FuncPtr test){

(*test)();

}[/codebox]

This will unfortunately not compile because current hardware doesn’t support function pointer :(

Has anyone else experimented in this area? I’m curious about what you came up with.

Anyone know if function pointers will be supported on the Fermi arch?

In the fermi whitepaper:

"The implementation of a unified address space enables Fermi to support true C++ programs. In

C++, all variables and functions reside in objects which are passed via pointers. PTX 2.0 makes

it possible to use unified pointers to pass objects in any memory space, and Fermi’s hardware

address translation unit automatically maps pointer references to the correct memory space.

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."

Oh, nice. Thanks. I just tried compiling the program with the 3.0 beta and was somewhat disappointed to note that nvcc still won’t compile, but apparantly that just temporary then :) Nice.