P4OMP:面向串行代码中 OpenMP 并行化的检索增强提示
P4OMP: Retrieval-Augmented Prompting for OpenMP Parallelism in Serial Code
AI总结:
P4OMP 是一个检索增强框架,通过结合大型语言模型和 OpenMP 教程知识,将串行 C/C++ 代码转换为 OpenMP 并行代码,无需微调即可实现 100% 编译成功率并显著提升代码可靠性。
摘要:
我们提出了 P4OMP,这是一个使用大型语言模型(LLM)将串行 C/C++ 代码转换为 OpenMP 标注并行代码的检索增强框架。据我们所知,这是首个应用基于检索的提示来实现 OpenMP pragma 正确性,且无需模型微调或编译器插桩的系统。P4OMP 利用检索增强生成(RAG)以及来自 OpenMP 教程的结构化指令知识,以提高提示驱动代码生成的可靠性。通过将生成过程基于检索到的上下文,与使用 GPT-3.5-Turbo 的基线提示相比,P4OMP 提高了语法正确性。我们在包含 108 个真实 C++ 程序的综合基准上评估 P4OMP 与无检索的 GPT-3.5-Turbo 基线,这些程序取自 Stack Overflow、PolyBench 和 NAS 基准套件。P4OMP 在所有可并行化案例上实现了 100% 的编译成功率,而基线在 108 个案例中有 20 个编译失败。由于 OpenMP 的根本限制,6 个依赖非随机访问迭代器或线程不安全结构的案例被排除。详细分析表明,P4OMP 如何持续避免作用域错误、语法误用和无效指令组合,这些错误通常会影响基线生成的代码。我们进一步展示了在 HPC 集群上的 7 个计算密集型基准中强大的运行时扩展性。P4OMP 提供了一个稳健、模块化的流程,显著提高了 LLM 生成的 OpenMP 代码的可靠性和适用性。
英文摘要:
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.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。