arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2603.30040cs.SEcs.AI
收藏

基于Transformer的源代码表示的并行化循环自动识别

Automatic Identification of Parallelizable Loops Using Transformer-Based Source Code Representations

Graduate Program in Applied Informatics (PPGIA), Federal Rural University of Pernambuco (UFRPE)(伯南布哥联邦农村大学应用信息学研究生项目);Undergraduate Program in Analysis and Systems Development (TADS), Federal Institute of Pernambuco (IFPE)(伯南布哥联邦学院分析与系统开发本科项目)

Izavan dos S. Correia, Henrique C. T. Santos, Tiago A. E. Ferreira

AI总结:

本文提出基于Transformer的源代码表示方法,用于识别可并行执行的循环。通过DistilBERT处理源代码序列,捕捉上下文语法和语义模式,实验表明在平衡数据集上具有高准确率和低误报率。

摘要:

自动并行化在软件工程中仍是一个具有挑战性的问题,特别是在识别可以在现代多核架构上安全并行执行的代码区域时。传统静态分析技术,如依赖分析和多面体模型,往往难以处理不规则或动态结构的代码。在本工作中,我们提出了一种基于Transformer的方法,用于分类源代码的并行化潜力,重点在于区分独立(可并行执行)的循环与未定义的循环。我们采用DistilBERT处理源代码序列,使用子词分词,使模型能够捕捉上下文语法和语义模式,而无需手工特征。该方法在结合合成生成的循环和人工注释的现实代码的平衡数据集上进行评估,使用10折交叉验证和多种性能指标。结果表明,方法在准确率方面表现一致,平均准确率超过99%,且误报率低,证明了其鲁棒性和可靠性。与先前基于标记的方法相比,所提出的方法简化了预处理,同时提高了泛化能力和保持计算效率。这些发现突显了轻量级Transformer模型在实际中识别循环级别的并行化机会的潜力。

英文摘要:

Automatic parallelization remains a challenging problem in software engineering, particularly in identifying code regions where loops can be safely executed in parallel on modern multi-core architectures. Traditional static analysis techniques, such as dependence analysis and polyhedral models, often struggle with irregular or dynamically structured code. In this work, we propose a Transformer-based approach to classify the parallelization potential of source code, focusing on distinguishing independent (parallelizable) loops from undefined ones. We adopt DistilBERT to process source code sequences using subword tokenization, enabling the model to capture contextual syntactic and semantic patterns without handcrafted features. The approach is evaluated on a balanced dataset combining synthetically generated loops and manually annotated real-world code, using 10-fold cross-validation and multiple performance metrics. Results show consistently high performance, with mean accuracy above 99\% and low false positive rates, demonstrating robustness and reliability. Compared to prior token-based methods, the proposed approach simplifies preprocessing while improving generalization and maintaining computational efficiency. These findings highlight the potential of lightweight Transformer models for practical identification of parallelization opportunities at the loop level.

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

↑