Saved in:
Bibliographic Details
Main Authors: Radtke, Pawel K., Weinzierl, Tobias
Format: Preprint
Published: 2025
Subjects:
Online Access:https://arxiv.org/abs/2502.16517
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866914034663555072
author Radtke, Pawel K.
Weinzierl, Tobias
author_facet Radtke, Pawel K.
Weinzierl, Tobias
contents The C++ programming language provides classes and structs as fundamental modeling entities. Consequently, C++ code tends to favour array-of-structs (AoS) for encoding data sequences, even though structure-of-arrays (SoA) yields better performance for some calculations. We propose a C++ language extension based on attributes that allows developers to guide the compiler in selecting memory arrangements, i.e.~to select the optimal choice between AoS and SoA dynamically depending on both the execution context and algorithm step. The compiler can then automatically convert data into the preferred format prior to the calculations and convert results back afterward. The compiler handles all the complexity of determining which data to convert and how to manage data transformations. Our implementation realises the compiler-extension for the new annotations in Clang and demonstrates their effectiveness through a smoothed particle hydrodynamics (SPH) code, which we evaluate on an Intel CPU, an ARM CPU, and a Grace-Hopper GPU. While the separation of concerns between data structure and operators is elegant and provides performance improvements, the new annotations do not eliminate the need for performance engineering. Instead, they challenge conventional performance wisdom and necessitate rethinking approaches how to write efficient implementations.
format Preprint
id arxiv_https___arxiv_org_abs_2502_16517
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Annotation-guided AoS-to-SoA conversions and GPU offloading with data views in C++
Radtke, Pawel K.
Weinzierl, Tobias
Mathematical Software
Performance
Programming Languages
The C++ programming language provides classes and structs as fundamental modeling entities. Consequently, C++ code tends to favour array-of-structs (AoS) for encoding data sequences, even though structure-of-arrays (SoA) yields better performance for some calculations. We propose a C++ language extension based on attributes that allows developers to guide the compiler in selecting memory arrangements, i.e.~to select the optimal choice between AoS and SoA dynamically depending on both the execution context and algorithm step. The compiler can then automatically convert data into the preferred format prior to the calculations and convert results back afterward. The compiler handles all the complexity of determining which data to convert and how to manage data transformations. Our implementation realises the compiler-extension for the new annotations in Clang and demonstrates their effectiveness through a smoothed particle hydrodynamics (SPH) code, which we evaluate on an Intel CPU, an ARM CPU, and a Grace-Hopper GPU. While the separation of concerns between data structure and operators is elegant and provides performance improvements, the new annotations do not eliminate the need for performance engineering. Instead, they challenge conventional performance wisdom and necessitate rethinking approaches how to write efficient implementations.
title Annotation-guided AoS-to-SoA conversions and GPU offloading with data views in C++
topic Mathematical Software
Performance
Programming Languages
url https://arxiv.org/abs/2502.16517