Skip to content

Latest commit

 

History

History
122 lines (105 loc) · 5.01 KB

ide_setup.md

File metadata and controls

122 lines (105 loc) · 5.01 KB

README > IDE Setup for CUTLASS Development

IDE Setup for CUTLASS Development

This document outlines instructions and tips for setting up a local editor for CUTLASS development, including support for intellisense, go-to-definition, code formatting, and so on.

Overview

In order for any intellisense tool to work with CUTLASS, the following things need to be configured with it:

  • Include paths, i.e. where the compiler (or in this case, the intellisense tool) should look for header files
  • Compiler flags; especially the C++ standard (--std)
  • Preprocessor variables; especially CUDA-related ones

One usually needs to configure the above variables in a settings file. Below, two config approaches are described: for VSCode, and for any editor that uses the clangd language server, which includes Vim, Emacs, NeoVim, Sublime Text, and so on. Note that VSCode can also be configured to use clangd. It might be worth setting up clangd for VSCode rather than the default intellisense, and you might see faster responses and more stable performance with clangd.

VSCode Setup

  1. Install the Official C/C++ extension
  2. Open settings...
    1. Ctrl+Shift+P to open the command palette
    2. Enter "C/C++" to filter results
    3. Select "C/C++ Edit Configurations (UI)" (or "... (JSON)" if you feel like editing the raw JSON)
    4. View the documentation for these settings here
  3. Edit "Include Path" to set up include paths. For CUTLASS, this includes the following:
    • ${workspaceFolder}/include
    • ${workspaceFolder}/tools/util/include
    • ${workspaceFolder}/examples/common
    • ...others, depending on which files you edit
  4. Edit C++ standard to be c++17, gnu++17, or equivalent.
  5. Edit defines to define preprocessor variables. See Global Config below for examples. The important ones include __CUDACC_VER_MAJOR__, __CUDA_ARCH__, __CUDA_ARCH_FEAT_SM90_ALL__. But configure them according to your target architecture.
  6. ...and possible edit any other fields for your specific setup.

clangd Setup

clangd is a C++ language server that is part of the LLVM project. You must first set it up your specific IDE:

  • clangd official documentation for editor setup.
  • NeoVim setup is possible through lsp and either manually installing clangd or using an installation manager like Mason.

Then, one needs to edit the config (documentation). One typically has a global and a per-project config.

Global Config

Here is one example for a global config. On linux this is usually located at ~/.config/clangd/config.yaml . Here is one example config for CUDA projects on SM90. The key settings here are the preprocessor vars (-D__CUDACC_VER_MAJOR__ , -D__CUDA_ARCH__)

CompileFlags:
  Compiler: /usr/local/cuda/bin/nvcc
  Add:
    - --cuda-path=/usr/local/cuda
    - --cuda-gpu-arch=sm_90a
    - -I/usr/local/cuda/include
    - "-xcuda"
    # report all errors
    - "-ferror-limit=0"
    - --cuda-gpu-arch=sm_90a
    - --std=c++17
    - "-D__INTELLISENSE__"
    - "-D__CLANGD__"
    - "-DCUDA_12_0_SM90_FEATURES_SUPPORTED"
    - "-DCUTLASS_ARCH_MMA_SM90_SUPPORTED=1"
    - "-D_LIBCUDACXX_STD_VER=12"
    - "-D__CUDACC_VER_MAJOR__=12"
    - "-D__CUDACC_VER_MINOR__=3"
    - "-D__CUDA_ARCH__=900"
    - "-D__CUDA_ARCH_FEAT_SM90_ALL"
    - "-Wno-invalid-constexpr"
  Remove:
    # strip CUDA fatbin args
    - "-Xfatbin*"
    # strip CUDA arch flags
    - "-gencode*"
    - "--generate-code*"
    # strip CUDA flags unknown to clang
    - "-ccbin*"
    - "--compiler-options*"
    - "--expt-extended-lambda"
    - "--expt-relaxed-constexpr"
    - "-forward-unknown-to-host-compiler"
    - "-Werror=cross-execution-space-call"
Hover:
  ShowAKA: No
InlayHints:
  Enabled: No
Diagnostics:
  Suppress:
    - "variadic_device_fn"
    - "attributes_not_allowed"

Local Config

Local config is needed to specify per-project settings, especially include paths. An example is:

CompileFlags:
  Add:
    - -I</absolute/path/to/cutlass>/include/
    - -I</absolute/path/to/cutlass>/tools/util/include/
    - -I</absolute/path/to/cutlass>/cutlass/examples/common/

Note that absolute paths are needed since clangd doesn't support relative paths.

Note on compile_commands.json

For typical C++ projects, clangd can automatically configure itself by parsing the compile_commands.json generated by your CMake build. The path to such a file is by default build/compile_commands.json and is configured by the CompilationDatabase config.

This is usually a convenient way to configure projects, but it's not as simple for CUDA/nvcc projects, since clang doesn't understand many of the compiler flags used by nvcc. Hence, for now, we don't recommend using compile_commands.json to configure your CUDA project.