3

I'm running VSCodium with the clangd extension, and I'd like to have proper CUDA highlighting (e.g. __device__ and __host__ keywords are understood). I ran CMake to generate the compile_commands.json file, and it includes CUDA-specific keywords (e.g. --cuda-gpu-arch=sm_52, --cuda-path=/usr/local/cuda). However, clangd still gives me the squiggle underline on CUDA-specific keywords. It seems like if clangd is just using the clang compiler to understand the source code, then clangd should work with CUDA (given that clang was able to compile the CUDA code).

So, is there any way to get clangd to work for CUDA? And if so, how do I do it via VSCodium?

Edit: As it turns out, the CUDA code highlighting works on the directly linked files (with a .cu extension), but it does not work on one of the included header files (with a .hpp extension). How do I get the text-highlighting to work on the header file?

talonmies
  • 70,661
  • 34
  • 192
  • 269
Lucas Myers
  • 366
  • 2
  • 13

1 Answers1

2

create a config file ".clangd" in your project directory and specify the location of CUDA headers. This works for me.

CompileFlags:   
Add:
    - -xc++
    - --cuda-path=/path_to_cuda_installation
    - --cuda-gpu-arch=sm_52
    - -I/path_to_cuda_installation/include
pem
  • 175
  • 1
  • 6