Skip to main content

Module soa

Module soa 

Source
Expand description

SoA (Structure-of-Arrays) extraction for GPU-friendly data layout.

ABM agents are stored as AoS (Array-of-Structures) in AgentStore. For GPU kernels, we need flat contiguous arrays of each field. SoaExtractable lets agent types define how to extract/write-back their data to/from flat f32 buffers suitable for GPU upload.

For workloads that require f64 precision (scientific simulations, long time horizons, or ill-conditioned dynamics), implement SoaExtractableF64 instead of or alongside SoaExtractable. The two traits are independent: an agent type may implement either, both, or neither. CUDA kernels that target f64 must declare double parameters.

Traits§

SoaExtractable
Trait for agents whose numeric fields can be extracted into SoA buffers and written back from SoA buffers after GPU computation.
SoaExtractableF64
Like SoaExtractable but using f64 columns.

Functions§

cast_columns_f32_to_f64
Convenience helper: upcast f32 columns to f64 columns.
cast_columns_f64_to_f32
Convenience helper: downcast f64 columns to f32 columns.
extract_soa
Extract SoA buffers from an AgentStore.
extract_soa_f64
Extract f64 SoA buffers from an AgentStore.
write_back_soa
Write SoA buffers back into an AgentStore.
write_back_soa_f64
Write f64 SoA buffers back into an AgentStore.