Structure of Arrays vs Array of Structs
Choosing layouts that coalesce.
Two Ways to Store Records
Say each particle has x, y, and z. You can keep them together or split them apart, and that choice changes how every warp coalesces.
Array of Structs
The natural C++ layout packs each record's fields side by side. This is an array of structs, often shortened to AoS.
struct Particle { float x, y, z; };
Particle p[N];All lessons in this course
- What a Memory Transaction Is
- Coalesced vs Strided Reads
- Structure of Arrays vs Array of Structs
- Measuring Effective Bandwidth