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.
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)
~