P4OMP: Retrieval-Augmented Prompting for OpenMP Parallelism in Serial Code
On the map: Retrieval-augmented generation → RAG for code
Abstract (arXiv)
We present P4OMP, a retrieval-augmented framework for transforming serial C/C++ code into OpenMP-annotated parallel code using large language models (LLMs). To our knowledge, this is the first system to apply retrieval-based prompting for OpenMP pragma correctness without model fine-tuning or compiler instrumentation. P4OMP leverages Retrieval-Augmented Generation (RAG) with structured instructional knowledge from OpenMP tutorials to improve the reliability of prompt-driven code generation. By grounding generation in the retrieved context, P4OMP improves syntactic correctness compared to baseline prompting with GPT-3.5-Turbo. We evaluate P4OMP against a baseline, GPT-3.5-Turbo without retrieval, on a comprehensive benchmark of 108 real-world C++ programs drawn from Stack Overflow, PolyBench, and NAS benchmark suites. P4OMP achieves 100% compilation success on all parallelizable cases, while the baseline fails to compile in 20 out of 108 cases. Six cases that rely on non-random-access iterators or thread-unsafe constructs are excluded due to fundamental OpenMP limitations. A detailed analysis demonstrates how P4OMP consistently avoids scoping errors, syntactic misuse, and invalid directive combinations that commonly affect baseline-generated code. We further demonstrate strong runtime scaling across seven compute-intensive benchmarks on an HPC cluster. P4OMP offers a robust, modular pipeline that significantly improves the reliability and applicability of LLM-generated OpenMP code.
Key facts. Cited by 1 paper in the map (data through 14 Oct 2026). Placed in RAG for code, one of 15 directions in Retrieval-augmented generation. Builds on 9 of its 20 references that are in the map. First posted on arXiv 28 Jun 2025.
Builds on
9 of 20 references.
References · 9
- 2025KernelBench: Can LLMs Write Efficient GPU Kernels?cited by 225
- 2023CoTran: An LLM-based Code Translator using Reinforcement Learning with Feedback from Compiler and Symbolic Executioncited by 22
- 2024OMPGPT: A Generative Pre-trained Transformer Model for OpenMPcited by 16
- 2023Advising OpenMP Parallelization via a Graph-Based Approach with Transformerscited by 10
- 2024LLM-Aided Compilation for Tensor Acceleratorscited by 8
- 2025UnitCoder: Scalable Iterative Code Synthesis with Unit Test Guidancecited by 7
- 2024OMPar: Automatic Parallelization with AI-Driven Source-to-Source Compilationcited by 5
- 2025Oracular Programming: A Modular Foundation for Building LLM-Enabled Softwarecited by 2
- 2024Developing an Interactive OpenMP Programming Book with Large Language Modelscited by 1
Built on by
Citing papers per year: 2026: 1.
1 paper.
- 2026Exploring the Role of LLMs in HPC Programming: A Surveycited by 1
- 2026Exploring the Role of LLMs in HPC Programming: A Survey24 May 2026
Similar, not cited
Close in wording, no citation either way
- 2024Symbolic Prompt Program Search: A Structure-Aware Approach to Efficient Compile-Time Prompt Optimization
- 2025LOOPRAG: Enhancing Loop Transformation Optimization with Retrieval-Augmented Large Language Models
- 2026ParBench: A Benchmark for Reliable Evaluation of LLM Parallel Code Translation
- 2025SpareCodeSearch: Searching for Code Context When You Have No Spare GPU
- 2024OpenCodeInterpreter: Integrating Code Generation with Execution and Refinement
- 2026LLM4C2Rust: Large Language Models for Automated Memory-Safe Code Transpilation ↗
- 2024Prompt-based Code Completion via Multi-Retrieval Augmented Generation
- 2023LLM4VV: Developing LLM-Driven Testsuite for Compiler Validation