一句话:提出 Hecate,将树遍历 DSL 编译为 ILP 编码,自动合成串行与并行树遍历。
高效处理树结构在编译器、数值计算与浏览器布局引擎中很重要:需将计算静态调度为少量遍历并尽量并行。手工设计易出错,现有自动调度器难以探索合法遍历空间,无法权衡并行度与遍历次数。本文提出 Hecate,可合成串行与并行树遍历,并允许程序员定义新遍历模板以扩展。Hecate 是求解器辅助的领域特定语言:将树遍历 DSL 翻译至求解器来自动生成合成器;进一步用面向调度的符号求值生成高效 ILP 编码。在 Grafter 问题集和 CSS 引擎遍历调度中,Hecate 权衡遍历融合与并行,支持任意子节点树;树渲染加速 2×,合成加速 3×,ILP 调度快数个数量级。
Efficient computation on tree data structures is important in compilers, numeric computations, and web browser layout engines. Efficiency is achieved by statically scheduling the computation into a small number of tree traversals and by performing the traversals in parallel when possible. Manual design of such traversals leads to bugs, as observed in web browsers. Automatic schedulers avoid these bugs but they currently cannot explore a space of legal traversals, which prevents exploring the trade-offs between parallelism and minimizing the number of traversals. We describe Hecate, a synthesizer of tree traversals that can produce both serial and parallel traversals. A key feature is that the synthesizer is extensible by the programmer who can define a template for new kinds of traversals. Hecate is constructed as a solver-aided domain-specific language, meaning that the synthesizer is generated automatically by translating the tree traversal DSL to an SMT solver that synthesizes the traversals. We improve on the general-purpose solver-aided architecture with a scheduling-specific symbolic evaluation that maintains the engineering advantages solver-aided design but generates efficient ILP encoding that is much more efficient to solve than SMT constraints. On the set of Grafter problems, Hecate synthesizes traversals that trade off traversal fusion to exploit parallelism. Additionally, Hecate allows defining a tree data structure with an arbitrary number of children. Together, parallelism and data structure improvements accelerate the computation 2× on a tree rendering problem. Finally, Hecate’s domain-specific symbolic compilation accelerates synthesis 3× compared to the general-purpose compilation to an SMT solver; when scheduling a CSS engine traversal, this ILP-based synthesis executes orders of magnitude faster.