Caviar: an e-graph based TRS for automatic code optimization

Smail Kourta, Adel Namani, Fatima Benbouzid-Si Tayeb, K. Hazelwood, Chris Cummins, Hugh Leather, Riyadh Baghdadi
{"title":"Caviar: an e-graph based TRS for automatic code optimization","authors":"Smail Kourta, Adel Namani, Fatima Benbouzid-Si Tayeb, K. Hazelwood, Chris Cummins, Hugh Leather, Riyadh Baghdadi","doi":"10.1145/3497776.3517781","DOIUrl":null,"url":null,"abstract":"Term Rewriting Systems (TRSs) are used in compilers to simplify and prove expressions. State-of-the-art TRSs in compilers use a greedy algorithm that applies a set of rewriting rules in a predefined order (where some of the rules are not axiomatic). This leads to a loss of the ability to simplify certain expressions. E-graphs and equality saturation sidestep this issue by representing the different equivalent expressions in a compact manner from which the optimal expression can be extracted. While an e-graph-based TRS can be more powerful than a TRS that uses a greedy algorithm, it is slower because expressions may have a large or sometimes infinite number of equivalent expressions. Accelerating e-graph construction is crucial for making the use of e-graphs practical in compilers. In this paper, we present Caviar, an e-graph-based TRS for proving expressions within compilers. The main advantage of Caviar is its speed. It can prove expressions much faster than base e-graph TRSs. It relies on three techniques: 1) a technique that stops e-graphs from growing when the goal is reached, called Iteration Level Check; 2) a mechanism that balances exploration and exploitation in the equality saturation algorithm, called Pulsing Caviar; 3) a technique to stop e-graph construction before reaching saturation when a non-provable pattern is detected, called Non-Provable Patterns Detection (NPPD). We evaluate caviar on Halide, an optimizing compiler that relies on a greedy-algorithm-based TRS to simplify and prove its expressions. The proposed techniques allow Caviar to accelerate e-graph expansion for the task of proving expressions. They also allow Caviar to prove expressions that Halide’s TRS cannot prove while being only 0.68x slower. Caviar is publicly available at: https://github.com/caviar-trs/caviar.","PeriodicalId":333281,"journal":{"name":"Proceedings of the 31st ACM SIGPLAN International Conference on Compiler Construction","volume":"71 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2021-11-23","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"3","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Proceedings of the 31st ACM SIGPLAN International Conference on Compiler Construction","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1145/3497776.3517781","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 3

Abstract

Term Rewriting Systems (TRSs) are used in compilers to simplify and prove expressions. State-of-the-art TRSs in compilers use a greedy algorithm that applies a set of rewriting rules in a predefined order (where some of the rules are not axiomatic). This leads to a loss of the ability to simplify certain expressions. E-graphs and equality saturation sidestep this issue by representing the different equivalent expressions in a compact manner from which the optimal expression can be extracted. While an e-graph-based TRS can be more powerful than a TRS that uses a greedy algorithm, it is slower because expressions may have a large or sometimes infinite number of equivalent expressions. Accelerating e-graph construction is crucial for making the use of e-graphs practical in compilers. In this paper, we present Caviar, an e-graph-based TRS for proving expressions within compilers. The main advantage of Caviar is its speed. It can prove expressions much faster than base e-graph TRSs. It relies on three techniques: 1) a technique that stops e-graphs from growing when the goal is reached, called Iteration Level Check; 2) a mechanism that balances exploration and exploitation in the equality saturation algorithm, called Pulsing Caviar; 3) a technique to stop e-graph construction before reaching saturation when a non-provable pattern is detected, called Non-Provable Patterns Detection (NPPD). We evaluate caviar on Halide, an optimizing compiler that relies on a greedy-algorithm-based TRS to simplify and prove its expressions. The proposed techniques allow Caviar to accelerate e-graph expansion for the task of proving expressions. They also allow Caviar to prove expressions that Halide’s TRS cannot prove while being only 0.68x slower. Caviar is publicly available at: https://github.com/caviar-trs/caviar.
鱼子酱:一个基于电子图的自动代码优化TRS
术语重写系统(TRSs)在编译器中用于简化和证明表达式。编译器中最先进的trs使用贪婪算法,该算法以预定义的顺序应用一组重写规则(其中一些规则不是公理)。这导致人们丧失了简化某些表达式的能力。e图和饱和等式避开了这个问题,它们以一种紧凑的方式表示不同的等价表达式,从中可以提取出最优表达式。虽然基于e-graph的TRS可能比使用贪婪算法的TRS更强大,但它速度较慢,因为表达式可能具有大量或有时无限数量的等效表达式。加快电子图的构建对于实现电子图在编译器中的实际应用至关重要。在本文中,我们提出了Caviar,一个基于电子图的TRS,用于证明编译器中的表达式。鱼子酱的主要优点是速度快。它可以比基本的电子图trs更快地证明表达式。它依赖于三种技术:1)当达到目标时阻止电子图增长的技术,称为迭代水平检查;2)均衡饱和算法中平衡探索和利用的机制,称为脉冲鱼子酱;3)当检测到不可证明的模式时,在达到饱和之前停止电子图构建的技术,称为不可证明模式检测(NPPD)。我们在Halide上评估鱼子酱,Halide是一个优化编译器,它依赖于基于贪婪算法的TRS来简化和证明其表达式。提出的技术允许鱼子酱加速电子图扩展的任务证明表达式。它们还允许鱼子酱证明Halide的TRS无法证明的表达式,而速度只慢0.68倍。鱼子酱可以在https://github.com/caviar-trs/caviar上公开购买。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 求助全文
来源期刊
自引率
0.00%
发文量
0
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
确定
请完成安全验证×
copy
已复制链接
快去分享给好友吧!
我知道了
右上角分享
点击右上角分享
0
联系我们:info@booksci.cn Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。 Copyright © 2023 布克学术 All rights reserved.
京ICP备2023020795号-1
ghs 京公网安备 11010802042870号
Book学术文献互助
Book学术文献互助群
群 号:604180095
Book学术官方微信