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

计算机工程

• •    

DEPTUNER:基于浮点运算带权依赖图的混合精度优化方法

  • 发布日期:2026-11-18

DEPTUNER: A Mixed-Precision Optimization Method Based on a Weighted Dependency Graph of Floating-Point Operations

  • Published:2026-11-18

摘要: 浮点计算广泛应用于科学计算领域,为保证计算结果的准确性,研究人员通常在程序中统一采用高精度浮点类型,但这种做法往往带来较高的计算与存储开销。混合精度技术通过降低部分变量的精度以提升程序性能,其中动态混合精度方法优势显著。然而,现有方法普遍未考虑精度转换开销对性能的影响,导致优化效果受限、调优效率较低。为此,本文提出一种基于浮点运算带权依赖图引导的自动混合精度调优工具DEPTUNER,包括依赖图构建与搜索两个模块。依赖图构建模块基于Clang LibTooling解析程序抽象语法树,提取函数信息与变量间的关联关系,并借助gcov采集各语句的实际执行次数,量化精度转换相关语句的执行频次以评估转换开销;将具备单、双精度实现的库函数统一抽象为变量,构建以变量为节点、浮点运算关联为边、语句累计执行频次为边权重的带权依赖图。搜索模块基于贪心搜索算法设计:以带权度最大的节点为起点,每步从与已选变量集合相连的节点中选择边权重最大的邻居纳入低精度配置,并测试配置的运行时间与误差以更新最优配置;误差超出用户设定阈值时触发回溯机制,直接恢复为历史最优配置,避免逐节点恢复的额外开销,提升调优效率。本文选取15个基准测试程序,在误差阈值为10-4、10-6和10-8的条件下开展实验。结果表明,依赖图能近似表征不同配置下精度转换指令数目的相对大小与变化趋势,回溯机制可进一步提升carbonGas、piqpr、fft等用例的配置性能;DEPTUNER为80%的测试程序找到了有效配置,分别比HIFPTUNER、ADAPT和CHEF-FP高26.7%、66.7%和53.4%;平均性能提升分别高11.15%、21.32%和13.46%,最高可达53.01%;工具整体运行时间较HIFPTUNER减少64.6%。DEPTUNER能在误差可控的前提下,为更多程序找到质量更优、搜索效率更高的混合精度配置,为浮点程序的自动混合精度调优提供了一种兼顾功能性与效率的新思路。

Abstract: Floating-point computation is widely used in scientific computing. To ensure accurate results, researchers usually adopt high-precision floating-point types throughout a program, which often incurs high computation and storage overhead. Mixed-precision techniques improve program performance by lowering the precision of some variables, and dynamic mixed-precision methods show notable advantages. However, existing methods generally ignore the performance impact of precision-conversion overhead, which limits the optimization achieved and lowers tuning efficiency. This paper proposes DEPTUNER, an automatic mixed-precision tuning tool guided by a weighted dependency graph of floating-point operations, consisting of a dependency graph construction module and a search module. The construction module parses the abstract syntax tree with Clang LibTooling to extract function information and relations among variables, and uses gcov to collect the actual execution count of each statement, quantifying the execution frequency of conversion-related statements to estimate conversion overhead. Library functions with both single- and double-precision implementations are abstracted as variables. The resulting weighted graph takes variables as nodes, floating-point operation relations as edges, and accumulated statement execution counts as edge weights, and ignores assignment order to reduce model complexity. The search module uses a greedy algorithm: starting from the node with the largest weighted degree, it repeatedly adds to the low-precision configuration the neighbor with the largest edge weight among nodes connected to the selected variables, and tests each configuration's runtime and error to update the best one. When the error exceeds the user-specified threshold, a backtracking mechanism restores the historical best configuration directly, avoiding the extra cost of node-by-node recovery and improving tuning efficiency. Experiments are conducted on 15 benchmark programs under error thresholds of 10-4, 10-6 and 10-8. The graph approximately reflects the relative magnitude and trend of the number of precision-conversion instructions across configurations, and the backtracking mechanism further improves the performance of configurations for programs such as carbonGas, piqpr and fft. DEPTUNER finds valid configurations for 80% of the programs, which is 26.7%, 66.7% and 53.4% higher than HIFPTUNER, ADAPT and CHEF-FP, respectively. Its average performance improvement exceeds theirs by 11.15%, 21.32% and 13.46%, with a maximum of 53.01%, and its overall running time is 64.6% shorter than that of HIFPTUNER. DEPTUNER can find higher-quality and more efficiently searched mixed-precision configurations for more programs under controlled output error, offering a new approach to automatic mixed-precision tuning of floating-point programs that balances functionality and efficiency.