RLibm-MultiRound: Correctly Rounded Math Libraries Without Worrying about the Application's Rounding Mode

📅 2025-04-10
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
Traditional correctly rounded math libraries suffer from high performance overhead due to frequent system rounding-mode switches and are restricted to round-to-nearest mode only. This work proposes the first mode-switch-free approach supporting all IEEE-754 rounding modes—round-toward-zero, round-up, and round-down—in addition to round-to-nearest. Our method introduces *rounding-agnostic outputs* and *rounding-agnostic input boundaries*, integrating error-agnostic polynomial approximation, round-toward-zero simulation transformations, interval-based error modeling, and native floating-point arithmetic. It guarantees strict correct rounding for all IEEE-754 binary32 and narrower formats. Crucially, it eliminates double-rounding errors entirely and ensures correctness across all supported precisions. Experimental evaluation demonstrates over 2× speedup compared to prior approaches, breaking the strong dependency on dynamic rounding-mode switching inherent in state-of-the-art libraries such as RLibm.

Technology Category

Application Category

📝 Abstract
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.
Problem

Research questions and friction points this paper is trying to address.

Generates correctly rounded math libraries for multiple rounding modes
Avoids performance cost from frequent rounding mode changes
Improves library performance by over 2X with new methods
Innovation

Methods, ideas, or system contributions that make the work stand out.

Uses round-to-zero mode for polynomial approximations
Employs error-free transformations for rounding mode emulation
Factors rounding errors using interval bounds
🔎 Similar Papers
No similar papers found.