[论文解读] ACL2 Meets the GPU: Formalizing a CUDA-based Parallelizable All-Pairs Shortest Path Algorithm in ACL2
本文在ACL2中使用单线程对象(stobjs)和尾递归形式化了一种基于CUDA的可并行化全源最短路径(APSP)算法,以实现高效且经过验证的执行。ACL2版本的执行速度达到C语言主机实现的六分之一,通过形式化证明的LIFO栈支持路径恢复,并在回传至C和CUDA后,分别仅出现3%的性能下降和1.8%的性能提升,证明了对GPU内核进行形式化验证的可行性。
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.
研究动机与目标
- 为应对GPU加速数值内核中正确性验证日益增长的挑战,特别是针对可并行化算法(如APSP)的验证。
- 探索ACL2的单线程对象(stobjs)和尾递归是否能有效建模并验证用CUDA编写的GPU内核。
- 在原始CUDA APSP实现的基础上,增加形式化路径恢复功能,该功能在原始代码中缺失。
- 通过将ACL2验证版本回传至C和CUDA,评估其性能和正确性。
- 证明ACL2中的形式化验证能够生成既正确又高效的实现,适用于实际的GPU工作负载。
提出的方法
- 使用单线程对象(stobjs)将基于CUDA的APSP内核翻译为ACL2,以建模可变状态并实现高效执行。
- 通过尾递归实现核心算法,以确保可扩展性并最小化ACL2中的垃圾生成。
- 添加第二个stobj以建模LIFO栈,用于最短路径恢复,并使用ACL2的定理证明能力形式化证明其正确性。
- 通过在大规模图(最多数百万个顶点)上执行ACL2版本并将其输出与原始CUDA实现进行比较,验证ACL2版本的正确性。
- 将ACL2验证的内核回传至C和CUDA,以评估性能可移植性,并验证正确性在不同语言间的一致性。
- 利用ACL2的代码提取和优化功能生成高效C代码,并与基线实现对比测量性能。
实验结果
研究问题
- RQ1ACL2的stobj和尾递归是否能有效捕捉用CUDA编写的GPU内核语义,从而实现高效执行和形式化验证?
- RQ2在ACL2中形式化GPU-based APSP算法是否能成功添加原始实现中缺失的功能(如路径恢复)?
- RQ3ACL2验证的APSP实现性能与同一算法的手动优化C版本相比如何?
- RQ4ACL2验证的内核是否能成功回传至CUDA,且性能下降最小化,甚至实现性能提升?
- RQ5在高性能GPU计算中,ACL2中的形式化验证在多大程度上可作为确保正确性的实用方法?
主要发现
- ACL2版本的APSP算法可扩展至包含数百万个顶点和边的图,在执行过程中生成极少甚至无垃圾。
- ACL2验证的APSP内核运行速度约为手动优化C实现的六分之一,对于定理证明器而言是极具竞争力的结果。
- 形式化成功通过经证明的LIFO栈数据结构添加了最短路径恢复功能,该功能在原始CUDA代码中缺失。
- 将ACL2版本回传至C后,与原始C参考实现相比仅出现3%的性能下降。
- 部分回传至CUDA后,相比原始非递归CUDA内核实现了1.8%的性能提升,表明ACL2验证版本可能更具效率。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。