在BuildIt系统中使用预言变量进行反向数据流分析
Prophecy Variables, Program Analysis, Binding Times, and Staged Compilation in the BuildIt System
AI总结:
BuildIt系统通过预言变量和重复前向执行实现无需反向分析的程序转换与优化。
摘要:
许多程序转换和优化需要了解程序的未来行为。通常的方法是构建中间程序表示,然后使用反向程序分析将相关信息沿着控制流反向传播到转换/优化位置。我们提出使用预言变量,这些变量预测程序的未来执行信息,以实现此类转换和优化。我们将在BuildIt中实现预言变量,这是一个轻量级的领域特定语言实现系统。BuildIt使用分阶段编译来实现嵌入在标准通用编程语言(C++)中的高性能领域特定语言。BuildIt的第一阶段使用标准C++程序执行生成优化的C、C++和CUDA第二阶段代码。这种方法使BuildIt能够消除编程语言实现组件,如解析器和中间表示,从而大幅减少实现领域特定语言所需的工程工作量。预言变量与重复前向程序执行的结合使BuildIt能够扩展这种方法,以包括需要了解程序未来执行信息的转换和优化,而无需反向分析和无需实现这些分析相关的工程开销。我们正式化了使用预言变量的目的,讨论了在BuildIt中实现预言变量和重复执行,以及展示了从BuildIt计算中受益于预言变量提供的信息的优化实验结果。
英文摘要:
BuildIt is a lightweight C++ library system for implementing domain specific languages (DSLs) and compilers through multi-stage execution. It uses partial evaluation to generate optimized code without requiring parsers, explicit intermediate representations (IRs), or custom code generators. History variables and forward execution support analyses of past computation, but optimizations such as data movement, operator fusion, and binding-time analysis also require information about future execution. We introduce prophecy variables into BuildIt to predict future program behavior and guide code generation. Repeated first-stage execution refines predictions until they satisfy the program's checks, extending BuildIt's existing reexecution machinery with little additional complexity. This approach obtains information typically computed by backwards dataflow analyses over an explicit IR while preserving BuildIt's lightweight implementation model. The cost of first-stage reexecution can be amortized over repeated executions of the generated code. We formalize the mechanism and mechanize its guarantees in Lean 4. We demonstrate prophecy variables in three applications: selective CPU-GPU data movement, neural-network operator fusion, and automatic binding-time analysis. These applications achieve performance improvements of up to 5.5x while simplifying the programming interface.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。