论文标题
来源匹配和重写
Source Matching and Rewriting
论文作者
论文摘要
典型的编译器流量依赖于翻译/优化步骤的单向序列,该步骤降低了程序抽象表示,因此很难在每个转换步骤中保留更高级别的程序信息。另一方面,现代ISA扩展和硬件加速器可以从编译器检测和提高程序成语以加速指令或优化库呼叫的能力中受益。尽管已经提出了基于多级IR(MLIR)的最新作品以筹集代码,但它们依靠专用语言,编译器重新编译或深入的方言知识。本文介绍了源匹配和重写(SMR),这是一种基于用户为基础的源代码的方法,用于MLIR成语匹配和重写,不需要编译器专家的干预。 SMR使用基于两阶段的自动机匹配算法,该算法灵感来自于树模式匹配的早期工作。首先,将成语控制依赖性图(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.