MLIR has become popular since it was open sourced in 2019. A sub-project of LLVM, the flexibility provided by MLIR to represent Intermediate Representations (IR) as dialects at different abstraction levels, to mix these, and to leverage transformations between dialects provides opportunities for automated program optimisation and parallelisation. In addition to general purpose compilers built upon MLIR, domain specific abstractions have also been developed. In this paper we explore complimenting the Flang MLIR general purpose compiler by combining with the domain specific Open Earth Compiler's MLIR stencil dialect. Developing transformations to discover and extracts stencils from Fortran, this specialisation delivers between a 2 and 10 times performance improvement for our benchmarks on a Cray supercomputer compared to using Flang alone. Furthermore, by leveraging existing MLIR transformations we develop an auto-parallelisation approach targeting multi-threaded and distributed memory parallelism, and optimised execution on GPUs, without any modifications to the serial Fortran source code.
翻译:自2019年开源以来,MLIR已广受欢迎。作为LLVM的子项目,MLIR通过在不同抽象层级以方言形式表示中间表示、混合使用这些表示并利用方言之间的变换,为自动程序优化与并行化提供了灵活性。除基于MLIR构建的通用编译器外,领域特定抽象也已得到发展。本文探索将Flang MLIR通用编译器与领域特定的Open Earth编译器MLIR模板方言相结合,通过开发从Fortran中发现并提取模板的变换方法,在Cray超级计算机上相比单独使用Flang为基准测试实现了2至10倍的性能提升。此外,通过利用现有MLIR变换,我们开发了一种自动并行化方法,无需修改串行Fortran源代码即可实现多线程与分布式内存并行性以及GPU优化执行。