This section documents CSL builtins that are only supported for WSE-3.Documentation Index
Fetch the complete documentation index at: https://sdk.cerebras.ai/llms.txt
Use this file to discover all available pages before exploring further.
@get_ut_id
Create a value of typeut_id from the provided integer identifier.
Syntax
idis a comptime-known expression of any unsigned integer type, or a runtime expression of typeu16.
Semantics
Ifid is comptime-known, the builtin will only accept integers
in the target architecture’s valid range for microthread IDs.
If id is not comptime-known, its type must be u16.
In this case no runtime checks are performed to ensure that id is
within the range of valid microthread IDs.
@queue_flush
Activates the teardown task ID (see teardown) once the given queue becomes empty.Syntax
queue_idis an expression of typeinput_queueoroutput_queue.
Example
Semantics
The builtin can only be evaluated at runtime, and therefore it cannot appear during comptime evaluation or during the evaluation of a top-level comptime or layout block. The builtin’s return type isvoid.
Calling the builtin will cause the teardown task to be activated once the
input (or output) queue associated with queue_id becomes empty or is
already empty.
It is guaranteed that if the teardown task is activated because of a call
to @queue_flush then the respective queue will be empty.
From within the teardown task the queue_flush library
(see queue_flush)
can be used to check whether the teardown task was activated due to
a call to queue_flush for a given queue or not.
@set_control_task_table
Create a separate control task table.Syntax
-
configis a comptime-known (anonymous) struct with the following optional fields:instructionsstride
Example
Semantics
The@set_control_task_table builtin will decouple control tasks
from data and local tasks by creating a separate task table that is
dedicated to control tasks.
The builtin can only be called at most once during the evaluation of a
top-level comptime block.
It can have an optional argument that must be a comptime-known struct
with two optional fields: instructions and stride.
If @set_control_task_table is called without an argument then the
default values for instructions and stride will be used (see
below).
The instructions field can be used to specify the number of instructions
for each entry point in the new control task table. The number of instructions
must be a comptime-known integer value within the valid set of options which are
2, 4 and 8. The default value is 4.
The stride field requires a comptime-known integer value that represents the
stride - in number of entry points - per input queue’s local control table index
(see @initialize_queue). Its value should be in the
range [1, 7] and the default value is 1.
@set_empty_queue_handler
Set a function to be the empty queue handler for a given queue.Syntax
funcis the name of a function with no input parameters andvoidreturn type.queue_idis a comptime-known expression of typeinput_queueoroutput_queue.
Example
Semantics
The@set_empty_queue_handler builtin must appear in a top-level
comptime block. When @queue_flush
(see @queue_flush) has been called for a qiven
queue (input or output) and the teardown task is activated due to that
queue becoming empty, then the function associated with that queue,
through a call to @set_empty_queue_handler, will be executed.
The user is responsible for resetting the status of the queue flush status
register through the queue_flush submodule of the <tile_config>
library (see queue_flush).
Calling @set_empty_queue_handler for the same queue more than once
is not allowed and will result in an error.
If there is at least 1 call to @set_empty_queue_handler in the program
then no task is allowed to be bound to the teardown task ID and vice-versa.
The teardown task ID is the value returned by the CSL standard library through
the teardown API (see teardown).
@bind_rotating_tasks
Bind a pair of tasks, a data task and a control task, and enable rotation between those tasks.Syntax
mainis a data task handler.altis a control task handler.task_idis a comptime-known expression of typedata_task_id.configis a comptime-known anonymous struct with the following fields:init(optional) is a comptime-known non-negative integer that may not exceedlimit.limit(required) is a comptime-known non-negative integer.
Example
Semantics
The@bind_rotating_tasks builtin enables task rotation for a pair of tasks.
Task rotation is a WSE-3 hardware feature that allows us to execute a different
task every Nth data task start.
Task main must be a data task, which means that it must have input parameters
corresponding to input wavelets, while task alt must be a control task.
WSE-3 can only support two concurrent pairs of rotating tasks. Therefore, the
builtin can only be called at most twice during the evaluation of a top-level
comptime block.
When @bind_rotating_tasks is called, task main gets bound to task_id,
which must be of type data_task_id, while task alt gets bound to control
task id zero. In other words, a call to @bind_rotating_tasks is equivalent
to @bind_data_task(main, task_id) and
@bind_control_task(alt, @get_control_task_id(0)).
Task alt is the same task that would be started if a control wavelet with
control task id zero arrived from the input queue that is associated with
task_id.
This means that if @bind_rotating_tasks is called more than once, then the
input queue associated with the task_id of each call must have its own
dedicated control task table (see
@set_control_task_table) in order to prevent
multiple control tasks bound to control task id zero from clashing.
Every time task main starts, a counter is compared against limit. If the
counter equals limit then task alt starts instead of main and the counter
resets to zero.
The initial value of the counter can be optionally specified through the init
field. If it is not specified then it defaults to zero.
