12

At the moment CUDA already recognizes a key CUDA C/C++ function such as cudaMalloc, cudaFree, cudaEventCreate, etc.

It also recognizes certain types like dim3 and cudaEvent_t.

However, it doesn't recognize other functions and types such as the texture template, the __syncthreads functions, or the atomicCAS function.

Everything compiles just fine, but I'm tired of seeing red underlinings all over the place and I want to the see the example parameters displayed when you type in any recognizable function.

How do I get VS to catch these functions?

Oded
  • 489,969
  • 99
  • 883
  • 1,009
sj755
  • 3,944
  • 14
  • 59
  • 79

2 Answers2

10

You could create a dummy #include file of the following form:

#pragma once
#ifdef __INTELLISENSE__
void __syncthreads();
...
#endif

This should hide the fake prototypes from the CUDA and Visual C++ compilers, but still make them visible to IntelliSense.

Source for __INTELLISENSE__ macro: http://blogs.msdn.com/b/vcblog/archive/2011/03/29/10146895.aspx

ChrisV
  • 3,363
  • 16
  • 19
4

You need to add CUDA-specific keywords like __syncthreads to the usertype.dat file for visual studio. An example usertype.dat file is included with the NVIDIA CUDA SDK. You also need to make sure that visual studio recognizes .cu files as c/c++ files as described in this post:

Note however that where that post uses $(CUDA_INC_PATH), with recent versions of CUDA you should use $(CUDA_PATH)/include.

Also, I would recommend Visual Assist X -- not free, but worth the money -- to improve intellisense. It works well with CUDA if you follow these instructions:

http://www.wholetomato.com/forum/topic.asp?TOPIC_ID=5481

http://forums.nvidia.com/index.php?showtopic=53690

harrism
  • 26,505
  • 2
  • 57
  • 88
  • __syncthreads is in the usertype.dat file, and it gets highlighted in blue, but the function still isn't recognized (underlined in red). I've followed the blog's instructions very clearly, but that only worked for the functions I described above. I've also manually found the CUDA 4.0 include directory. The only benefit was that I was able to open the documents. – sj755 May 31 '11 at 05:41