The Message Passing Interface (MPI) is widely used in parallel, high-performance programming, yet writing bug-free software that uses MPI remains difficult. We introduce DafnyMPI, a novel, scalable approach to formally verifying MPI software. DafnyMPI allows proving deadlock freedom, termination, and functional equivalence with simpler sequential implementations. In contrast to existing specialized frameworks, DafnyMPI avoids custom concurrency logics and instead relies on Dafny, a verification-ready programming language used for sequential programs, extending it with concurrent reasoning abilities. DafnyMPI is implemented as a library that enables safe MPI programming by requiring users to specify the communication topology upfront and to verify that calls to communication primitives such as MPI_ISEND and MPI_WAIT meet their preconditions. We formalize DafnyMPI using a core calculus and prove that the preconditions suffice to guarantee deadlock freedom. Functional equivalence is proved via rely-guarantee reasoning over message payloads and a system that guarantees safe use of read and write buffers. Termination and the absence of runtime errors are proved using standard Dafny techniques. To further demonstrate the applicability of DafnyMPI, we verify numerical solutions to three canonical partial differential equations. We believe DafnyMPI demonstrates how to make formal verification viable for a broader class of programs and provides proof engineers with additional tools for software verification of parallel and concurrent systems.
翻译:消息传递接口(MPI)在并行高性能编程中被广泛使用,但编写无错误的MPI软件仍然困难。我们提出了DafnyMPI,一种新颖、可扩展的形式化验证MPI软件的方法。DafnyMPI能够证明死锁自由性、终止性以及与更简单的顺序实现之间的功能等价性。与现有的专用框架不同,DafnyMPI避免了自定义并发逻辑,而是依赖于Dafny——一种用于顺序程序的、具备验证就绪特性的编程语言,并通过扩展使其具备并发推理能力。DafnyMPI被实现为一个库,它要求用户预先指定通信拓扑,并验证对通信原语(如MPI_ISEND和MPI_WAIT)的调用满足其前置条件,从而实现安全的MPI编程。我们使用核心演算对DafnyMPI进行了形式化,并证明了这些前置条件足以保证死锁自由性。功能等价性通过对消息负载的依赖-保证推理以及一个保证读写缓冲区安全使用的系统来证明。终止性和运行时错误的缺失则使用标准的Dafny技术进行证明。为了进一步展示DafnyMPI的适用性,我们验证了三个典型偏微分方程的数值解。我们相信DafnyMPI展示了如何使形式化验证适用于更广泛的程序类别,并为并行和并发系统的软件验证提供了额外的工具给验证工程师。