Cost models predict the cost of executing given assembly code basic blocks on a specific microarchitecture. Recently, neural cost models have been shown to be fairly accurate and easy to construct. They can replace heavily engineered analytical cost models used in mainstream compiler workflows. However, their black-box nature discourages their adoption. In this work, we develop the first framework, COMET, for generating faithful, generalizable, and intuitive explanations for neural cost models. We generate and compare COMET's explanations for the popular neural cost model, Ithemal against those for an accurate CPU simulation-based cost model, uiCA. Our empirical findings show an inverse correlation between the prediction errors of Ithemal and uiCA and the granularity of basic block features in COMET's explanations for them, thus indicating potential reasons for the higher error of Ithemal with respect to uiCA.
翻译:代价模型用于预测给定汇编代码基本块在特定微架构上的执行代价。近年来,神经代价模型被证明具有相当高的准确性且易于构建,能够替代主流编译器流程中大量工程化的分析型代价模型。然而,其黑箱特性阻碍了实际应用推广。本研究首次提出COMET框架,旨在为神经代价模型生成忠实、可泛化且直观的解释。我们基于准确CPU模拟代价模型uiCA,对流行神经代价模型Ithemal生成并比较COMET解释。实验发现,Ithemal与uiCA的预测误差与COMET解释中基本块特征的粒度呈负相关,这揭示了Ithemal相对于uiCA具有更高误差的潜在原因。