作者投稿和查稿 主编审稿 专家审稿 编委审稿 远程编辑

计算机工程 ›› 2026, Vol. 52 ›› Issue (8): 225-237. doi: 10.19678/j.issn.1000-3428.0070570

• 体系结构与先进计算 • 上一篇    下一篇

基于国产GPGPU非一致控制流的分支优化

吴艺鹏1, 霍志坤2,*(), 韩孟之2   

  1. 1. 郑州大学计算机与人工智能学院, 河南 郑州 450001
    2. 曙光信息产业(北京)有限公司, 北京 100193
  • 收稿日期:2024-11-01 修回日期:2025-02-28 出版日期:2026-08-15 发布日期:2025-04-09
  • 通讯作者: 霍志坤
  • 作者简介:

    吴艺鹏, 男, 硕士研究生, 主研方向为编译器优化

    霍志坤(通信作者), 高级工程师

    韩孟之, 高级工程师、博士

  • 基金资助:
    国家重点研发计划(2021YFB0300200)

Branch Optimization Based on Domestic GPGPU Non-Consistent Control Flow

WU Yipeng1, HUO Zhikun2,*(), HAN Mengzhi2   

  1. 1. School of Computer and Artificial Intelligence, Zhengzhou University, Zhengzhou 450001, Henan, China
    2. Dawning Information Industry (Beijing) Co., Ltd., Beijing 100193, China
  • Received:2024-11-01 Revised:2025-02-28 Online:2026-08-15 Published:2025-04-09
  • Contact: HUO Zhikun

摘要:

目前, 通用图形处理单元(GPGPU)因其强大的并行处理能力而被广泛应用于各种计算任务。然而, 采用单指令多线程(SIMT)并行执行模型的GPGPU在程序执行时, 核函数会产生非一致控制流行为, 从而引发线程束分化, 降低加速器的整体性能。针对核函数执行过程中因非一致控制流引起的性能下降问题, 提出一种特定场景下的分支编译优化方法——连续分支合并MergeCFG。在编译器中间代码优化阶段, 通过控制流分析识别出控制流图中含相同条件跳转的连续分支结构, 以确定潜在的优化机会。接着, 基于指令分析, 评估优化的可行性, 判断是否存在能够减少分支跳转的优化空间。最后, 运用基本块复制与合并技术, 对控制流结构进行优化, 以减少程序中的分支跳转操作, 从而简化控制流, 提高程序执行效率。在国产GPGPU上使用7个合适的基准测试套件验证所提方法的可行性。仿真实验结果表明, 该方法有效减少程序中的分支跳转操作, 优化后的测试用例在性能上获得了显著提升。所测用例的平均加速比提高了2%~12%, 个别测试用例的性能提升超过5倍。

关键词: 通用图形处理单元, 单指令多线程, 控制流, 线程束分化, 编译优化

Abstract:

General-Purpose Graphics Processing Units (GPGPUs) are widely utilized for various computational tasks owing to their robust parallel processing capabilities. However, GPGPUs employing the Single Instruction Multiple Threads (SIMT) execution model often encounter non-consistent control flows during kernel execution, leading to warp divergence and a subsequent decline in the overall accelerator performance. To address the performance degradation caused by non-consistent control flows in kernel execution, this study introduces MergeCFG, a branch compilation optimization technique tailored for specific scenarios. During the intermediate code optimization phase in the compiler, MergeCFG conducts a control flow analysis to identify consecutive branch structures in the control flow graph that share identical conditional branches, thereby identifying potential optimization opportunities. Subsequently, based on instruction analysis, it assesses the feasibility of optimization to determine whether opportunities for reducing branch operations exist. Finally, by employing basic block duplication and merging techniques, it optimizes the control flow structure to minimize branch operations, thereby simplifying the control flow and enhancing the program execution efficiency. Experiments are conducted using a domestic GPGPU system with seven suitable benchmark test suites to validate the feasibility of this method. The results demonstrate that this method effectively reduces branch operations within programs, leading to significant performance improvements in optimized test cases. The average speedup across the evaluated cases ranges from 2% to 12%, with certain test cases exhibiting performance enhancements exceeding fivefold.

Key words: General-Purpose Graphics Processing Unit (GPGPU), Single Instruction Multiple Threads (SIMT), control flow, warp divergence, compilation optimization