Chapter 31

Abstraction for AoS and SoA Layout in C++

Robert Strzodka

Memory access patterns are critical for performance, especially on parallel architectures such as GPUs. Because of this, the choice between an array-of-structures (AoS) data layout and a structure-of-arrays (SoA) layout has a large impact on overall program performance. However, it is not always obvious which layout will better serve a particular application, and testing both of them by hand in C++ is tedious because their syntax greatly differs. Not only is the syntax for defining the container different, but worse, the syntax for accessing the data within the container is different, leading to anywhere from tens to thousands of source code changes needed to switch any given ...

Get GPU Computing Gems Jade Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.