Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

Visual Studio: Intellisense for CUDA

📅 2011-Feb-01 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ cuda, intellisense, visual studio ⬩ 📚 Archive

Why?

It is convenient to have Intellisense turned on for CUDA source files in Visual Studio. This enables autocompletion while typing code and navigation while investigating code. The navigation is especially useful since the programmer can seamlessly navigate between C/C++ and CUDA code using Go to Definition and similar commands.

How?

To turn on Intellisense in Visual Studio 2008 for CUDA source files:

  1. Close all instances of Visual Studio.

  2. Open Registry Editor and navigate to HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\Languages\Language Services\C/C++

  3. In the value of the name NCB Default C/C++ Extensions, append the text .cu;.cuh;.cl; This instructs Intellisense to build its database for CUDA source files too.

  4. Delete the .ncb file in your Visual Studio project directory. Open your CUDA project in Visual Studio, Intellisense will rebuild its database, this time it will include the CUDA source files.

Clicking Go to Definition or F12 on a CUDA runtime function call (like cudaMalloc) may not work. If you want such functionality, include the CUDA header file that has those declarations. For example, cuda_runtime.h needs to be included for most runtime calls.

Note: Related information and files can be found in the %CUDA_PATH%\extras\visual_studio_integration directory.

Tried with: Visual Studio 2008


© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 @codeyarns@hachyderm.io📧