The performance gap between CPU and memory widens continuously. Choosing the best memory layout for each hardware architecture is increasingly important as more and more programs become memory bound. For portable codes that run across heterogeneous hardware architectures, the choice of the memory layout for data structures is ideally decoupled from the rest of a program. This can be accomplished via a zero-runtime-overhead abstraction layer, underneath which memory layouts can be freely exchanged. We present the Low-Level Abstraction of Memory Access (LLAMA), a C++ library that provides such a data structure abstraction layer with example implementations for multidimensional arrays of nested, structured data. LLAMA provides fully C++ compliant methods for defining and switching custom memory layouts for user-defined data types. The library is extensible with third-party allocators. Providing two close-to-life examples, we show that the LLAMA-generated AoS (Array of Structs) and SoA (Struct of Arrays) layouts produce identical code with the same performance characteristics as manually written data structures. Integrations into the SPEC CPU\textsuperscript{\textregistered} lbm benchmark and the particle-in-cell simulation PIConGPU demonstrate LLAMA's abilities in real-world applications. LLAMA's layout-aware copy routines can significantly speed up transfer and reshuffling of data between layouts compared with naive element-wise copying. LLAMA provides a novel tool for the development of high-performance C++ applications in a heterogeneous environment.
翻译:CPU 和 内存之间的性能差距会持续扩大。 选择每个硬件架构的最佳内存布局将变得越来越重要, 因为越来越多的程序会被内存约束。 对于跨多种硬件架构运行的便携式代码, 数据结构的内存布局的选择最好与程序的其余部分脱钩。 可以通过零运行时间覆盖式的抽象层来完成, 在这种层下可以自由交换内存布局。 我们展示了低水平内存存存存存存存存存存存存存存存存存存( LLLAMA) 和 SOA 库, 提供这样的数据结构抽象层, 以及嵌套式、 结构化数据的多功能。 LLAMA 提供了完全C++A 符合定义和切换用户定义数据类型自定义内存储布局的自定义内容布局的全 C++A 方法。 提供两个接近寿命的缩略图样的缩略图, 我们显示LAMA 和SLA RODRA 的平流翻版版布局与手动式数据结构结构结构结构的硬性数据结构的硬体化性平版化内, 内, IMALMA 的内, 和SLMA IMLMA 的磁性平流平流缩缩缩缩缩缩缩图图能应用程序应用程序应用程序能能能能能能将大量平基路基路基件。