Abstraction for AoS and SoA layout in C
暂无分享,去创建一个
Publisher Summary Memory access patterns are critical for performance, especially on parallel architectures such as graphics processing units (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 container from the AoS to the SoA layout or vice versa. This chapter presents an abstraction layer that allows switching between the AoS and SoA layouts in C++ without having to change the data access syntax. A few changes to the structure and container definitions allow for easy performance comparison of AoS vs. SoA on existing AoS code. This abstraction retains the more intuitive AoS syntax (container[index].component) for data access yet allows switching between the AoS and SoA layouts with a single template parameter in the container type definition on the CPU and GPU. In this way, code development becomes independent of the data layout and performance is improved by choosing the correct layout for the application's usage pattern.
[1] Xiaoming Li,et al. CUDA Memory Optimizations for Large Data-Structures in the Gravit Simulator , 2009, 2009 International Conference on Parallel Processing Workshops.
[2] James Abel,et al. Applications Tuning for Streaming SIMD Extensions , 1999 .
[3] Georgi Gaydadjiev,et al. SAMS multi-layout memory: providing multiple views of data to boost SIMD performance , 2010, ICS '10.