NVIDIA / nsight-vscode-edition

A Visual Studio Code extension for building and debugging CUDA applications.
Other
72 stars 11 forks source link

Set Compute capability version for Intellisense autocomplete #17

Closed rik1599 closed 5 months ago

rik1599 commented 2 years ago

Intellisense recognize atomicAdd(double*, double) as an error image

But I'm compiling for compute capability 6.1 (so atomicAdd for doubles exists) and there isn't an option for choosing the desired compute capability for Intellisense.

Any solution/workaround?

edochang commented 2 years ago

Took some hints here - microsoft/vscode-cpptools#8091

When I searched for "compile" in my C/C++ extension in my workspace settings, I found the Compiler Args. I added "-arch native" to it. At first it didn't work. I looked at the c_cpp_properties.json and split the string representation to be "-arch", "native". My intellisense accepted the double atmoicAdd and didn't break my other intellisense for c++17.

These settings are added to your .vscode/c_cpp_properties.json and not my .vscode/settings.json file as...

{ "configurations": [ { "name": "Linux", "includePath": [ "${workspaceFolder}/src/", "/usr/local/cuda-11.7/" ], "defines": [], "compilerPath": "/usr/local/cuda-11.7/bin/nvcc", "cStandard": "gnu17", "cppStandard": "c++17", "intelliSenseMode": "linux-gcc-x64", "configurationProvider": "ms-vscode.makefile-tools", "compilerArgs": [ "-arch", "native" ] } ], "version": 4 }

This seems to work for me now. This makes sense, since similarly when you build with make, you need to define the -arch flag for nvcc.

nvcc --help has an explanation of the -arch flag.

Here's a good article about identifying the right gpu architecture: https://arnon.dk/matching-sm-architectures-arch-and-gencode-for-various-nvidia-cards/

To see what you can set with -arch, do nvcc --help and read

Options for steering GPU code generation.

--gpu-architecture (-arch)