Skip to main content
QUICK REVIEW

[论文解读] Learning to Parallelize with OpenMP by Augmented Heterogeneous AST Representation

Le Chen, Quazi Ishtiaque Mahmud|arXiv (Cornell University)|May 9, 2023
Software Engineering Research被引用 5
一句话总结

该论文提出 Graph2Par,一种基于图的机器学习方法,利用异构增强抽象语法树(aug-AST)检测 C 代码中 OpenMP 的循环级并行性。通过采用新颖的代码表示方法和异构图神经网络(HGT),该方法在识别可并行化循环方面达到 85% 的准确率,优于基于标记的模型,并发现了 48 个传统静态分析工具遗漏的复杂或嵌套循环中的并行性机会。

ABSTRACT

Detecting parallelizable code regions is a challenging task, even for experienced developers. Numerous recent studies have explored the use of machine learning for code analysis and program synthesis, including parallelization, in light of the success of machine learning in natural language processing. However, applying machine learning techniques to parallelism detection presents several challenges, such as the lack of an adequate dataset for training, an effective code representation with rich information, and a suitable machine learning model to learn the latent features of code for diverse analyses. To address these challenges, we propose a novel graph-based learning approach called Graph2Par that utilizes a heterogeneous augmented abstract syntax tree (Augmented-AST) representation for code. The proposed approach primarily focused on loop-level parallelization with OpenMP. Moreover, we create an OMP\_Serial dataset with 18598 parallelizable and 13972 non-parallelizable loops to train the machine learning models. Our results show that our proposed approach achieves the accuracy of parallelizable code region detection with 85\% accuracy and outperforms the state-of-the-art token-based machine learning approach. These results indicate that our approach is competitive with state-of-the-art tools and capable of handling loops with complex structures that other tools may overlook.

研究动机与目标

  • 解决用于训练循环级并行性检测机器学习模型的高质量、标注数据集缺乏的问题。
  • 克服基于标记的代码表示方法忽略对并行性分析至关重要的结构依赖关系的局限性。
  • 开发更具表现力的代码表示方法,以捕捉循环的语法和结构特征,从而提升模型的泛化能力。
  • 设计一种机器学习流水线,能够检测复杂并行性模式,包括传统静态分析工具遗漏的模式。
  • 创建可复用的数据集和模型框架,以支持程序分析和自动并行化研究的广泛应用。

提出的方法

  • 从 GitHub、基准测试和合成生成代码中构建 OMP_Serial 数据集,包含 18,598 个可并行化循环和 13,972 个不可并行化循环。
  • 通过注释和空白字符移除等预处理步骤从 C 代码中提取循环,并根据是否存在 OpenMP 指令 pragma 对每个循环进行标注。
  • 将每个循环的 AST 转换为编码了节点类型、控制/数据依赖关系以及循环特定属性(如归约操作)的异构增强 AST(aug-AST)。
  • 将 aug-AST 表示为具有多种节点类型和边类型的异构图,以捕捉多样化的语义和结构关系。
  • 在 aug-AST 上训练异构图神经网络(HGT),以分类判断循环是否可并行化以及适用的 OpenMP pragma。
  • 利用 HGT 模型执行四项下游任务:并行性检测、pragma 推荐和依赖性分析,通过异构图结构中的消息传递机制实现。
Figure 1: Proposed methodology. Data collection and generation: our dataset contains data from GitHub crawling, benchmark collection, and synthetic data generation. Data pre-processing: we extracted loops from codes with pre-processing steps, e.g., removing comments and blank lines. We also label th
Figure 1: Proposed methodology. Data collection and generation: our dataset contains data from GitHub crawling, benchmark collection, and synthetic data generation. Data pre-processing: we extracted loops from codes with pre-processing steps, e.g., removing comments and blank lines. We also label th

实验结果

研究问题

  • RQ1与基于标记的模型相比,结合结构特征和文本特征的基于图的代码表示是否能提升循环级并行性检测的准确率?
  • RQ2异构增强 AST 在多大程度上能够捕捉复杂循环模式(如无循环依赖的嵌套循环和归约操作),而这些模式是传统工具所遗漏的?
  • RQ3所提出的基于 HGT 的模型在检测具有复杂控制或数据依赖关系的循环中的并行性机会方面效果如何?
  • RQ4OMP_Serial 数据集能否作为未来自动并行化工具和模型训练与评估的可靠基准?
  • RQ5生成 aug-AST 表示的实际开销如何?是否适用于真实世界的静态分析流水线?

主要发现

  • Graph2Par 模型在检测可并行化循环方面达到 85% 的准确率,优于最先进的基于标记的机器学习方法。
  • 该模型成功识别出 48 个传统工具(DiscoPoP、PLUTO 和 autoPar)遗漏的并行性机会。
  • aug-AST 表示使模型能够检测复杂情况下的并行性,包括无循环依赖的嵌套循环和具有归约操作的循环。
  • 该模型正确识别出:对单个索引(如 j)进行二维数组访问并执行归约操作的循环,即使在传统工具失败的情况下,也可安全并行化。
  • 生成 aug-AST 的开销极低,典型循环(平均 6.9 行)仅需数毫秒,适用于静态分析流程。
  • OMP_Serial 数据集为未来基于机器学习的自动并行化和代码分析研究提供了宝贵且大规模的基准。
Figure 2: Category-wise loops missed by renowned parallelization assistant tools. The results are generated using the OMP_Serial dataset introduced in section 4 .
Figure 2: Category-wise loops missed by renowned parallelization assistant tools. The results are generated using the OMP_Serial dataset introduced in section 4 .

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。