VSCode Nsight Intellisense not detecting functions and datatypes for *cu; *cpp works

Hi all,

I have been able to debug and step through code on the GPU and the code lints (with coloring for __global__ and __device__). However, it seems that I need help with configuring Intellisense. I am able to use *.h files perfectly well, but any *.cu files end up not having any Intellisense, meaning no autocomplete and no argument suggestions.

Does anyone have suggestions for getting Intellisense to work? I am using the latest toolkit 11.7. I’ve listed what I believe are the relevant information below. Please let me know if you need more.

My system specs:

------------ 
OS: Pop!_OS 22.04 LTS x86_64 
Host: Laptop A6 
Kernel: 5.18.10-76051810-generic 
Uptime: 33 mins 
Packages: 2956 (dpkg), 18 (flatpak), 13 (snap) 
Shell: zsh 5.8.1 
Resolution: 2560x1080 
DE: GNOME 42.2 
WM: Mutter 
WM Theme: Pop 
Theme: Pop-dark [GTK2/3] 
Icons: Pop [GTK2/3] 
Terminal: gnome-terminal 
CPU: 11th Gen Intel i7-1165G7 (8) @ 4.700GHz 
GPU: Intel TigerLake-LP GT2 [Iris Xe Graphics] 
Memory: 7144MiB / 31891MiB 
➜  ~ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Tue_May__3_18:49:52_PDT_2022
Cuda compilation tools, release 11.7, V11.7.64
Build cuda_11.7.r11.7/compiler.31294372_0

VSCode Extensions:

GitHub.vscode-pull-request-github@0.46.0
jeff-hykin.better-cpp-syntax@1.15.19
josetr.cmake-language-support-vscode@0.0.4
kriegalex.vscode-cudacpp@0.1.1
ms-vscode-remote.remote-containers@0.241.3
ms-vscode-remote.remote-ssh@0.84.0
ms-vscode-remote.remote-ssh-edit@0.80.0
ms-vscode-remote.remote-wsl@0.66.3
ms-vscode.cmake-tools@1.11.26
ms-vscode.cpptools@1.10.8
ms-vscode.cpptools-extension-pack@1.2.0
ms-vscode.cpptools-themes@1.0.0
nobuhito.printcode@3.0.0
nvidia.nsight-vscode-edition@2022.1.31181613
vadimcn.vscode-lldb@1.7.2

Intellisense for CUDA actually ships with cpptools. If you already have cpptools installed then likely the issue is that the C++ language id is selected (see language in status bar), change this to CUDA C++ and see if this helps.

Thanks for that suggestion. Interestingly, Intellisense works when I change language id to “C++” but does not work when using “Cuda C++”.

So I can click on a function when using language id “C++” to go to the definition of the function but not when the language id is “Cuda C++”

I am also able to see where __global__ is defined when it is “C++”. So I guess the only downside of using “C++” instead of “Cuda C++” is that __global__ is not properly syntax highlighted.

So I found out how to get to the c_cpp extension’s log. Here are the two versions of the logs. I have a single file open in the workspace. The first is for “cuda C++” and the second is for “C++”.

If the file is being read as “Cuda C++”

