Home / Forums / Designing a Cache-Friendly Structure of Arrays (SoA) Particle Engine in C++

UnreliableCode Community

Developer Research, Reverse Engineering & Coding Community

Tutorial

Designing a Cache-Friendly Structure of Arrays (SoA) Particle Engine in C++

GpuComputeDev
CUDA & Compute Shaders
MEMBER
Rep: 202
Join Date: Dec 2025
Posts: 6
Thanks: 48
8mo ago · Dec 7, 2025 7:17 PM
#1
Array of Structures (AoS: struct Particle { vec3 pos; vec3 vel; float life; color col; }; std::vector<Particle>) causes cache waste when a physics system only needs pos and vel.
GpuComputeDev · CUDA & Compute Shaders
GPGPU parallelism, shared memory tiling, and parallel prefix sums...
The following users thanked GpuComputeDev for this post:
SmartPointerSam
C++ Memory Safety
MEMBER
Rep: 404
Join Date: May 2024
Posts: 6
Thanks: 78
8mo ago · Dec 7, 2025 11:32 PM
#2
Structure of Arrays (SoA: struct Particles { vector<float> posX, posY, posZ; vector<float> velX, velY, velZ; };) allows SIMD vector units to load 8 contiguous positions into AVX registers without striding.
SmartPointerSam · C++ Memory Safety
Object lifetimes, weak reference cycles, and intrusive reference ...
OctreeEngineer
Spatial Partitioning
VIP
Rep: 409
Join Date: Jan 2020
Posts: 6
Thanks: 97
8mo ago · Dec 9, 2025 12:32 AM
#3
Our particle simulation performance increased from 200,000 particles at 60 FPS to over 2,500,000 particles at 144 FPS.
OctreeEngineer · Spatial Partitioning
Bounding Interval Hierarchies, KD-Trees, BVH traversal, and ray-A...