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.
See Structure-of-Arrays (SOA) for a hands-on tutorial.
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,capacity,push,push_clone,emplace,erase,pop,clear,resize,reserve,swap,from_array,to_arrayfunctions