arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2202.04153cs.PL
收藏

源代码匹配和重写

Source Matching and Rewriting

Vinicius Couto, Luciano Zago, Hervé Yviquel, Guido Araújo

摘要:

典型的编译器流程依赖于单向的转换/优化步骤序列,这降低了程序抽象表示,使得难以在每个转换步骤中保留更高级别的程序信息。另一方面,现代ISA扩展和硬件加速器可以受益于编译器检测和提升程序习惯用法以加速指令或优化库调用的能力。虽然最近的工作基于多级IR(MLIR)已经提出了代码提升,他们依赖于专门的语言,编译器重新编译,或深入的方言知识。本文介绍了源代码匹配和重写(SMR),面向用户的源代码为基础的MLIR成语匹配和重写的方法,不需要编译器专家的干预。SMR使用基于自动机的两阶段DAG匹配算法,该算法受到树模式匹配的早期工作的启发。首先,将习惯用法控制依赖图(CDG)与程序的CDG进行匹配,以排除不具有与所需习惯用法相似的控制流结构的代码片段。第二,来自前一阶段的候选代码片段具有它们的数据相关图(DDG),并与习惯用法DDG进行匹配。实验结果表明,SMR可以有效地匹配来自Fortran(FIR)和C(CIL)程序的习惯用法,同时将它们提升为BLAS调用,以提高性能。

英文摘要:

A typical compiler flow relies on a uni-directional sequence of translation/optimization steps that lower the program abstract representation, making it hard to preserve higher-level program information across each transformation step. On the other hand, modern ISA extensions and hardware accelerators can benefit from the compiler's ability to detect and raise program idioms to acceleration instructions or optimized library calls. Although recent works based on Multi-Level IR (MLIR) have been proposed for code raising, they rely on specialized languages, compiler recompilation, or in-depth dialect knowledge. This paper presents Source Matching and Rewriting (SMR), a user-oriented source-code-based approach for MLIR idiom matching and rewriting that does not require a compiler expert's intervention. SMR uses a two-phase automaton-based DAG-matching algorithm inspired by early work on tree-pattern matching. First, the idiom Control-Dependency Graph (CDG) is matched against the program's CDG to rule out code fragments that do not have a control-flow structure similar to the desired idiom. Second, candidate code fragments from the previous phase have their Data-Dependency Graphs (DDGs) constructed and matched against the idiom DDG. Experimental results show that SMR can effectively match idioms from Fortran (FIR) and C (CIL) programs while raising them as BLAS calls to improve performance.

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

↑