Skip to content

VS Code extension

The VS Code extension Language Server for CSL checks CSL and csl++ programs while they are edited. It runs csl-lsp-server, a language server that uses the frontend of csl-pp, including the comptime evaluation of the whole program. The server therefore reports the errors that csl-pp reports while parsing, evaluating and type-checking, and it knows the types of values that depend on comptime code.

The extension provides:

  • diagnostics while you type;
  • the type of a value on hover;
  • go to definition, including into imported modules and the system modules of the SDK;
  • completion, including members after .;
  • signature help for calls;
  • the outline of a file;
  • syntax highlighting.

Install the extension from the Visual Studio Marketplace, or from the command line:

Terminal window
code --install-extension esa-tu-darmstadt.csl-lsp

The extension contains csl-lsp-server for Linux on x86-64, so nothing has to be built. On another system, open the program on a Linux machine with the Remote - SSH or WSL extension of VS Code. The extension is then installed on that machine and runs there.

The settings of the extension begin with csl.. VS Code offers two ways to change them:

  • In the Settings editor. Open it with Ctrl+, or File > Preferences > Settings, and search for csl.
  • As JSON. Open the Command Palette with Ctrl+Shift+P, run “Preferences: Open User Settings (JSON)” or “Preferences: Open Workspace Settings (JSON)”, and add the settings to the file.

VS Code stores settings on several levels. User settings apply to every folder that you open. Workspace settings apply to one folder, are stored in its .vscode/settings.json, and take precedence over the user settings. In a remote window, “Preferences: Open Remote Settings (JSON)” opens the user settings of the remote machine.

The extension restarts the language server when one of its settings changes.

One setting is required. Set csl.systemModuleSif to the *.sif file in the directory of the Cerebras SDK:

{
"csl.systemModuleSif": "/home/user/cerebras-sdk/sdk-cbcore-2.10.0.sif"
}

The server reads the system modules of the SDK, such as <memcpy/memcpy>, from this file. Without the setting, it reports an error for every import of a system module. The path is the same for all programs on a machine, so the setting belongs in the user settings, or in the remote settings in a remote window.

The architecture and the parameters of a program belong in the workspace settings of its folder. For a program that is compiled with csl-pp layout.csl --arch=wse3 --params=width:4,N:8, the file .vscode/settings.json in the folder contains:

{
"csl.arch": "wse3",
"csl.params": { "width": 4, "N": 8 }
}

csl.params gives the values of the param declarations of the layout file, like --params on the command line.

The server checks a program in the way csl-pp compiles it, starting from the layout file. A layout file is a file with a layout block. When one is open, the server evaluates it with csl.params and checks every PE program that a @set_tile_code call names, with the parameters of that call. If several calls name the same file, the server uses the parameters of the first one.

A PE program whose layout file is not open is checked on its own. Its param declarations then have no values, and the server reports an error for each of them. Keep the layout file of a program open in a tab while you edit its PE programs.

The extension does not contain the csl++ libraries. For a program that imports them, set csl.serverPath to the csl-lsp-server of the installed package, which finds the libraries of its installation. which csl-lsp-server prints its path:

{
"csl.serverPath": "/home/user/.local/bin/csl-lsp-server"
}

csl.serverPath also selects a server that was built from the repository, for work on the language server itself.

Setting Meaning Default
csl.systemModuleSif The SDK image (*.sif) from which the server reads the system modules. none
csl.systemImportPath A directory with the system modules, in place of the image. If both settings are given, it is the directory of the system modules within the image. none
csl.arch The target architecture, wse2 or wse3. wse2
csl.params The values of the param declarations of the layout file, as an object of names and numbers. A number with a decimal point is a comptime_float, any other number a comptime_int. {}
csl.fabricDims The fabric dimensions, as width,height. 100,100
csl.fabricOffsets The offset of the program rectangle in the fabric, as x,y. 3,3
csl.rectangle The size of the program rectangle that @get_rectangle returns, as width,height. 100,100
csl.serverPath A csl-lsp-server to run in place of the one in the extension. the server in the extension
csl.serverArgs Further command-line arguments of the server, as an array of strings. []
csl.filterOverlappingErrors If several errors overlap, show only the innermost one. false
csl.trace.server Log the messages between VS Code and the server: off, messages or verbose. off

The server writes its log to the output channel “CSL Language Server” of the Output panel. “CSL: Restart Language Server” in the Command Palette restarts the server.

The extension works next to the extension “Cerebras Software Language (CSL)” of Cerebras, which provides syntax highlighting only.