Re: [RFC PATCH] riscv: add vectorized sin
Pincheng Wang <[email protected]> Fri, 10 Jul 2026 10:11:44 +0800
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <[email protected]> |
Hi Paul, On 2026/7/9 20:02, Paul Zimmermann wrote: >> The worst-case error is <= 1 ULP. > > great! Is that observed or do you have a proof of this bound? > Did you try with inputs from [1] and [2]? > > Note that it now exists some vector and correctly rounded implementations [3] and [4]. Thank you for the insightful questions. To be completely honest, the <= 1 ULP bound was an observation rather than a proof. I arrived at this conclusion by testing the implementation with approximately 770,000 samples (about 440,000 uniformly distributed random inputs across three code paths, plus roughly 300,000 random full-exponent-range bit patterns) against a 250-bit MPFR/mpmath reference. In those specific tests, no results exceeded 1 ULP. However, after running the test cases you provided, I realized my initial assessment was incomplete. The maximum ULP errors are 0.931 and 1.0 for trig.wc and sin.wc respectively. Specifically, 17 cases in sin.wc show a ULP error of exactly 1.0, and all of these cases fall into the slow path (where |x| >= 1e6). Thank you also for sharing those papers; they serve as excellent references for improving my implementation. I have also noticed that some open-source libraries, such as SLEEF [1], claim to achieve <= 1 ULP accuracy. Before formally submitting the patch, I will continue to study these resources and further refine the accuracy of my implementation, while ensuring license compatibility. Thank you very much for your valuable feedback and guidance. BR, Pincheng Wang [1] https://sleef.org/