摘要
混合精度是计算机中的一种数值计算技术,通过将计算中的部分数据类型从高精度转换成低精度来提高计算效率。矩阵乘法在计算机科学和数学中有着重要而广泛的应用,在矩阵乘法中使用混合精度技术来加速计算过程是一项很有挑战性的工作。现有的混合精度优化存在一些问题,例如存储开销大,必须在特定的硬件单元上实现,限制了模型或算法的部署选项并降低了其可移植性。针对上述问题,提出并实现了基于多面体模型的混合精度代码自动生成工具AGMMMPC。通过将低精度乘高精度加基础混合精度矩阵乘代码生成功能添加到“源-源”的PPCG编译器中,并使用精度调优算法(Precision Tuning,PT)找到基础混合精度计算中的高频误差点,将这些点用高精度计算,其余点用基础混合精度计算,有效减小基础混合精度计算中的误差,首次实现了源到源的面向矩阵乘计算的混合精度代码自动生成。实验表明,以高精度计算为基准,AGMMMPC生成的高级混合精度代码在X86平台上的最大加速比为1.39,几何平均加速比为1.14。
Mixed precision is a numerical computation technique in computers that improves the efficiency of computation by converting some of the data types in the computation from high precision to low precision.Matrix multiplication has an important and wide application in computer science and mathematics,using mixed precision techniques in matrix multiplication to speed up the computational process is a challenging task.Existing mixed-precision optimisation suffers from several problems,such as high storage overhead,having to be implemented on specific hardware units,limiting the deployment options of models or algorithms and reducing their portability.In the face of the above problems,this paper proposes and implements an automatic mixed-precision code generation tool based on polyhedral models AGMMMPC.By adding the low-precision-by-high-precision-plus-basic-mixed-precision matrix multiplication code generation functionality to the source-source PPCG compiler,and using the precision tuning(PT)algorithm to find high-frequency errors in the basic mixed-precision computation.These points are processed by high precision calculation method,while the rest are processed by the basic mixed precision calculation method,which effectively reduces the error in the basic mixed precision calculation,and realises the automatic generation of source-to-source mixed-precision code for matrix multiplication for the first time.Experiments show that the maximum acceleration ratio of the advanced mixed-precision code generated by AGMMMPC is 1.39 and the geometric mean acceleration ratio is 1.14 on X86 platform with high-precision computation as the benchmark.
作者
何昊天
周蓓
郭绍忠
张作言
郝江伟
许瑾晨
HE Haotian;ZHOU Bei;GUO Shaozhong;ZHANG Zuoyan;HAO Jiangwei;XU Jinchen(School of Cyberspace Security,University of Information Engineering,Zhengzhou 450001,China)
出处
《计算机科学》
CSCD
北大核心
2024年第12期110-119,共10页
Computer Science
关键词
混合精度
矩阵乘法
多面体模型
调度变换
代码生成
Mixed precision
Matrix multiplication
Polyhedral model
Scheduling transformation
Code Generation