vscode-clangd
vscode-clangd copied to clipboard
How to write CUDA?

You should add a .clangd file
CompileFlags:
Add:
- -std=c++11
- --cuda-path=/usr/local/cuda
- --cuda-gpu-arch=sm_61
- -L/usr/local/cuda/lib64
- -I/usr/local/cuda/include
clangd seems to not working on windows though...
Also, clangd 11.0+ is needed.
looks like not work on windows until now
@Wongboo It works, but you need to carefully configure it though...
@cloudhan , how's your configuration file?
This should work:
.clangd file:
CompileFlags:
Add:
- -std=c++14
- --cuda-path=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.1
- --cuda-gpu-arch=sm_61
- -LC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.1\lib\x64
- -IC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.1\include
You must not quote your path and must not escape the backslash in the path. Pretty weird here, though.
And you should set your .cu file to cpp mode via vscode's "Chang Language Mode".


@cloudhan, thank you for your code, I think vscode-clangd may make some improvement: vscode-clangd should work under cuda and cuda-cpp language mode
- by my testing, you can remove
-LC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.1\lib\x64and-IC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.1\includefrom configuration, which still works. My final question is my environment variable already haveCUDA_PATH, can I simple write something like-xcudato useCUDA_PATH?
Some improvements are being discussed in https://reviews.llvm.org/D114326. Feel free to state your opinions there.