5.6. SOA (Structure of Arrays) transformation
The SOA (Structure of Arrays) module transforms array-of-structures data layouts into structure-of-arrays layouts for better cache performance. It provides macros that generate parallel arrays for each field of a structure, enabling SIMD-friendly data access patterns.
All functions and symbols are in “soa” module, use require to get access to it.
require daslib/soa
5.6.1. Structures
- soa.SOA_INDEX
Proxy type returned by the [] operator on an SOA structure.
Field access on this proxy is rewritten by SoaCallMacro to index into the correct column array.
5.6.2. Function annotations
- soa.SoaCallMacro
Rewrites soa[index].field into soa.field[index] at compile time.
This is the core of the SOA access pattern — it transforms AOS-style element access
into column-wise array indexing for better cache locality.
5.6.3. Structure macros
- soa.soa
Generates a Structure-of-Arrays layout from a regular struct.
For a struct Foo with fields x : float and y : float, generates:
Foo`SOA— struct where every field isarray<FieldType>
operator []returningSOA_INDEXproxy
length,push,emplace,push_clone,erasefunctions
5.6.4. SOA field access
- SOA_INDEX.(src: SOA_INDEX; field: string)
Field access operator for SOA_INDEX; rewritten by SoaCallMacro to convert soa[index].field into soa.field[index].
- Arguments:
src : SOA_INDEX
field : string