Check for Device Emulation

I am writing some code, and for the sake of debug, I want to be able to printf things from within kernels. However, I really don’t want to have to go through the code and add the statements when I need to debug and remove them when I release. Is there any way I can check a macro or something and do something on the lines of #ifdef DEVICE_EMULATION"?

Of course you can :)

Use ifdef whereever you want

As noted in the programming guide, the preprocessor macro DEVICE_EMULATION is automatically defined when using the -deviceemu flag.

Right, thank you. Is there a comprehensive list of macros available? I’m not looking for anything in particular, I’d just like to see one for curiosity.

The only other ones I’m aware of are CUDACC and CUDA_ARCH. They’re in the nvcc documentation.