loggingLevel: Debug
cpptools/didChangeCppProperties
Attempting to get defaults from C compiler in "compilerPath" property: '/usr/bin/gcc'
Querying compiler for default C++ language standard using command line: /usr/bin/gcc -x c++ -E -dM /dev/null
Detected language standard version: gnu++17
Querying compiler for default C language standard using command line: /usr/bin/gcc -x c -E -dM /dev/null
Detected language standard version: gnu17
Querying compiler's default target using command line: "/usr/bin/gcc" -dumpmachine
Compiler returned default target value: x86_64-linux-gnu
Compiler query command line: /usr/bin/gcc -std=gnu17 -m64 -Wp,-v -E -dM -x c /dev/null
Code browsing service initialized
Attempting to get defaults from C++ compiler in "compilerPath" property: '/usr/bin/gcc'
Compiler query command line: /usr/bin/gcc -std=gnu++17 -m64 -Wp,-v -E -dM -x c++ /dev/null
Folder: /usr/include/ will be indexed
Folder: /usr/lib/gcc/x86_64-linux-gnu/11/include/ will be indexed
Folder: /usr/local/include/ will be indexed
Folder: /home/jim/code/cuda-bd-refactor-2022/ will be indexed
Folder: /usr/local/cuda-11.7/targets/x86_64-linux/include/ will be indexed
cpptools/didChangeSettings
Discovering files...
IntelliSense Engine = Default.
Enhanced Colorization is enabled.
Error squiggles are enabled if all header dependencies are resolved.
Autocomplete is enabled.
Processing folder (recursive): /usr/include/
Processing folder (recursive): /usr/lib/gcc/x86_64-linux-gnu/11/include/
Processing folder (recursive): /usr/local/include/
Processing folder (recursive): /home/jim/code/cuda-bd-refactor-2022/
Processing folder (recursive): /usr/local/cuda-11.7/targets/x86_64-linux/include/
Discovering files: 8462 file(s) processed
0 file(s) removed from database
Done discovering files.
Populating include completion cache.
Parsing remaining files...
Parsing: 0 files(s) processed
Done parsing remaining files.

If the file is set to “C++”:

loggingLevel: Debug    
cpptools/didChangeCppProperties    
Attempting to get defaults from C compiler in "compilerPath" property: '/usr/bin/gcc'    
Querying compiler for default C++ language standard using command line: /usr/bin/gcc -x c++ -E -dM /dev/null    
Detected language standard version: gnu++17    
Querying compiler for default C language standard using command line: /usr/bin/gcc -x c -E -dM /dev/null    
Detected language standard version: gnu17    
Querying compiler's default target using command line: "/usr/bin/gcc" -dumpmachine    
Compiler returned default target value: x86_64-linux-gnu    
Compiler query command line: /usr/bin/gcc -std=gnu17 -m64 -Wp,-v -E -dM -x c /dev/null    
Code browsing service initialized    
Attempting to get defaults from C++ compiler in "compilerPath" property: '/usr/bin/gcc'    
Compiler query command line: /usr/bin/gcc -std=gnu++17 -m64 -Wp,-v -E -dM -x c++ /dev/null    
  Folder: /usr/include/ will be indexed    
  Folder: /usr/lib/gcc/x86_64-linux-gnu/11/include/ will be indexed    
  Folder: /usr/local/include/ will be indexed    
  Folder: /home/jim/code/cuda-bd-refactor-2022/ will be indexed    
  Folder: /usr/local/cuda-11.7/targets/x86_64-linux/include/ will be indexed    
textDocument/didOpen: /home/jim/code/cuda-bd-refactor-2022/calc_properties.cu    
Discovering files...    
cpptools/textEditorSelectionChange    
cpptools/activeDocumentChange: /home/jim/code/cuda-bd-refactor-2022/calc_properties.cu    
Invoking nvcc with command line: /usr/local/cuda/bin/nvcc /home/jim/.config/Code/User/workspaceStorage/9628c1573f866174de3a0dbf3e145d13/ms-vscode.cpptools/nvcc_temp/temp.cu -c -x cu -odir /home/chris/.config/Code/User/workspaceStorage/9628c1573f866174de3a0dbf3e145d13/ms-vscode.cpptools/nvcc_temp -keep -keep-dir /home/chris/.config/Code/User/workspaceStorage/9628c1573f866174de3a0dbf3e145d13/ms-vscode.cpptools/nvcc_temp -v
  Processing folder (recursive): /usr/include/    
