arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2305.11999cs.DCcs.AIcs.LGcs.PF
收藏

通过基于图和Transformer的方法指导OpenMP并行化

Advising OpenMP Parallelization via a Graph-Based Approach with Transformers

Ben-Gurion University of the Negev(内盖夫本-古里安大学);Israel Atomic Energy Commission(以色列原子能委员会);Intel Labs(英特尔实验室);Nuclear Research Center – Negev(内盖夫核研究中心);Technion – Israel Institute of Technology(以色列理工学院)

Tal Kadosh, Nadav Schneider, Niranjan Hasabnis, Timothy Mattson, Yuval Pinter, Gal Oren

AI总结:

提出OMPify方法,结合图表示与Transformer模型预测串行C/C++代码的OpenMP并行化指令,在F1分数和准确率上优于ChatGPT和PragFormer,基准测试准确率达90%。

摘要:

为了充分发挥多核架构的潜力,对共享内存并行化方案的需求始终存在。目前满足这一需求的最常见并行化API是OpenMP。然而,手动编写并行代码既复杂又耗费精力。因此,出现了许多确定性源到源(S2S)编译器,旨在自动化将串行代码转换为并行代码的过程。但最近的研究表明,这些编译器在许多场景下并不实用。在本研究中,我们结合AI和自然语言处理(NLP)领域的最新进展以及海量的开源代码,来解决自动并行化问题。具体而言,我们提出了一种名为OMPify的新方法,用于在给定串行版本代码的情况下,检测并预测并行代码中的OpenMP pragma和共享内存属性。OMPify基于Transformer模型,该模型利用了源代码的图表示,从而利用代码的固有结构。我们通过预测用C和C++语言编写的大型串行代码语料库(超过54,000个代码片段,Open-OMP-Plus)的并行化pragma和属性来评估我们的工具。结果表明,OMPify在F1分数和准确率方面优于现有的方法,包括通用且流行的ChatGPT以及针对性的PragFormer模型。具体而言,OMPify在常用的OpenMP基准测试(如NAS、SPEC和PolyBench)上达到了高达90%的准确率。此外,我们还进行了消融研究以评估不同模型组件的影响,并展示了从中得出的有趣见解。最后,我们还探索了使用数据增强和课程学习技术来提高模型鲁棒性和泛化能力的潜力。

英文摘要:

There is an ever-present need for shared memory parallelization schemes to exploit the full potential of multi-core architectures. The most common parallelization API addressing this need today is OpenMP. Nevertheless, writing parallel code manually is complex and effort-intensive. Thus, many deterministic source-to-source (S2S) compilers have emerged, intending to automate the process of translating serial to parallel code. However, recent studies have shown that these compilers are impractical in many scenarios. In this work, we combine the latest advancements in the field of AI and natural language processing (NLP) with the vast amount of open-source code to address the problem of automatic parallelization. Specifically, we propose a novel approach, called OMPify, to detect and predict the OpenMP pragmas and shared-memory attributes in parallel code, given its serial version. OMPify is based on a Transformer-based model that leverages a graph-based representation of source code that exploits the inherent structure of code. We evaluated our tool by predicting the parallelization pragmas and attributes of a large corpus of (over 54,000) snippets of serial code written in C and C++ languages (Open-OMP-Plus). Our results demonstrate that OMPify outperforms existing approaches, the general-purposed and popular ChatGPT and targeted PragFormer models, in terms of F1 score and accuracy. Specifically, OMPify achieves up to 90% accuracy on commonly-used OpenMP benchmark tests such as NAS, SPEC, and PolyBench. Additionally, we performed an ablation study to assess the impact of different model components and present interesting insights derived from the study. Lastly, we also explored the potential of using data augmentation and curriculum learning techniques to improve the model's robustness and generalization capabilities.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