arXiv:2409.14771cs.CL2024-09被引 15

用AI自动把C++代码转成OpenMP并行代码,效果比传统方法更好。

OMPar: Automatic Parallelization with AI-Driven Source-to-Source Compilation

  • 用大模型分析循环并行潜力,生成精准OpenMP指令
  • 在HeCBench和ParEval上准确率超传统工具,性能提升明显
  • 能处理不完整代码,还能持续学习新模式

手动并行化代码因现代软件系统复杂性和多核架构普及而面临巨大挑战。本文提出OMPar,一种基于AI的源到源编译工具,可自动为C/C++代码添加OpenMP pragma。OMPar通过两个核心组件实现:OMPify评估循环并行潜力,MonoCoder-OMP是新训练的微调模型,用于生成精确的OpenMP指令。评估遵循传统工具AutoPar和ICPC编译器的标准流程:(1)确保生成代码串行编译运行正确;(2)逐步增加线程数与物理核心数测试性能;(3)验证输出结果正确性。使用HeCBench和ParEval基准测试评估准确率与性能。实验表明,OMPar显著优于传统方法,在识别可并行循环和生成高效pragma方面表现更优。除准确率外,还具备处理部分或不完整代码库的能力,并能持续从新代码模式中学习,不断提升并行化能力。这些结果凸显大模型在自动化并行化中的潜力,推动更高效、可扩展的并行计算系统发展。

原文摘要 · Abstract (English)

Manual parallelization of code remains a significant challenge due to the complexities of modern software systems and the widespread adoption of multi-core architectures. This paper introduces OMPar, an AI-driven tool designed to automate the parallelization of C/C++ code using OpenMP pragmas. OMPar integrates Large Language Models (LLMs) through two key components: OMPify, which assesses loop parallelization potential, and MonoCoder-OMP, a new fine-tuned model which generates precise OpenMP pragmas. The evaluation of OMPar follows the same rigorous process applied to traditional tools like source-to-source AutoPar and ICPC compilers: (1) ensuring the generated code compiles and runs correctly in serial form, (2) assessing performance with the gradual addition of threads and corresponding physical cores, and (3) verifying and validating the correctness of the code's output. Benchmarks from HeCBench and ParEval are used to evaluate accuracy and performance. Experimental results demonstrate that OMPar significantly outperforms traditional methods, achieving higher accuracy in identifying parallelizable loops and generating efficient pragmas. Beyond accuracy, OMPar offers advantages such as the ability to work on partial or incomplete codebases and the capacity to continuously learn from new code patterns, enhancing its parallelization capabilities over time. These results underscore the potential of LLMs in revolutionizing automatic parallelization techniques, paving the way for more efficient and scalable parallel computing systems.

AI编译并行计算OpenMPLLM应用

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。