RLibm-MultiRound:无需担心应用舍入模式的正确舍入数学库
RLibm-MultiRound: Correctly Rounded Math Libraries Without Worrying about the Application's Rounding Mode
AI总结:
本文提出舍入不变输出和舍入不变输入边界两种新方法,避免 RLibm 数学库频繁更改舍入模式,使生成库性能提升2倍以上。
摘要:
我们的 RLibm 项目为初等函数生成单一实现,该实现能为多种舍入模式和最多32位的表示产生正确舍入的结果。它们非常适合用于开发没有双重舍入问题的快速参考库。其核心洞察是构建多项式,使其在与最大目标表示相比多两个比特的表示下,使用“非标准”的舍入到奇数模式产生正确舍入结果,这使得将 RLibm 数学库结果双重舍入到任何更小的目标表示是无害的。RLibm 方法生成的近似值通过使用舍入到最近模式的机器支持浮点运算来实现。当应用使用除舍入到最近模式以外的舍入模式时,RLibm 数学库会保存应用的舍入模式,将系统舍入模式更改为舍入到最近,计算正确舍入结果,然后恢复应用的舍入模式。这种频繁更改舍入模式会带来性能开销。本文提出两种新方法,分别称为舍入不变输出和舍入不变输入边界,以避免频繁更改舍入模式和对舍入到最近模式的依赖。首先,新的舍入不变输出方法提出使用舍入到零模式来实现 RLibm 的多项式近似。我们提出快速、无误差的变换,从任何标准舍入模式模拟舍入到零结果而无需更改舍入模式。其次,舍入不变输入边界方法在 RLibm 流水线中使用区间边界分解不同舍入模式引起的任何舍入误差。两种方法做出不同的权衡,将生成库的性能提高2倍以上。
英文摘要:
Our RLibm project generates 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 polynomials 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 floating-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 2X.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。