The default value of __CUDA_ARCH__ macro causes the vscode intellisence to report errors

so basically, i was using cuda_fp16.h and fp16 arithmetic operations are defined when CUDA_ARCH is not defined or it is greater than 530 according to the source code definitions. However, when i hover my mouse to the definition of CUDA_ARCH, it shows the it is defined as 520. And i am not sure which header files defines this value. Every time i do an arithmetic operation such as dereferencing a fp-16 pointer or += or … it gives me an error, which is super annoying. when i compile my code, i use -arch compute-80 and i know the compiler will set the correct value for that macro. therefore the execution has no problem.
Is there any way to set this default macro to 800 or other way around?

That macro is not defined by any header files. It is defined by the compiler during certain phases as it is compiling code.

intellisense doesn’t work well with CUDA. You can find lots of forum posts to that effect.

If you decide to try to “fix” intellisense, my suggestion is that any changes you make would be wrapped in an ifdef conditioned on the __INTELLISENSE__ macro, so as to be certain to have no effect on actual code compilation.

For example:

#ifdef __INTELLISENSE__
#define __CUDA_ARCH__ 800
#endif

Does this help?

Thanks, this also provides a general solution for similar cases where the intellisencse has troubles to work with other libs.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.