一句话:提出 MegaLibm,一个用于实现、测试、调优与合成数学库函数的领域特定语言。
数学库函数(如 exp、sin、log)在速度与精度上难以兼顾,而 C 等底层语言无法帮助开发者发现数学错误、增量构建实现或分离高层算法与底层决策。为此,作者设计了领域特定语言 MegaLibm,它通过语义良构性检查检测符号翻转等数学错误,以模块化、可组合方式实现范围归约(range reduction),并用正交调优参数调整工作精度与求值方案。MegaLibm 还支持交互式编译、测试与调优,并可调用 Sollya 和类型导向合成来补全组件或合成整个实现。评估表明,MegaLibm 能以与原 C 代码相当的速度和精度表达 8 个先进数学库实现,并能在最少指导下合成 5 个变体和 3 个从零实现。
Achieving speed and accuracy for math library functions like exp , sin , and log is difficult. This is because low-level implementation languages like C do not help math library developers catch mathematical errors, build implementations incrementally, or separate high-level and low-level decision making. This ultimately puts development of such functions out of reach for all but the most experienced experts. To address this, we introduce MegaLibm, a domain-specific language for implementing, testing, and tuning math library implementations. MegaLibm is safe, modular, and tunable. Implementations in MegaLibm can automatically detect mathematical mistakes like sign flips via semantic wellformedness checks, and components like range reductions can be implemented in a modular, composable way, simplifying implementations. Once the high-level algorithm is done, tuning parameters like working precisions and evaluation schemes can be adjusted through orthogonal tuning parameters to achieve the desired speed and accuracy. MegaLibm also enables math library developers to work interactively, compiling, testing, and tuning their implementations and invoking tools like Sollya and type-directed synthesis to complete components and synthesize entire implementations. MegaLibm can express 8 state-of-the-art math library implementations with comparable speed and accuracy to the original C code, and can synthesize 5 variations and 3 from-scratch implementations with minimal guidance.
@article{paperbot2644,
title = {Implementation and Synthesis of Math Library Functions},
author = {Ian Briggs and Yash Lad and Pavel Panchekha},
journal = {Proceedings of the ACM on Programming Languages},
volume = {8},
number = {POPL},
year = {2024},
doi = {10.1145/3632874}
}