Explicit SIMD Vectorization with Modern C++
Loop vectorization remains a challenging task. While automatic vectorization from compilers can now handle a wide range of codes, the underlying dependency reasoning tends to fail when either data or control flow become too complex. Guided vectorization as, e. g., provided by OpenMP pragmas, allows the compiler to offload the reasoning to the developer and handle more code in turn. However, neither guided nor automatic vectorization has yet been able to generate suitable data structures for vectorized code. In this case, explicit vectorization remains the sole option for programmers. We present our general-purpose approach to explicitly vectorize complex loops based on C++ templates and the upcoming std::simd library. The core idea of this approach is the introduction of a SIMD index type, which allows loop bodies to be completely written in a simd-generic way. On top of that, we have developed the open source library SIMD_ACCESS, which complements std::simd. This library adds streamlined load and store expressions, residual and aligning loop handling and a framework for vectorizing data structures. We conclude the paper with a performance evaluation. We show that there is no performance overhead caused by our abstraction layer. Finally, we investigate and compare two different vectorization approaches of a loop in a Discontinous-Galerkin Spectral-Element Method in an industry-grade CFD code for unstructured meshes.
Authors
- Olaf Krzikalla
- Johannes Wendler (ORCID: https://orcid.org/0000-0001-6915-5383)
- Immo Huismann (ORCID: https://orcid.org/0009-0008-5827-9266)
Institutions
- Institute of Virology of the Slovak Academy of Sciences (SK)
Publication Details
- Published
- 2025-08-13
- DOI
- https://doi.org/10.1109/hpcc67675.2025.00033
- Primary Topic
- Parallel Computing and Optimization Techniques
- Type
- article
- Field-Weighted Citation Impact
- 0.00