How to set all functions to __device__ by default?

Hello Experts,

We would need to write a library of C++ classes that will be used on multiple platforms (x64, RISK, etc) including CUDA GPUs. Though very sophisticated with thousands of classes and methods, this library does not need to be fast at all, because on GPUs it is used only to initialize memory structures passed further to a small efficient parallel computing code.

All other compilers will allow us the syntax like:

int MyFunction() { return 0; }

but nvcc requires us to add the device keyword:

int device MyFunction() { return 0; }

Because the library contains only the device-side code with no any host-side code , I would expect a simple command-line option like:

nvcc --device MyFunction.cu

will make all functions inside MyFunction.cu file device by default, instead of host.

Of course there is an option to add a macro like:

[b]#ifdef NVCC
#define MyKeyword device
#else
#define MyKeyword
#endif

int MyKeyword MyFunction() { return 0; }
[/b]
but I really, really do not want to mess all the sources with any extra truly unnecessary macros.

Is there a way to tell nvcc to treat all functions as device by default?

Thanks!

There is no such option.

If you’d like to see a change to CUDA behavior, you may wish to file a bug. The instructions are linked in a sticky post at the top of this forum.