Without even some manual knob-turning the C/C++ syntax in the .cu files is not even highlighted, but what about functions and variables names completion? What about Intellisense (VS)?
Let’s start by having a project that already works as far as compiling the .cu files with NVCC (using the custom build rule for the .cu files [if needed I can post the one used in nVIDIA’s sample projects]).
Well, the basic idea is to write your .cu code (for the main file and for the kernels) in nice .C files (C++ syntax) and set those “would be .cu files” to compile using a custom build rule (check that this rules comes before the CUDA/NVCC one in the build tools order for your project).
The custom build rule for these “dummy” .C files, thanks to VS’s Macros (env. vars), is not tough to write…
rm (InputName).cu cp (InputFileName) $(InputName).cu
Description (nice console output):
(InputFileName) --> (InputName).cu
The idea is to basically have a .C file for each .cu file and set those .C files compilation step appropriately to just “transform” them into .cu files for you giving you back Intellisense (for your code and for CUDA SDK’s functions and macros too) at a very minor cost.
If I have explained myself poorly, please do ask any question you might have and I’ll try to answer it.
say you have your main .cu file named MatTest.cu (when you split in one main .cu file and several kernel files then the kernel files are usually excluded from the build process, included by the main .cu file itself, and referenced in the custom build process of the main .cu file)… and this file references a MatTest_kernel.cu
If you just created it, then you might have to set the Custom Build process for it (it cannot just use NVCC directly as Visual Studio attempts it to do automatically)… so you right click on the file and click on Properties…
You set it to use a Custom Build Tool (General), you click on Apply, and then you configure the custom build process…
“(CUDA_BIN_PATH)\nvcc.exe" -ccbin "(VCInstallDir)bin” -c -D_DEBUG -DWIN32 -D_CONSOLE -D_MBCS -Xcompiler /EHsc,/W3,/nologo,/Wp64,/Od,/Zi,/RTC1,/MTd -I"(CUDA_INC_PATH)" -I./ -I../../common/inc -o (ConfigurationName)\MatTest.obj MatTest.cu