程序的行为嵌入:一种用于优化预测的准动态方法
Behavioral Embeddings of Programs: A Quasi-Dynamic Approach for Optimization Prediction
AI总结:
本文提出准动态程序表示框架,通过程序行为谱和PQ-BERT模型预测编译器优化,在最佳遍预测和-Oz收益预测任务上超越静态基线。
摘要:
学习程序的有效数值表示(即嵌入)是将机器学习应用于自动化并增强编译器优化的基本前提。然而,现有的主流范式面临两难困境。静态表示,源自源代码或中间表示(IR),高效且确定性,但难以深入洞察程序在复杂代码变换下的行为或演化。相反,动态表示依赖运行时剖析,能提供对性能瓶颈的深刻见解,但往往因过高的开销和固有的非确定性而难以用于大规模任务。本文通过提出一种新颖的准动态程序表示框架,超越了这一权衡。核心见解在于对程序的优化敏感性进行建模。我们引入了程序行为谱(Program Behavior Spectrum),这是一种通过用多样化的优化序列探测程序IR并量化其静态特征变化而生成的新表示。为了有效编码这种高维、连续的谱,我们开创了一种组合学习方法。采用乘积量化(Product Quantization)将连续的反应向量离散化为结构化的组合子词。随后,预训练一个多任务Transformer模型,称为PQ-BERT,以学习这些行为代码的深层上下文语法。在两个代表性的编译器优化任务——最佳遍预测(Best Pass Prediction)和-Oz收益预测(-Oz Benefit Prediction)——上的全面实验表明,我们的方法优于最先进的静态基线。我们的代码公开于 https://github.com/Panhaolin2001/PREP/。
英文摘要:
Learning effective numerical representations, or embeddings, of programs is a fundamental prerequisite for applying machine learning to automate and enhance compiler optimization. Prevailing paradigms, however, present a dilemma. Static representations, derived from source code or intermediate representation (IR), are efficient and deterministic but offer limited insight into how a program will behave or evolve under complex code transformations. Conversely, dynamic representations, which rely on runtime profiling, provide profound insights into performance bottlenecks but are often impractical for large-scale tasks due to prohibitive overhead and inherent non-determinism. This paper transcends this trade-off by proposing a novel quasi-dynamic framework for program representation. The core insight is to model a program's optimization sensitivity. We introduce the Program Behavior Spectrum, a new representation generated by probing a program's IR with a diverse set of optimization sequences and quantifying the resulting changes in its static features. To effectively encode this high-dimensional, continuous spectrum, we pioneer a compositional learning approach. Product Quantization is employed to discretize the continuous reaction vectors into structured, compositional sub-words. Subsequently, a multi-task Transformer model, termed PQ-BERT, is pre-trained to learn the deep contextual grammar of these behavioral codes. Comprehensive experiments on two representative compiler optimization tasks -- Best Pass Prediction and -Oz Benefit Prediction -- demonstrate that our method outperforms state-of-the-art static baselines. Our code is publicly available at https://github.com/Panhaolin2001/PREP/.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。