As an aside, you might simplify your functors and avoid the passing of useless arguments by using some temporary functor instantiation, like
template<typename Fex>
__global__ void bob()
{
struct bog Joe;
struct bog *john;
john = &Joe;
john->bilbo = 0;
Fex()(john->bilbo);
}
int main (int argc, char * const argv[])
{
printf("Hello\n");
bob<Fex><<<1,1>>>();
return 0;
}
I use functors like this a lot. Static member functions are even more useful… the method name helps you document. And you can define as many methods as you like, forming a packaged suite of tools, not just one.
I just installed 2.3 on Mac OS X, and now, with the same code I posted originally, I’m getting the error: “/tmp/tmpxft_00001608_00000000-1_functortest2.cudafe1.stub.c:16: error: ‘MyBob’ is not a template type”
I’m using the command “nvcc functortest2.cu -arch=sm_13 -o test” to compile. Can you give details on how exactly you got it to compile under 2.3? (i.e. platform, command line command, etc)
Also, I think you mentioned the dummy variables bit before in another thread. It’s a very good idea and I’ll most likely use it in the future. For this program that I’m working on though (converting the LSODA stiff/non-stiff ODE solver to run on CUDA), I think it’s better to pass the dummy variables anyway, since it keeps the interface closer to the original fortran, and makes it a little bit easier to keep track of exactly what’s going on. So for the sake of easy reading, it’s more useful this way. At THIS time, anyway. :D In the future, once the conversion is functionally complete, and I start going back to clean it up and optimize it, I may sneak that version of things in.