数学库函数的实现与综合
Implementation and Synthesis of Math Library Functions
AI总结:
本文提出安全、模块化、可调优的领域特定语言 MegaLibm,支持数学库函数的实现、检查、交互式测试调优与自动综合,并在多个先进实现上验证其性能与有效性。
摘要:
为 exp、sin 和 log 等数学库函数同时实现速度和精度十分困难。原因在于,C 等底层实现语言无法帮助数学库开发者发现数学错误、增量式地构建实现,或将高层与底层决策分离。这最终使得此类函数的开发只有最富经验的专家才能完成。为解决该问题,我们提出 MegaLibm,这是一种用于实现、测试和调优数学库实现的领域特定语言。MegaLibm 安全、模块化且可调优。MegaLibm 中的实现可通过语义良构性检查自动检测符号翻转等数学错误,而范围归约等组件能够以模块化、可组合的方式实现,从而简化实现。高层算法完成后,可通过正交的调优参数调整工作精度和求值方案等参数,以获得期望的速度与精度。MegaLibm 还支持数学库开发者交互式工作,对实现进行编译、测试和调优,并调用 Sollya 和类型引导综合等工具来补全组件以及综合完整实现。MegaLibm 能够表达 8 个最先进数学库实现,其速度和精度与原始 C 代码相当;还能在极少指导下综合出 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.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。