Skip to main content

Module sync

Module sync 

Source
Expand description

Synchronization primitives (barriers, atomics). CPU- and CUDA-compatible wrappers for spirv_std::arch functions.

On target_arch = "spirv", these delegate to the real SPIR-V intrinsics. On target_arch = "nvptx64", these use LLVM NVVM intrinsics for CUDA. On the CPU, they provide functional equivalents using std::sync primitives.

Shader code should import from this module instead of spirv_std::arch directly to enable CPU and CUDA execution.

Functionsยง

atomic_add_f32
Atomically adds a float value to the f32 stored (as u32 bits) at ptr.
atomic_add_i32
Atomically adds value to *ptr and returns the old value.
atomic_add_u32
Atomically adds value to *ptr (u32) and returns the old value.
atomic_add_u32_workgroup
Atomically adds value to *ptr (workgroup scope) and returns the old value.
atomic_and_u32
Atomically ANDs *ptr with value and returns the old value.
atomic_compare_exchange_u32
Atomically compares *ptr with comparator and, if equal, replaces with value. Returns the old value at *ptr.
atomic_exchange_u32
Atomically exchanges *ptr with value and returns the old value.
atomic_load_u32
Atomically loads the value at *ptr.
atomic_load_u32_shared
Atomically loads the value at *ptr from a shared reference.
atomic_load_u32_workgroup
Atomically loads *ptr (workgroup scope).
atomic_max_u32
Atomically computes max(*ptr, value) and returns the old value.
atomic_max_u32_workgroup
Atomically computes max(*ptr, value) (workgroup scope) and returns the old value.
atomic_min_u32
Atomically computes min(*ptr, value) and returns the old value.
atomic_or_u32
Atomically ORs *ptr with value and returns the old value.
atomic_store_u32_workgroup
Atomically stores value to *ptr (workgroup scope).
control_barrier
Control barrier with explicit execution scope, memory scope, and semantics.
subgroup_f_add
Subgroup (wave/warp) floating-point add reduction.
subgroup_f_max
Subgroup (wave/warp) floating-point max reduction.
workgroup_memory_barrier_with_group_sync
Workgroup memory barrier with group synchronization.