The official C++ MPI bindings were removed from the standard in 2008, leaving a gap that numerous third-party libraries have attempted to fill. However, existing wrappers typically cover only a limited subset of MPI or target specific use cases, falling short of a general-purpose solution. A recent conceptual paper proposed general design principles for modern C++ bindings based on C++20 concepts, without committing to a concrete interface. We present the first concrete realization of these principles in a layered architecture. At the foundation, we define a core layer: refined C++20 concepts formalizing the MPI standard's notion of data buffers, automatic mapping of standard C++ constructs, non-intrusive customization points for third-party types, and concept-based wrappers for MPI procedures. The result is a low-level native C++ MPI interface that works directly with STL containers, is highly extensible, and lends itself to standardization. Built on this core, we present KaMPIng-v2 -- a C++ MPI library offering the convenience and memory-safety of KaMPIng with composable, pipe-based syntax inspired by C++ ranges for efficient, boilerplate-free MPI programming. Finally, we demonstrate the core layer's broad applicability by designing lightweight adapters for GPU and performance-portability libraries, making the HPC ecosystem a first-class citizen in MPI. Kokkos views, Thrust device vectors, and SYCL buffers can be passed directly to MPI procedures, with adapter logic remaining self-contained. All contributions are backed by a fully functional open-source reference implementation, demonstrating the practical viability of the proposed design.
翻译:官方C++ MPI绑定于2008年从标准中移除,留下了众多第三方库试图填补的空白。然而,现有封装通常仅覆盖MPI的有限子集或针对特定用例,未能成为通用解决方案。近期一篇概念性论文提出了基于C++20概念实现现代C++绑定的通用设计原则,但未承诺具体接口。我们首次在分层架构中实现了这些原则的具体化。在底层,我们定义了一个核心层:通过精炼的C++20概念形式化MPI标准对数据缓冲区的定义、标准C++构造的自动映射、第三方类型的非侵入式定制点,以及基于概念的MPI过程封装。这产生了一个低层原生C++ MPI接口,可直接处理STL容器,具有高度可扩展性,并适合标准化。在此基础上,我们构建了KaMPIng-v2——一个C++ MPI库,在提供KaMPIng便利性与内存安全性的同时,采用受C++ ranges启发的可组合流水线式语法,实现高效、无模板代码的MPI编程。最后,我们通过为GPU和性能可移植性库设计轻量级适配器,展示了核心层的广泛适用性,使HPC生态系统成为MPI中的一等公民。Kokkos视图、Thrust设备向量和SYCL缓冲区可直接传递给MPI过程,且适配器逻辑保持自包含。所有贡献均基于功能完善的开源参考实现,论证了所提出设计的实际可行性。