csl++
csl++ is a place to develop new language features for CSL and to test them at wafer scale. It extends CSL, so every CSL program is also a csl++ program.
The csl++ compiler csl-pp is a drop-in replacement for cslc and takes the same command-line arguments. It translates a program to vanilla CSL and then compiles the result with cslc, the compiler of the Cerebras SDK.
Language extensions
Section titled “Language extensions”csl++ currently adds two extensions to CSL. The Tutorial introduces them step by step with one small program, and the Language section is their reference. The libraries that come with csl++ are written with them.
Async CSL
Section titled “Async CSL”A task of vanilla CSL runs to completion, so a sequence of asynchronous fabric operations is written as one task per step, or as a state machine with its values in globals. In csl++, a task can suspend: it ends its current run at suspend and continues after it when it is activated again, with its local variables intact.
// Receives one value from in and returns it.async fn receive(comptime in: fabin_dsd) f32 { var value: f32 = 0.0; const value_dsd = @get_dsd(mem1d_dsd, .{ .base_address = &value, .extent = 1 }); @fmovs(value_dsd, in, .{ .async = true, .activate = @current_task() }); suspend; // continues here when the value has arrived return value;}
async task sum_task() void { // Receive from both neighbors at the same time. const values = @await_parallel(receive(west_in_dsd), receive(east_in_dsd)); x[0] = values[0] + values[1]; sys_mod.unblock_cmd_stream();}An async function is called with @await like an ordinary function and returns its result. @await_parallel runs several calls at the same time and continues when all of them have returned. A library offers async functions instead of taking a task ID to activate when it is done.
Automatic resource allocation
Section titled “Automatic resource allocation”Vanilla CSL names colors, task IDs and queues by number. The numbers of all modules of a program must be distinct, so the programmer keeps a table of them and passes them into every library. In csl++, a module claims what it needs. A claim at compile time returns a resource that no other claim returns and that memcpy does not use. A claim at runtime takes one of those that are left, and can be released again:
const c_route: color = @claim_color();const iq: input_queue = @claim_input_queue();const task_id: local_task_id = @claim_local_task();A library claims its own resources, so the program imports it without resource parameters, and two libraries, or two instances of one, never collide.
Libraries
Section titled “Libraries”Three libraries of the Cerebras SDK benchmarks are ported to csl++ and come with it: allreduce, a reduction over all PEs; stencil_3d_7pts, a 7-point stencil product on a 3D grid; and collectives_2d, broadcast, scatter, gather and reduce along rows or columns. They offer async functions and claim their resources.
csl-pp writes readable CSL, with one file per distinct PE program. Its frontend also drives csl-lsp-server, a language server with diagnostics, hover, completion and go-to-definition for CSL and csl++ in VS Code. simtracer shows flamegraphs and instruction traces of simulator runs of any CSL program, and keeps the call stacks of async tasks intact across suspend.
Get started
Section titled “Get started”Install
csl-ppfrom PyPI, next to the Cerebras SDK. Installation →Terminal window pipx install csl-ppCompile a CSL program with it: replace
cslcwithcsl-ppin the command of any SDK example. The arguments stay the same. Quickstart →Terminal window csl-pp ./layout.csl --arch=wse3 --fabric-dims=8,3 --fabric-offsets=4,1 -o out --memcpy --channels=1Follow the tutorial, which introduces
suspend, async functions, claims and parallel calls. Tutorial →
Development
Section titled “Development”csl++ is developed by the Embedded Systems and Applications Group at the Technical University of Darmstadt as a research project on programming the Cerebras Wafer-Scale Engine. It is not a product of Cerebras Systems; CSL, cslc and the SDK are. The code is open source, and new language features, library ports, bug reports and fixes are welcome. Contributing →
The paper on the async extension and its stackful lowering, Structured Coroutines for the Wafer-Scale Engine, has been accepted at CGO 2027 in Salt Lake City. It is not published yet; see About for how to cite it until then.