Just would like to give small tips I found to help working with CUDA under visual studio.
First, syntax highlighting for .cu files can be enabled with these few steps:
1. Copy the content of the “usertype.dat” file provided by nvidia (NVIDIA CUDA SDK\doc\syntax_highlighting\visual_studio_8) into your “Microsoft Visual Studio 8\Common7\IDE” folder from your program files folder.
2. Open Visual Studio and Take Tools -> Options. Under Text Editor -> File Extension tab, specify the extension “cu” as a new type.
Visual Studio rely on a feature named Intellisense to provide functions and variables names completion, definitions lookup and all these kind of features. To get intelligence working with .cu files, yo have to modify a windows registry key: Add c and cuh extensions to NCB Default C/C++ Extensions key under “HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\Languages\Language Services\C/C++” path. (Thanks to http://www.wizardsofeast.com/?p=378 for the tip)
For those using Visual Assist X, you can do the following. First, find the Visual Assist X install directory: (X:\Program Files\Visual
Assist X\AutoText\latest) and then make a copy of Cpp.tpl and rename it
to Cu.tpl. Second, Open and close Visual Studio (this initializes
Visual Assist X parameters by creating some folders/variables in the
Registry ). Third, open regedit and go to: “HKEY_CURRENT_USER\Software\Whole Tomato\Visual Assist X\VANet9” and add “.cu;” to the ExtSource key and add “.cuh;” to the ExtHeader key. (Thanks to ciberxtrem for the tip)
Finally, build rules allowing to easily compile .cu files without having to write the rules manually can be integrated installing this little wizard: http://forums.nvidia.com/index.php?showtopic=65111. More details on CUDA build rules can be found on this website : http://sarathc.wordpress.com/2008/09/26/how-to-integrate-cuda-with-visual-c/.
June 16th, 2010 on 3:53 pm
Ankit Hey thanks for the above highlighting info. I was able to do it.
But I m getting a lot of errors when compiling a .cu codes. I have added CUDA rules files by the name of nvcc.rules and added the library also but am not able to figure out what else to do. For all the CUDA commands like cudaMalloc , cudaMemcopy etc are undefined.
1) Is nvcc.rules the correct file coz in many sites I have found the name cuda.rules . I searched but I dont have any such file in my computer
September 26th, 2009 on 12:44 am
Pat Thanks, makes life a little nicer haveing these features with th .cu files. Thanks again.
October 6th, 2009 on 9:59 am
hi i am new to CUDA , could you please let me know how to build cuda code in visual studio, any setting or any file which needs to copy system details.
XP 64bit