"computed goto" or pointer list to subroutines

I’d like to build a list of subroutines of the form

[codebox]

device psi_000(…)

device psi_001(…)

:

:

__device__psi_968(…)

[/codebox]

and have different threads call specific subroutines based on their block number and thread ID. In C I’d just do this:

[codebox]double (*function_table[969])(double, double, double)={NULL};

void Init_function_table()

{

    function_table[0] = &psi_000;

    function_table[1] = &psi_001;

    function_table[2] = &psi_002;

:

:

    function_table[968] = &psi_968;

}

[/codebox]

How do I do the same thing with a kernel? Can nvcc build the list of addresses so I can put it in either global or constant memory before invoking the kernel?

Thanks for any ideas.

that’s not possible. there is no way of calling a function in the current PTX ISA, all the device functions get inlined during compilation anyway… the only thing you can do is to use a switch statement to execute different functions based on index.

OK, glad I asked!

I will have to think about alternative ways to skin this cat.