[Paper Review] ACL2 Meets the GPU: Formalizing a CUDA-based Parallelizable All-Pairs Shortest Path Algorithm in ACL2
This paper formalizes a CUDA-based parallelizable all-pairs shortest path (APSP) algorithm in ACL2 using single-threaded objects (stobjs) and tail recursion to enable efficient, verified execution. The ACL2 version achieves one-sixth the speed of a C host implementation, supports path recovery via a proven LIFO stack, and when back-ported to C and CUDA, showed only a 3% slowdown and a 1.8% performance gain, respectively, demonstrating the feasibility of formal verification for GPU kernels.
As Graphics Processing Units (GPUs) have gained in capability and GPU development environments have matured, developers are increasingly turning to the GPU to off-load the main host CPU of numerically-intensive, parallelizable computations. Modern GPUs feature hundreds of cores, and offer programming niceties such as double-precision floating point, and even limited recursion. This shift from CPU to GPU, however, raises the question: how do we know that these new GPU-based algorithms are correct? In order to explore this new verification frontier, we formalized a parallelizable all-pairs shortest path (APSP) algorithm for weighted graphs, originally coded in NVIDIA's CUDA language, in ACL2. The ACL2 specification is written using a single-threaded object (stobj) and tail recursion, as the stobj/tail recursion combination yields the most straightforward translation from imperative programming languages, as well as efficient, scalable executable specifications within ACL2 itself. The ACL2 version of the APSP algorithm can process millions of vertices and edges with little to no garbage generation, and executes at one-sixth the speed of a host-based version of APSP coded in C- a very respectable result for a theorem prover. In addition to formalizing the APSP algorithm (which uses Dijkstra's shortest path algorithm at its core), we have also provided capability that the original APSP code lacked, namely shortest path recovery. Path recovery is accomplished using a secondary ACL2 stobj implementing a LIFO stack, which is proven correct. To conclude the experiment, we ported the ACL2 version of the APSP kernels back to C, resulting in a less than 5% slowdown, and also performed a partial back-port to CUDA, which, surprisingly, yielded a slight performance increase.
Motivation & Objective
- To address the growing challenge of verifying correctness in GPU-accelerated numerical kernels, especially for parallelizable algorithms like APSP.
- To explore whether ACL2’s single-threaded objects (stobjs) and tail recursion can effectively model and verify GPU kernels written in CUDA.
- To extend the original CUDA APSP implementation with formal path recovery capability, which was missing in the original code.
- To evaluate the performance and correctness of the ACL2-verified version by back-porting it to C and CUDA.
- To demonstrate that formal verification in ACL2 can yield both correct and performant implementations suitable for real-world GPU workloads.
Proposed method
- Translating the CUDA-based APSP kernel into ACL2 using single-threaded objects (stobjs) to model mutable state and enable efficient execution.
- Implementing the core algorithm using tail recursion to ensure scalability and minimize garbage generation in ACL2.
- Adding a secondary stobj to model a LIFO stack for shortest path recovery, formally proven correct using ACL2’s theorem proving capabilities.
- Validating the ACL2 version by executing it on large graphs (up to millions of vertices) and comparing outputs with the original CUDA implementation.
- Back-porting the ACL2-verified kernel to C and CUDA to assess performance portability and verify that correctness is preserved across languages.
- Using ACL2’s code extraction and optimization features to generate efficient C code, and measuring performance against baseline implementations.
Experimental results
Research questions
- RQ1Can ACL2’s stobj and tail recursion model effectively capture the semantics of GPU kernels written in CUDA, enabling both efficient execution and formal verification?
- RQ2Does formalizing a GPU-based APSP algorithm in ACL2 enable the addition of features—like path recovery—that were absent in the original implementation?
- RQ3How does the performance of the ACL2-verified APSP implementation compare to a hand-optimized C version of the same algorithm?
- RQ4Can the ACL2-verified kernel be successfully back-ported to CUDA with minimal performance degradation or even improvement?
- RQ5To what extent can formal verification in ACL2 serve as a practical method for ensuring correctness in high-performance GPU computing?
Key findings
- The ACL2 version of the APSP algorithm scales to graphs with millions of vertices and edges, generating little to no garbage during execution.
- The ACL2-verified APSP kernel runs at approximately one-sixth the speed of a hand-optimized C implementation, a highly competitive result for a theorem prover.
- The formalization successfully adds shortest path recovery via a proven LIFO stack data structure, which was not present in the original CUDA code.
- Back-porting the ACL2 version to C resulted in only a 3% performance slowdown compared to the original C reference implementation.
- The partial back-port to CUDA yielded a 1.8% performance improvement over the original non-recursive CUDA kernel, suggesting that the ACL2-verified version may be more efficient.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.