一句话:提出 Pitchfork:以可移植定点中间表示 FPIR 配合项重写系统自动识别并生成 DSP 专用定点指令,最高获得 2.44 倍加速。
现代向量处理器为定点数字信号处理提供了大量专用指令,涵盖多种舍入、饱和与类型转换模式,且往往是多个原语操作的融合。这使程序员难以用类 C 的可移植代码精确对应某条指令,编译器也难以自动识别这些惯用法。本文提出 Pitchfork:定义可移植的定点中间表示 FPIR 来刻画定点代码中的常见惯用法;借助由人工编写与自动合成并经验证的规则所组成的项重写系统,将整数运算自动提升为 FPIR,再通过一组目标相关的项重写系统下降到具体定点指令。在 Halide 的多个基准上,与基于 LLVM 的标准编译流程相比,可移植定点信号处理代码的运行时间几何平均加速分别为 x86+AVX2 上 1.31 倍、ARM Neon 上 1.82 倍、Hexagon HVX 上 2.44 倍,同时编译时间持平或更优。
Modern vector processors support a wide variety of instructions for fixed-point digital signal processing. These instructions support a proliferation of rounding, saturating, and type conversion modes, and are often fused combinations of more primitive operations. While these are common idioms in fixed-point signal processing, it is difficult to use these operations in portable code. It is challenging for programmers to write down portable integer arithmetic in a C-like language that corresponds exactly to one of these instructions, and even more challenging for compilers to recognize when these instructions can be used. Our system, Pitchfork, defines a portable fixed-point intermediate representation, FPIR, that captures common idioms in fixed-point code. FPIR can be used directly by programmers experienced with fixed-point, or Pitchfork can automatically lift from integer operations into FPIR using a term-rewriting system (TRS) composed of verified manual and automatically-synthesized rules. Pitchfork then lowers from FPIR into target-specific fixed-point instructions using a set of target-specific TRSs. We show that this approach improves runtime performance of portably-written fixed-point signal processing code in Halide, across a range of benchmarks, by geomean 1.31x on x86 with AVX2, 1.82x on ARM Neon, and 2.44x on Hexagon HVX compared to a standard LLVM-based compiler flow, while maintaining or improving existing compile times.
@inproceedings{paperbot10113,
title = {Fast Instruction Selection for Fast Digital Signal Processing},
author = {Alexander J Root and Maaz Bin Safeer Ahmad and Dillon Sharlet and Andrew Adams and Shoaib Kamil and Jonathan Ragan-Kelley},
booktitle = {ASPLOS},
year = {2023},
doi = {10.1145/3623278.3624768}
}