Address spaces
Device memory
All kernel buffer parameters (A: enigma.f32, etc.) are in device memory. Indexed access emits global loads and stores:
vec_width=4, Enigma emits device float4* paths where alignment allows, improving memory bandwidth utilization.
Threadgroup (shared) memory
Threadgroup memory is a scratchpad shared by all threads in a threadgroup. It is fast, limited (typically 32 KB), and requires explicit synchronization. Allocate withenigma.threadgroup_alloc:
- Always call
enigma.barrier()between a write and a cross-thread read. - Allocation size is fixed at compile time.
- The
mem_flagsargument controls which memory types the barrier synchronizes.
Barrier flags
Scalar parameters
enigma.Scalar(dtype) parameters are lowered as 1-element device buffers and auto-loaded at kernel entry. Use them for per-dispatch constants that vary across calls:
Higher-level memory primitives
The DSL provides register-and-pipeline building blocks for staged compute patterns:
These are building blocks for advanced tiled GEMM and attention kernels. See Layout Algebra for the tiling workflow.
