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

📄 arXiv: 2409.14771v1 📥 PDF

作者: Tal Kadosh, Niranjan Hasabnis, Prema Soundararajan, Vy A. Vo, Mihai Capota, Nesreen Ahmed, Yuval Pinter, Gal Oren

分类: cs.CL

发布日期: 2024-09-23


💡 一句话要点

OMPar:利用AI驱动的源到源编译实现自动并行化

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 自动并行化 OpenMP 大型语言模型 代码生成 源到源编译

📋 核心要点

  1. 手动并行化代码面临软件系统复杂性和多核架构普及的挑战,需要更有效的自动化工具。
  2. OMPar利用大型语言模型,通过评估循环并行潜力和生成精确OpenMP pragmas实现自动并行化。
  3. 实验表明,OMPar在准确性和性能上优于传统方法,并具备处理不完整代码和持续学习的能力。

📝 摘要(中文)

本文介绍了一种名为OMPar的AI驱动工具,旨在利用OpenMP pragmas自动并行化C/C++代码。OMPar集成了大型语言模型(LLMs),通过两个关键组件实现:OMPify评估循环并行化的潜力,以及MonoCoder-OMP,这是一个新的微调模型,用于生成精确的OpenMP pragmas。OMPar的评估遵循与传统工具(如源到源AutoPar和ICPC编译器)相同的严格流程:(1) 确保生成的代码能够编译并在串行形式下正确运行,(2) 评估随着线程和相应物理核心的逐步增加的性能,以及(3) 验证和确认代码输出的正确性。使用来自HeCBench和ParEval的基准来评估准确性和性能。实验结果表明,OMPar显著优于传统方法,在识别可并行化循环和生成高效pragmas方面实现了更高的准确性。除了准确性之外,OMPar还具有能够在部分或不完整的代码库上工作以及能够不断从新的代码模式中学习的优势,从而随着时间的推移增强其并行化能力。这些结果强调了LLM在彻底改变自动并行化技术方面的潜力,为更高效和可扩展的并行计算系统铺平了道路。

🔬 方法详解

问题定义:论文旨在解决C/C++代码手动并行化效率低下的问题。现有方法,如传统的编译器和自动并行化工具,在识别可并行化的循环和生成高效的OpenMP pragmas方面存在局限性,难以适应复杂代码库,且缺乏持续学习能力。

核心思路:论文的核心思路是利用大型语言模型(LLMs)的强大代码理解和生成能力,自动化OpenMP pragmas的生成过程。通过训练LLM,使其能够准确识别代码中的并行化机会,并生成优化的OpenMP指令,从而提高并行化效率。

技术框架:OMPar包含两个主要组件:OMPify和MonoCoder-OMP。OMPify负责评估循环的并行化潜力,判断循环是否适合并行化。MonoCoder-OMP是一个经过微调的LLM,专门用于生成OpenMP pragmas。整个流程包括:输入C/C++代码,OMPify评估循环并行潜力,MonoCoder-OMP生成OpenMP pragmas,最后生成并行化的代码。

关键创新:关键创新在于将大型语言模型应用于自动并行化领域,利用LLM的代码理解和生成能力,显著提高了并行化效率和准确性。与传统方法相比,OMPar能够处理更复杂的代码库,并具备持续学习能力,能够不断优化并行化策略。

关键设计:MonoCoder-OMP模型的微调是关键设计之一。论文可能采用了特定的数据集和训练策略,以提高模型生成OpenMP pragmas的准确性和效率。具体参数设置、损失函数和网络结构等细节可能在论文中有更详细的描述(未知)。

🖼️ 关键图片

fig_0

📊 实验亮点

OMPar在HeCBench和ParEval基准测试中表现出色,显著优于传统的自动并行化工具。实验结果表明,OMPar在识别可并行化循环和生成高效OpenMP pragmas方面具有更高的准确性。具体的性能提升数据(例如加速比、并行效率等)需要在论文中查找(未知),但总体而言,OMPar展示了LLM在自动并行化领域的巨大潜力。

🎯 应用场景

OMPar的应用场景广泛,包括高性能计算、科学计算、嵌入式系统等领域。它可以帮助开发者更轻松地将现有C/C++代码并行化,充分利用多核处理器的性能,提高应用程序的运行效率。此外,OMPar还可以应用于代码优化和重构,帮助开发者发现潜在的并行化机会,并自动生成并行化代码,从而降低开发成本,加速软件开发周期。

📄 摘要(原文)

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.