arXiv:2610.03571cs.PLOct 2026

Manuscript Offprint

arXiv:2610.03571

OpenMP Meta-Lowering: A Declarative Approach to Performance Portable Parallel Code Generation

Luca Parigi, Giuseppe Tagliavini

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

The increasing diversity of parallel hardware challenges existing compilation flows. While OpenMP provides a portable abstraction for shared-memory parallelism, existing compilers tightly couple the frontend semantics with fixed lowering strategies. This design limits performance portability across different runtimes and architectures. In this paper, we present a modular approach to parallel code generation based on the Multi-Level Intermediate Representation (MLIR) framework. Our approach combines an OpenMP frontend with a domain-specific language (DSL) that specifies how OpenMP constructs are lowered for a target. We call this approach OpenMP meta-lowering, treating lowering as a programmable component rather than compiler-specific logic. This design provides explicit control over code outlining, data sharing, and runtime interfacing across diverse targets. We evaluate our approach on PolyBench/C-OMP across general-purpose and embedded multicore targets. Our results show that the proposed method matches the performance of state-of-the-art compiler toolchains with negligible code-size overhead (< 0.7%). Preserving OpenMP constructs until late lowering stages enables both general-purpose and OpenMP-specific MLIR optimizations. By decoupling lowering from compiler internals, our approach expresses the same OpenMP subset in 5,182 lines of code, ~32% fewer than the corresponding lowering code in Clang and ~76% fewer than in GCC, while supporting the pmsis runtime costs only a few specification lines, enabling rapid support for new runtimes without modifying the compiler.

CCS Concepts: • Software and its engineering → Compilers; Parallel programming languages; Runtime environments.

Keywords: Parallel Programming, OpenMP, MLIR, Performance Portability, Domain-Specific Languages, Runtime Systems

1 Introduction

The increasing heterogeneity of modern computing platforms, ranging from general-purpose CPUs to embedded

Giuseppe Tagliavini

University of Bologna

Bologna, BO, Italy

giuseppe.tagliavini@unibo.it

systems, has made performance portability a key requirement, as maintaining separate implementations for each target architecture significantly increases development time and cost [6]. This challenge is particularly critical in parallel computing systems, where differences in execution models, memory hierarchies, and synchronization mechanisms complicate the development of software that enforces portability without sacrificing efficiency [7].

To address this complexity, high-level parallel programming models have been introduced to allow developers to express parallelism independently of the underlying hardware. Open Multi-Processing (OpenMP) has emerged as one of the most widely used models for shared-memory parallel platforms [5, 27]. It provides a directive-based abstraction that enables developers to express parallelism and data-sharing semantics through source-code annotations. By abstracting low-level aspects of parallel execution, such as thread creation, synchronization, and workload distribution, OpenMP allows developers to write portable parallel code through a set of compiler directives and runtime services. This approach has been demonstrated to be effective across various domains, including high-performance computing [13], desktop applications, and embedded systems [32].

The portability of OpenMP is mainly limited to the source code level. The translation of OpenMP constructs into executable code relies on compiler-specific strategies that are closely tied to a particular runtime implementation. Modern toolchains, such as LLVM and GCC, convert OpenMP directives into calls to their respective runtime libraries (e.g., libomp for LLVM and libgomp for GCC). Consequently, assumptions about runtime interfaces and low-level execution semantics are embedded directly into the compiler infrastructure, limiting portability across alternative runtimes and execution environments. This tight coupling is evident even for simple constructs. For instance, consider a #pragma omp parallel for loop: depending on the target runtime, the compiler must generate different sequences of runtime calls, such as __kmpc_fork_call and __kmpc_for_static_init for libomp [23], or GOMP_parallel followed by explicit loop-boundary computations for libgomp [12], respectively. While these implementations achieve the same high-level semantics, their interfaces and calling conventions differ significantly. In current implementations, the compiler integrates runtime-specific logic directly into the lowering pipeline,

