Annotation-guided AoS-to-SoA conversions and GPU offloading with data views in C++

Reading time: 3 minute
...

📝 Original Info

  • Title: Annotation-guided AoS-to-SoA conversions and GPU offloading with data views in C++
  • ArXiv ID: 2502.16517
  • Date: 2025-02-23
  • Authors: Pawel K. Radtke, Tobias Weinzierl

📝 Abstract

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.

💡 Deep Analysis

Deep Dive into Annotation-guided AoS-to-SoA conversions and GPU offloading with data views in C++.

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 AR

📄 Full Content

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.

📸 Image Gallery

cell_legend.webp dcalcdcr.webp density_cell0064_aos.webp density_cell1024_aos.webp density_continuous_active_local_coalesced_dist_check.webp density_continuous_generic_dist_check-relative.webp density_gpu_scattered_generic_dist_check.webp density_gpu_scattered_generic_dist_check_shmem.webp density_gpu_scattered_generic_no_dist_check.webp density_gpu_scattered_generic_no_dist_check_shmem.webp density_scattered_generic_dist_check-relative.webp density_scattered_generic_dist_check.webp density_scattered_generic_no_dist_check-relative.webp density_scattered_generic_no_dist_check.webp density_variants_legend.webp drift_cell0064_aos.webp drift_cell1024_aos.webp drift_continuous_generic-relative.webp drift_gpu_scattered_generic.webp drift_gpu_scattered_generic_shmem.webp drift_scattered_generic-relative.webp drift_variants_legend.webp generic-ordered.webp generic-unordered.webp plot-1-aarch64-density-legend.webp plot-1-aarch64-density.webp plot-1-aarch64-drift.webp plot-1-aarch64-force.webp plot-1-aarch64-kick1.webp plot-1-aarch64-kick2.webp plot-1-x64-density-legend.webp plot-1-x64-density.webp plot-1-x64-drift.webp plot-1-x64-force.webp plot-1-x64-kick1.webp plot-1-x64-kick2.webp plot-2-aarch64-density-legend.webp plot-2-aarch64-density.webp plot-2-aarch64-drift.webp plot-2-aarch64-force.webp plot-2-aarch64-kick1.webp plot-2-aarch64-kick2.webp plot-2-x64-density-legend.webp plot-2-x64-density.webp plot-2-x64-drift.webp plot-2-x64-force.webp plot-2-x64-kick1.webp plot-2-x64-kick2.webp plot-3-aarch64-density-legend.webp plot-3-aarch64-density.webp plot-3-aarch64-drift.webp plot-3-aarch64-force.webp plot-3-aarch64-kick1.webp plot-3-aarch64-kick2.webp plot-4-aarch64-density-legend.webp plot-4-aarch64-density.webp plot-4-aarch64-drift.webp plot-4-aarch64-force.webp plot-4-aarch64-kick1.webp plot-4-aarch64-kick2.webp

Reference

This content is AI-processed based on ArXiv data.

Start searching

Enter keywords to search articles

↑↓
ESC
⌘K Shortcut