MLIR is an emerging compiler infrastructure for modern hardware, but existing programs cannot take advantage of MLIR's high-performance compilation if they are described in lower-level general purpose languages. Consequently, to avoid programs needing to be rewritten manually, this has led to efforts to automatically raise lower-level to higher-level dialects in MLIR. However, current methods rely on manually-defined raising rules, which limit their applicability and make them challenging to maintain as MLIR dialects evolve. We present mlirSynth -- a novel approach which translates programs from lower-level MLIR dialects to high-level ones without manually defined rules. Instead, it uses available dialect definitions to construct a program space and searches it effectively using type constraints and equivalences. We demonstrate its effectiveness \revi{by raising C programs} to two distinct high-level MLIR dialects, which enables us to use existing high-level dialect specific compilation flows. On Polybench, we show a greater coverage than previous approaches, resulting in geomean speedups of 2.5x (Intel) and 3.4x (AMD) over state-of-the-art compilation flows for the C programming language. mlirSynth also enables retargetability to domain-specific accelerators, resulting in a geomean speedup of 21.6x on a TPU.
翻译:MLIR是一种针对现代硬件的新兴编译器基础设施,但若程序以底层通用语言描述,则无法利用MLIR的高性能编译优势。因此,为避免程序需要手动重写,学界已开展相关研究,旨在自动将MLIR中的底层方言提升为高层方言。然而,当前方法依赖手动定义的提升规则,这不仅限制了其适用范围,且随着MLIR方言的演进,维护这些规则变得困难。我们提出mlirSynth——一种无需手动定义规则即可将程序从底层MLIR方言转换为高层方言的新方法。该方法利用现有方言定义构建程序空间,并通过类型约束与等价性实现高效搜索。我们通过将C程序提升至两种不同的高层MLIR方言验证其有效性,从而得以利用现有高层方言专用编译流程。在Polybench基准测试上,我们展示了超越先前方法的覆盖率,相对于C语言最先进的编译流程,在Intel和AMD平台上分别实现了2.5倍和3.4倍的几何平均加速。mlirSynth还可重定向至领域专用加速器,在TPU上实现了21.6倍的几何平均加速。