C++ Parallel Algorithms for GPU Programming: A Case Study with the Lattice Boltzmann Method
Speaker: Jonas Latt, University of Geneva
Presentation
Seminar Slide Deck (PDF-2.3MB)
Abstract
Starting with C++17, the C++ standard offers a way to express multi-threaded parallelism implicitly in the form of parallel algorithms. With this formalism, some of the calls to algorithms of the C++ standard template library (STL) are executed on a given parallel platform, which is selected by the compiler and STL implementation. The approach does not rely on language extensions, external libraries, vendor-specific code annotations, or pre-compilation stages. It is also highly maintainable, as the same code can be compiled both for multi-core CPUs and for selected hardware accelerators, which include NVIDIA GPUs, thanks to the backend for parallel algorithms that was recently added to the NVC++ compiler. In this presentation, the principles of C++ parallel algorithms are explained, and the simple case of the 2D heat equation is used to showcase the application of this formalism to numerical algorithms. The presentation then carries on with an introduction to the STLBM, an open-source proof-of-principle implementation of lattice Boltzmann (LB) algorithms for fluid flow, based on parallel algorithms. It is shown that with a quite straightforward code, and without the use of any platform-specific techniques, performances close to the state-of-the-art are achieved on both homogeneous and heterogeneous multi-threaded platforms. It is for example shown that a complex, turbulent flow problem (a turbulent flow in a lid-driven 3D cavity) can be simulated at 73% of the peak performance (as prescribed by the memory bandwidth) of a NVIDIA A100 device, while an optimized CUDA reference implementation for the same problem reaches 84% of the peak performance. The approach is applied to a variety of modern LB collision models. The achieved performance on GPU is discussed and put in perspective with the type of improvements delivered by the models, mostly in terms of robustness.
Biography