.csl files, that each either demonstrate individual features of the language, or solve a larger application problem. A Python script, the run.py file, accompanies each program to run it with the simulator.
The source for these code examples is hosted at the SDK examples GitHub repository.
For the GEMV tutorial code examples, we additionally provide step-by-step explanations of the code in the Tutorials section.
If you’re just getting started, we recommend walking through the step-by-step tutorials in Tutorials to get a fuller explanation of these programs.
Compile the Code Examples
Each code example contains a CSL file as the top-level source file, typically namedlayout.csl. This file may reference additional CSL source files in that directory.
Each code example also contains a commands.sh script, which contains the commands required to compile and run it.
For example, the tutorials/gemv-01-complete-program/commands.sh in the SDK examples repository contains:
- First, cd into the directory that contains the CSL files.
- Then run the
cslccommand shown in thecommands.shfile to compile the program. Note, this command may span multiple lines and produces files with theelfextension. For example:
Run the Program
Use therun.py Python script that is in the code example directory to execute the compiled program. For example, to run the above compiled program, execute the following command in the gemv-01-complete-program directory:
SUCCESS! near the end of the output.
Debug Your Program
See Debugging Guide and SDK GUI.Move from Simulation to Hardware
After successfully simulating your CSL program, you can run it on hardware by following the guidelines below when usingcslc:
Pass the --arch Flag
Use the --arch flag with cslc to ensure the compiler targets the appropriate Cerebras system.
Allowed values are --arch=wse2 for WSE-2 architecture and --arch=wse3 for WSE-3 architecture. The default value is wse2. For example:
wse3 is not yet supported for all example programs.
Provide --fabric-dims
When compiling for simulation with cslc, the --fabric-dims flag can be any bounding box large enough to contain your program’s PEs. However, when compiling for hardware, these dimensions must match your Cerebras system’s fabric dimensions. For example:
Provide an IP Address to SdkRuntime
To run on the Cerebras system hardware, you must pass the IP and port address of the network-attached Cerebras system to thecmaddr argument of the SdkRuntime constructor in your run.py: