Blog Logo
TAGS

StructureOfArraysGenerator - Generating Cache and SIMD Friendly Data Structures for High-Performance Code in .NET and Unity

StructureOfArraysGenerator is a source generator that generates structure of arrays (SoA) data structure in .NET and Unity. The standard C# array is an array of structures (AoS), whereas the SoA is more suitable for utilizing the CPU cache and for ultra-fast parallel processing by SIMD. MultiArray is x2 faster and SIMD version (SoA is easy to write SIMD) is x10 faster. The generated code minimizes memory and heap usage in C#. The package provides only analyzer and the generated code does not depend on any other libraries. To use it, make a readonly partial struct type with [MultiArray] attribute. The package is distributed via NuGet. For Unity, the requirements and installation process are completely different. See the documentation for details.