Tutorial
The tutorial introduces the language extensions of csl++ with one small program, which changes from step to step. It assumes that you know CSL as taught in the tutorials of the Cerebras SDK: tasks, DSDs, colors and routes, and memcpy.
Program
Section titled “Program”Three PEs form a row. Each of the two outer PEs holds a value and sends it to the middle PE. The middle PE receives the two values and adds them.
PE 0 PE 1 PE 2 sender.csl ─────────► receiver.csl ◄───────── sender.csl west_color east_colorThe outer PEs run sender.csl, which is vanilla CSL. When the host calls compute, the PE sends its value x to the middle PE:
// Called by the host.fn compute() void { @fmovs(out_dsd, x[0]); sys_mod.unblock_cmd_stream();}The middle PE runs receiver.csl. It has one input queue and one fabric input DSD for each neighbor:
// One input queue per neighbor.const west_queue: input_queue = @get_input_queue(2);const east_queue: input_queue = @get_input_queue(3);const west_in_dsd = @get_dsd(fabin_dsd, .{ .extent = 1, .input_queue = west_queue });const east_in_dsd = @get_dsd(fabin_dsd, .{ .extent = 1, .input_queue = east_queue });The tutorial is about the rest of this file: the code that receives the two values and stores their sum. The layout file routes one color from each outer PE to the middle PE. The host program writes a value to each outer PE, calls compute on all PEs, and reads the sum from the middle PE.
Running a step
Section titled “Running a step”Every step has a complete program in the csl++ repository, in website/examples/tutorial. With csl-pp and the Cerebras SDK on your PATH, as described in Installation, clone the repository and run the script of a step:
git clone https://github.com/esa-tu-darmstadt/csl-pp.gitcd csl-pp/website/examples/tutorial/1-suspend./commands_wse3.shThe script compiles the program for WSE-3 and runs it on the simulator of the SDK. commands_wse2.sh does the same for WSE-2.
#!/usr/bin/env bash
set -e
csl-pp ./src/layout.csl --arch=wse3 --fabric-dims=10,3 --fabric-offsets=4,1 \ -o out --memcpy --channels=1cs_python ./run.py --name outcsl-pp takes the arguments of cslc. The host program prints the two values and the sum that it read from the middle PE:
1.5 + 2.25 = 3.75SUCCESS!- Suspending a task: a task waits for an operation with
suspend. - Async functions: the wait becomes a function that is called with
@await. - Claiming resources: the program claims its colors, queues and task ID instead of choosing numbers.
- Parallel calls:
@await_parallelreceives both values at the same time.