arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2309.04660cs.PL
收藏

在稠密和稀疏数组上编译递推

Compiling Recurrences over Dense and Sparse Arrays

Shiv Sundram, Muhammad Usman Tariq, Fredrik Kjolstad

AI总结:

提出一种通用编译框架,通过用户指定的递推系统、数据结构和调度原语,将递推方程自动编译为稠密或稀疏数据结构上的本地并行代码,其性能可与手写库实现相媲美。

摘要:

递推方程是许多计算范式的核心,包括动态规划、图分析和线性求解器。这些方程的计算成本通常很高,已有大量工作致力于在不同情况下对其进行优化。递推实现集合是一个庞大的设计空间,涵盖所有递推集合(例如 Viterbi 和 Floyd-Warshall 算法)、数据结构的选择(例如稠密和稀疏矩阵)以及不同的循环顺序集合。该设计空间中的大多数点不存在优化的库实现,因此开发者通常必须手动实现并优化递推。我们提出了一个通用框架,可将递推方程编译为对应于该通用设计空间中任意有效点的本地代码。在此框架中,用户需指定递推系统、用于存储输入和输出的数据结构类型,以及一组用于优化的调度原语。随后,贪婪算法接收此规范,并将其降级为遵循递推方程固有依赖关系的本地程序。我们描述了将此高级规范降级为适用于稀疏或稠密数据结构的本地并行代码所需的编译器转换,并提供了一种算法来确定递推系统是否可使用所提供的调度原语求解。我们在来自稠密和稀疏矩阵求解器、动态规划、图问题及稀疏张量代数等领域的各种计算任务上评估了生成代码的性能与正确性。我们证明,生成的代码与库中手写实现的性能相当。

英文摘要:

Recurrence equations lie at the heart of many computational paradigms including dynamic programming, graph analysis, and linear solvers. These equations are often expensive to compute and much work has gone into optimizing them for different situations. The set of recurrence implementations is a large design space across the set of all recurrences (e.g., the Viterbi and Floyd-Warshall algorithms), the choice of data structures (e.g., dense and sparse matrices), and the set of different loop orders. Optimized library implementations do not exist for most points in this design space, and developers must therefore often manually implement and optimize recurrences. We present a general framework for compiling recurrence equations into native code corresponding to any valid point in this general design space. In this framework, users specify a system of recurrences, the type of data structures for storing the input and outputs, and a set of scheduling primitives for optimization. A greedy algorithm then takes this specification and lowers it into a native program that respects the dependencies inherent to the recurrence equation. We describe the compiler transformations necessary to lower this high-level specification into native parallel code for either sparse and dense data structures and provide an algorithm for determining whether the recurrence system is solvable with the provided scheduling primitives. We evaluate the performance and correctness of the generated code on various computational tasks from domains including dense and sparse matrix solvers, dynamic programming, graph problems, and sparse tensor algebra. We demonstrate that generated code has competitive performance to handwritten implementations in libraries.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