If you happen to use Visual Assist X from Whole Tomato Software (http://www.wholetomato.com/), you may wonder how you can get visual assist to recognize CUDA files and parse and highlight them like regular C/C++ files. I wondered the same thing, and the helpful people at the Whole Tomato forums pointed me to their FAQ, which has instructions for exactly what I needed.
Note that you might also want to go into the VA settings->Projects->C/C++ Directories, switch to “Custom” Platform mode, and add your /inc directory to the list of search directories.
The steps I do to configure the Visual Assist X properly are the next ones (for Visual Studio 2008):
First, close all the instances of Visual Studio and install the software.
Second, 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
Third, Open and close Visual Studio (this initializes Visual Assist X parameters by creating some folders/variables in the Registry ).
Finally add .cu; to the ExtSource key and add .cuh; to the ExtHeader key
A part from that you can use what this link (from the user wizardsofeast) put to improve intellisense, specially for navigating through functions. Using this one in combination with Visual Assit X is superb :rolleyes: :
Hello, Some good folks over at Visual Assist (see sources below). They helped clean up Visual Assist X a little more when working with CUDA. I tried their suggestion and I no longer get any annoying squiggly lines under some of the keywords in .cu files for device and global functions.
To summarize it(and add to it more), I wrote up some instructions: (note: see sources below for additional info)
==================================================================
To help make it so Visual Assist X does not fail with cuda and underline unknown words, perform the following:
copy C:\Program Files\Visual Assist X\Misc\StdAfx.h to C:\Users\RWHITE\AppData\Roaming\VisualAssist\ Misc\StdAfx.h
Then insert the following to C:\Users\RWHITE\AppData\Roaming\VisualAssist\ Misc\StdAfx.h
///////////////////////////////////////////////////////////// //////////////////
// macro for visual assist compatibility with cuda #definelaunch_bounds(x) #definerestrict #definedevice #defineglobal #defineshared #defineconstant
struct int3{
int x;
int y;
int z;
};
struct uint3{
unsigned int x;
unsigned int y;
unsigned int z;
};
struct uint3{
unsigned int x;
unsigned int y;
unsigned int z;
};
struct blockIdx{
int x;
int y;
int z;
};
struct threadIdx{
unsigned int x;
unsigned int y;
unsigned int z;
};
struct blockDim{
int x;
int y;
int z;
};
struct blockIdx{
int x;
int y;
int z;
};
typedef int warpSize;
Last, Open Visual studio and run from the menu: VA Options → Performance → General → Rebuild symbol databases
tools > options> projects and solutions > VC++ directories
choose your platform. i use win32 but theres probably a better way but i dont know how to create a custom config. this way works fine.
foreach X in {library files, source files, include files} in the “show directories for:” drop down,
add folder “$(CUDA_PATH)<>”
for includes it would be “$(CUDA_PATH)\include”
for source files it would be “$(CUDA_PATH)\src”
for library files it would be “$(CUDA_PATH)\lib”
this will enable f12 lookups to work,and make visual assist properly populate translations for cude #defines. this approach is far superior to faking out with a corrupted StdAfx.h files in roaming.
I’ve never used CUDA myself, but if the keywords such as constant and shared are not defined in some way in the source itself, cleverly combining the two solutions (roaming file and your new way) may result in an enhanced “superior” experience :)