Attempting to get defaults from C++ compiler in "compilerPath" property: 'gcc'    
Compiler query command line: /usr/bin/gcc -m64 -std=gnu++17 -Wp,-v -E -dM -x c++ /dev/null    
cpptools/getDocumentSymbols: /home/jim/code/cuda-bd-refactor-2022/calc_properties.cu (id: 2)    
cpptools/getDocumentSymbols    
cpptools/getCodeActions: /home/jim/code/cuda-bd-refactor-2022/calc_properties.cu (id: 3)    
cpptools/getDocumentSymbols: /home/jim/code/cuda-bd-refactor-2022/calc_properties.cu (id: 4)    
cpptools/getDocumentSymbols    
  Processing folder (recursive): /usr/lib/gcc/x86_64-linux-gnu/11/include/    
  Processing folder (recursive): /usr/local/include/    
  Processing folder (recursive): /home/jim/code/cuda-bd-refactor-2022/    
  Processing folder (recursive): /usr/local/cuda-11.7/targets/x86_64-linux/include/    
  Discovering files: 8462 file(s) processed    
  0 file(s) removed from database    
Done discovering files.    
Populating include completion cache.    
Parsing remaining files...    
  Parsing: 0 files(s) processed    
Done parsing remaining files.    
Checking for syntax errors: /home/jim/code/cuda-bd-refactor-2022/calc_properties.cu    
sending compilation args for /home/jim/code/cuda-bd-refactor-2022/calc_properties.cu    
  include: /usr/local/cuda-11.7/targets/x86_64-linux/include    
  include: /usr/include/c++/11    
  include: /usr/include/x86_64-linux-gnu/c++/11    
  include: /usr/include/c++/11/backward    
  include: /usr/lib/gcc/x86_64-linux-gnu/11/include    
  include: /usr/local/include    
  include: /usr/include/x86_64-linux-gnu    
  include: /usr/include    
  include: /usr/local/cuda-11.7/targets/x86_64-linux/include/cuda/std/detail    
  include: /usr/local/cuda-11.7/targets/x86_64-linux/include/cuda/std/detail/libcxx/include    
  include: /usr/local/cuda-11.7/targets/x86_64-linux/include/thrust/system/cuda    
  define: __SSP_STRONG__=3    
  define: __DBL_MIN_EXP__=(-1021)    
  // Lots of define's cut for clarity    
  define: __CUDA_API_VER_MAJOR__=11    
  define: __CUDA_API_VER_MINOR__=7    
  define: __NVCC_DIAG_PRAGMA_SUPPORT__=1    
  preinclude: /usr/local/cuda/bin/../targets/x86_64-linux/include/cuda_runtime.h    
  other: --g++    
  other: --gnu_version=110200    
  other: --cuda    
  stdver: c++17    
  intelliSenseMode: linux-gcc-x64    
Checking for syntax errors: /home/jim/code/cuda-bd-refactor-2022/calc_properties.cu    
Queueing IntelliSense update for files in translation unit of: /home/jim/code/cuda-bd-refactor-2022/calc_properties.cu                                                                                                                                                                                                       
cpptools/getSemanticTokens: /home/jim/code/cuda-bd-refactor-2022/calc_properties.cu (id: 5)                                                                                                                                                                                                                                  
cpptools/getCodeActions: /home/jim/code/cuda-bd-refactor-2022/calc_properties.cu (id: 6)                                                                                                                                                                                                                                     
cpptools/finishUpdateSquiggles                                                                                                                                                                                                                                                                                               
Error squiggle count: 0                                                                                                                                                                                                                                                                                                      
Update IntelliSense time (sec): 1.225                                                                                                                                                                                                                                                                                        
cpptools/getFoldingRanges: /home/jim/code/cuda-bd-refactor-2022/calc_properties.cu (id: 7)                                                                                                                                                                                                                                   
cpptools/getCodeActions: /home/jim/code/cuda-bd-refactor-2022/calc_properties.cu (id: 8)                                                                                                                                                                                                                                     
cpptools/getFoldingRanges: /home/jim/code/cuda-bd-refactor-2022/calc_properties.cu (id: 9)                                                                                                                                                                                                                                   
cpptools/getCodeActions: /home/jim/code/cuda-bd-refactor-2022/calc_properties.cu (id: 10)                                                                                                                                                                                                                                    
~

I’m a fool. I had an old extension that was interfering with the tool. Apologies for that. Upon removal of other cuda extensions, everything works.

OK perfect, happy to hear it’s working for you now. Let us know if there’s anything else that we can help with.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.