paperbot · PL 论文追踪

全部论文 待读 收藏

P1 Correctly Rounded Math Libraries without Worrying about the Application’s Rounding Mode

无需担忧应用舍入模式的正确舍入数学库
PLDI 9(PLDI)2025匹配度 5/10 · 论文聚焦浮点数学库的正确舍入与舍入模式处理,属于浮点数值正确性方向,与浮点程序分析有间接关联;但未涉及程序分析、LLM/Agent 或形式化验证,因此匹配度中等。引用 1 inbox
Sehyeok Park, Justin Kim, Santosh Nagarakatte
crossref: 2026-09-10

AI 速览

一句话:提出舍入不变输出与舍入不变输入界两种方法,使 RLibm 数学库无需频繁切换舍入模式,性能提升超过 2 倍。

RLibm 此前能为至多 32 位表示、多种舍入模式生成单一正确舍入初等函数实现,其多项式逼近基于 round-to-odd 与额外两位表示以避免双重舍入;但实现依赖 round-to-nearest,应用使用其他舍入模式时需保存、切换并恢复系统舍入模式,频繁切换带来性能开销。本文提出舍入不变输出与舍入不变输入界两种方法:前者用 round-to-zero 实现多项式逼近,并用快速无误差变换在不改变舍入模式的情况下从任意标准舍入模式模拟 round-to-zero;后者在 RLibm 流程中用区间界吸收不同舍入模式导致的误差。两种方法各有取舍,均使生成库性能提升 2 倍以上。

问题
RLibm 生成的正确舍入数学库依赖 round-to-nearest,应用使用其他舍入模式时需频繁切换系统舍入模式,造成性能开销。
方法
提出舍入不变输出(用 round-to-zero 实现多项式逼近,并用无误差变换模拟该模式)和舍入不变输入界(用区间界吸收不同舍入模式的误差)两种方法。
评估
在 RLibm 库中实现两种方法并测量性能,报告生成库性能提升超过 2 倍。
原文摘要(Abstract)

Our RLibm project has recently proposed methods to generate a single implementation for an elementary function that produces correctly rounded results for multiple rounding modes and representations with up to 32-bits. They are appealing for developing fast reference libraries without double rounding issues. The key insight is to build polynomial approximations that produce the correctly rounded result for a representation with two additional bits when compared to the largest target representation and with the “non-standard” round-to-odd rounding mode, which makes double rounding the RLibm math library result to any smaller target representation innocuous. The resulting approximations generated by the RLibm approach are implemented with machine supported foating-point operations with the round-to-nearest rounding mode. When an application uses a rounding mode other than the round-to-nearest mode, the RLibm math library saves the application’s rounding mode, changes the system’s rounding mode to round-to-nearest, computes the correctly rounded result, and restores the application’s rounding mode. This frequent change of rounding modes has a performance cost. This paper proposes two new methods, which we call rounding-invariant outputs and rounding-invariant input bounds, to avoid the frequent changes to the rounding mode and the dependence on the round-to-nearest mode. First, our new rounding-invariant outputs method proposes using the round-to-zero rounding mode to implement RLibm ’s polynomial approximations. We propose fast, error-free transformations to emulate a round-to-zero result from any standard rounding mode without changing the rounding mode. Second, our rounding-invariant input bounds method factors any rounding error due to different rounding modes using interval bounds in the RLibm pipeline. Both methods make a different set of trade-offs and improve the performance of resulting libraries by more than 2×.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@article{paperbot3093,
  title = {Correctly Rounded Math Libraries without Worrying about the Application’s Rounding Mode},
  author = {Sehyeok Park and Justin Kim and Santosh Nagarakatte},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {9},
  number = {PLDI},
  year = {2025},
  doi = {10.1145/3729332}
}