arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2502.17075cs.PLcs.SE
收藏

用于优化高级 Julia IR 的等式饱和

Equality Saturation for Optimizing High-Level Julia IR

Jules Merckx, Tim Besard, Bjorn De Sutter

AI总结:

开发了基于 e-graphs 和等式饱和的系统,允许领域专家通过重写规则优化 Julia 代码,支持控制流、副作用、多重派发约束及类型传播,并提出 ILP 公式和 CFG 骨架松弛技术。

摘要:

编译器对于将高级语言编写的代码转换为高性能机器代码是不可或缺的,但其通用优化有时会显得不足。领域专家可能了解某些编译器无法应用或仅在特定领域有效的优化。我们开发了一个系统,允许领域专家表达重写规则来优化 Julia 编程语言中的代码。我们的系统基于 e-graphs 和等式饱和。它可以在存在控制流和副作用的情况下应用优化。由于 Julia 使用多重派发,我们允许用户通过参数类型约束重写规则,并通过 e-graph 表示传播类型信息。我们提出了一种 ILP 公式,用于考虑代码重用的支配属性的最优 e-graph 提取,并引入 CFG 骨架松弛,以重写对纯函数以及带有副作用的函数的调用。用例表明,我们的系统可以对高级、特定领域的代码以及较低级别的代码(如 Julia 的广播机制)执行重写。最后,我们分析了所需的编译时间。

英文摘要:

Compilers are indispensable for transforming code written in high-level languages into performant machine code, but their general-purpose optimizations sometimes fall short. Domain experts might be aware of certain optimizations that the compiler is unable to apply or that are only valid in a particular domain. We have developed a system that allows domain experts to express rewrite rules to optimize code in the Julia programming language. Our system builds on e-graphs and equality saturation. It can apply optimizations in the presence of control flow and side effects. As Julia uses multiple dispatch, we allow users to constrain rewrite rules by argument types, and propagate type information through the e-graph representation. We propose an ILP formulation for optimal e-graph extraction taking into account dominance properties for code reuse and introduce CFG skeleton relaxation to rewrite calls to pure functions as well as those with side effects. Use cases demonstrate that our system can perform rewrites on high-level, domain-specific code, as well as on lower-level code such as Julia's broadcasting mechanism. Finally, we analyze the required compilation time.

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

↑