[Paper Review] OMP2MPI: Automatic MPI code generation from OpenMP programs
OMP2MPI is a source-to-source compiler that automatically transforms OpenMP programs into MPI code, enabling execution on distributed-memory HPC clusters beyond the node level. It achieves this by converting OpenMP parallel loops into master/worker patterns with MPI communication, resulting in correct, scalable code that often outperforms both the original OpenMP and sequential versions on 64 cores with speedups exceeding 20×.
In this paper, we present OMP2MPI a tool that generates automatically MPI source code from OpenMP. With this transformation the original program can be adapted to be able to exploit a larger number of processors by surpassing the limits of the node level on large HPC clusters. The transformation can also be useful to adapt the source code to execute in distributed memory many-cores with message passing support. In addition, the resulting MPI code can be used as an starting point that still can be further optimized by software engineers. The transformation process is focused on detecting OpenMP parallel loops and distributing them in a master/worker pattern. A set of micro-benchmarks have been used to verify the correctness of the the transformation and to measure the resulting performance. Surprisingly not only the automatically generated code is correct by construction, but also it often performs faster even when executed with MPI.
Motivation & Objective
- To enable OpenMP programs to scale beyond single-node shared-memory systems by automatically generating portable MPI code.
- To provide a practical, correct-by-construction transformation from OpenMP to MPI for use in large HPC clusters and distributed-memory many-core systems.
- To offer a performance-competitive starting point for MPI optimization that retains readability and allows expert tuning.
- To overcome the limitations of software-distributed shared memory runtimes by exposing explicit MPI communication patterns.
Proposed method
- The tool uses the Mercurium compiler framework to parse C/C++ OpenMP source code and generate an abstract syntax tree (AST).
- It identifies OpenMP parallel loops and applies static analysis to detect shared, private, and reduction variables, including special handling for reduction clauses.
- The transformation maps each OpenMP parallel region into a master/worker pattern using MPI_Send and MPI_Recv for workload distribution and result collection.
- It supports both static and dynamic workload distribution strategies, with dynamic distribution used when load imbalance is detected.
- The tool handles data distribution by sending full arrays only when necessary—specifically, when the last slave performs a write operation.
- Finalization includes assigning non-parallelized code to the master and inserting MPI_Finalize to ensure proper cleanup.
Experimental results
Research questions
- RQ1Can a source-to-source compiler automatically and correctly transform OpenMP parallel loops into equivalent MPI code for distributed-memory execution?
- RQ2Does the automatically generated MPI code maintain or improve performance compared to the original OpenMP version on shared-memory systems?
- RQ3Can the generated MPI code scale effectively across large numbers of cores in a cluster environment?
- RQ4How does the performance of the generated code compare to both sequential and original OpenMP implementations on 64-core systems?
- RQ5To what extent can the generated code be further optimized by experts, given its readability and structure?
Key findings
- The OMP2MPI tool successfully transforms OpenMP programs into correct, executable MPI code that is portable across distributed-memory systems, including large HPC clusters and experimental many-core platforms.
- The generated MPI code achieves better scalability than the original OpenMP version, with speedups exceeding 20× on 64 cores compared to the sequential baseline.
- On average, the generated MPI code outperforms the original OpenMP version, demonstrating that MPI can be more efficient than OpenMP even on shared-memory systems in some cases.
- The transformation is correct by construction, with no semantic loss, and supports key OpenMP constructs such as reduction clauses with proper initialization and accumulation.
- The tool supports both static and dynamic workload distribution, with dynamic distribution improving load balancing in irregular or imbalanced computations.
- The resulting code is readable and suitable for further manual optimization, making it a viable starting point for performance tuning.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.