Skip to main content

Module dsl_common

Module dsl_common 

Source
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

FunctionCUDAWGSL
thread_idx_x()threadIdx.xlocal_invocation_id.x
block_idx_x()blockIdx.xworkgroup_id.x
block_dim_x()blockDim.xWORKGROUP_SIZE_X
grid_dim_x()gridDim.xnum_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).