0PricingLogin
CUDA Academy · Lesson

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

  1. What a Memory Transaction Is
  2. Coalesced vs Strided Reads
  3. Structure of Arrays vs Array of Structs
  4. Measuring Effective Bandwidth
← Back to CUDA Academy