Expand description
Common DSL marker functions shared across GPU backends.
These functions provide CPU-fallback implementations of GPU intrinsics. During transpilation, the CUDA and WGSL code generators recognize these function names and replace them with their backend-specific equivalents.
§Thread/Block Indices
| Function | CUDA | WGSL |
|---|---|---|
thread_idx_x() | threadIdx.x | local_invocation_id.x |
block_idx_x() | blockIdx.x | workgroup_id.x |
block_dim_x() | blockDim.x | WORKGROUP_SIZE_X |
grid_dim_x() | gridDim.x | num_workgroups.x |
§Math Functions
All math functions use Rust’s standard library for CPU fallback:
sqrt, rsqrt, floor, ceil, round, sin, cos, tan,
exp, log, fma.
Functions§
- block_
dim_ x - Get the block/workgroup dimension (x dimension).
- block_
dim_ y - Get the block/workgroup dimension (y dimension).
- block_
dim_ z - Get the block/workgroup dimension (z dimension).
- block_
idx_ x - Get the block/workgroup index (x dimension).
- block_
idx_ y - Get the block/workgroup index (y dimension).
- block_
idx_ z - Get the block/workgroup index (z dimension).
- ceil
- Ceiling.
- cos
- Cosine.
- exp
- Exponential (base e).
- floor
- Floor.
- fma
- Fused multiply-add:
a * b + c. - grid_
dim_ x - Get the grid/dispatch dimension (x dimension).
- grid_
dim_ y - Get the grid/dispatch dimension (y dimension).
- grid_
dim_ z - Get the grid/dispatch dimension (z dimension).
- log
- Natural logarithm (base e).
- powf
- Power:
x^y. - round
- Round to nearest.
- rsqrt
- Reciprocal square root.
- sin
- Sine.
- sqrt
- Square root.
- sync_
threads - Synchronize all threads in a block/workgroup.
- tan
- Tangent.
- thread_
fence - Thread/storage memory fence.
- thread_
fence_ block - Block-level/workgroup memory fence.
- thread_
idx_ x - Get the thread index within a block/workgroup (x dimension).
- thread_
idx_ y - Get the thread index within a block/workgroup (y dimension).
- thread_
idx_ z - Get the thread index within a block/workgroup (z dimension).