In computing, an array of structures (AoS), structure of arrays (SoA) or array of structures of arrays (AoSoA) are contrasting ways to arrange a sequence of records in memory, with regard to interleaving, and are of interest in SIMD and SIMT programming.
record (or 'struct' in the C programming language) into one parallel array per field. The motivation is easier manipulation with packed SIMD instructions in most instruction set architectures, since a single SIMD register can load internal datapath (e.g. 128-bit). If only a specific part of the record is needed, only those parts need to be iterated over, allowing more data to fit onto a single cache line. The downside is requiring more cache ways when traversing data, and inefficient indexed addressing.For example, to store N points in 3D space using a structure of arrays:
For example, to store N points in 3D space using an array of structures:
Although most GPU hardware has moved away from 4D instructions to scalar SIMT pipelines, modern compute kernels using SoA instead of AoS can still give better performance due to memory coalescing.
Software support
SoA is mostly found in languages, libraries, or metaprogramming tools used to support a data-oriented design. Examples include:
- "Data frames", as implemented in R, Python's Pandas package, and Julia's DataFrames.jl package, are interfaces to access SoA like AoS.
- The Julia package StructArrays.jl allows for accessing SoA as AoS to combine the performance of SoA with the intuitiveness of AoS.
- Code generators for the C language, including Datadraw and the X Macro technique.
Automated creation of AoSoA is more complex. An example of AoSoA in metaprogramming is found in LANL's Cabana library written in C++; it assumes a vector width of 16 lanes by default.
Plus d articles de Worldlex Wiki
Revenez a l index pour explorer davantage de pages sur l histoire, la science, la culture, la geographie et la societe en francais.
Explorer l index