CGO 2027, Salt Lake City, UT, USA

  1. ACM ISBN 978-X-XXXX-XXXX-X/XX/XX

https://doi.org/XXXXXXX.XXXXXXX

Luca Parigi and Giuseppe Tagliavini

making it difficult and error-prone to retarget to new run-times.

This approach becomes particularly challenging when targeting embedded and ultra-low-power architectures. While general-purpose platforms rely on mature runtimes, embedded systems often require specialized runtime implementations that sacrifice generality for efficiency [3, 32, 35]. Supporting these environments typically requires re-implementing significant parts of the lowering pipeline to align with the target application binary interface (ABI) and execution model. Consequently, expanding OpenMP support to new architectures or runtimes demands considerable engineering effort and restricts the ability to experiment with different execution strategies [1].

To address the aforementioned limitations, this paper presents a modular approach to OpenMP lowering across multiple targets. The proposed methodology introduces a meta-layer on top of the Multi-Level Intermediate Representation (MLIR) [14, 15], a compiler infrastructure that enables flexible program representations at different levels of abstraction. However, despite this flexibility, the current approach to lowering OpenMP constructs within the MLIR infrastructure remains tightly coupled to specific runtime implementations. The key insight of this work is that the lowering process should not be hardwired into the compiler, but instead expressed as a declarative mapping between high-level parallel semantics and runtime interfaces. We reformulate the lowering process as a programmable component by introducing a domain-specific language (DSL) that describes lowering rules for diverse runtime implementations as an external specification, decoupling parallel semantics from runtime-specific details. Unlike previous MLIR-based approaches, which rely on fixed lowering pipelines [24] or imperative transformations implemented through compiler passes and pattern rewrites [19, 20], our methodology treats lowering as a declarative, runtime-parametric abstraction. To the best of our knowledge, this is the first approach to make OpenMP lowering explicitly programmable and runtime-agnostic within a production compiler infrastructure. Our implementation is available as open-source software 1^{1}, with an archived snapshot 2^{2}.

Our approach replaces the traditional monolithic lowering pipeline with a three-phase process: annotating the Intermediate Representation (IR), outlining functional contexts, and applying the lowering plan. The lowering process is driven by the meta-level specification expressed through DSL rules, enabling each phase to be customized for different runtime targets. This design fully decouples OpenMP semantics from any particular runtime implementation, allowing the same high-level representation to be lowered to multiple backends without embedding runtime-specific logic into the compiler infrastructure.

To summarize, this paper presents the following contributions:

  • A meta-lowering methodology that expresses the OpenMP lowering by means of a DSL specification, interpreted by the compiler infrastructure in a runtime-agnostic and extensible manner.

  • A modular three-phase MLIR lowering pipeline that instantiates the runtime-specific behavior based on the rules provided by the DSL specification.

• An end-to-end integration of the DSL and MLIR pipeline into a Clang/CIR-based compiler flow, enabling the combination with additional MLIR transformations from very early compilation stages.

• An evaluation on the PolyBench/C-OMP benchmark suite, across general-purpose and embedded targets, showing that our approach matches the performance of state-of-the-art compiler toolchains while incurring negligible code size overhead. Additionally, the evaluation considers the effects of illustrative general-purpose and OpenMP-specific optimizations.

We demonstrate the flexibility of our approach by targeting heterogeneous execution environments, including general-purpose runtimes (libomp, libgomp) and a lightweight embedded runtime for the Parallel Ultra-Low Power (PULP) multicore platform [4]. Across the evaluated benchmarks, our approach matches the performance of state-of-the-art compiler toolchains while introducing negligible code size overhead (below 0.7%). This decoupling reduces engineering complexity: the whole lowering pipeline takes 5,040 lines of code, ~32% less than the corresponding lowering code in Clang and ~76% less than in GCC for the same OpenMP subset, and adding support for a new runtime costs a few lines in the specification.

References (10)