-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Non-musl f32
functions?
#298
Comments
@jdh8 do you have any specific examples of which specific functions you are talking about? Supplying math symbols that are not exposed in |
I have published metallic, so its docs are publicly available. For now I have implemented Functions not yet in
|
Is your crate |
Which platform are you doing the performance comparison on? Looking at the performance numbers, you've math builtins don't appear to be coming from Rust You've stated that the accuracy of all the functions is error < 1 ULP; is this just an upper bound or can this amount of error actually occur for each functions? Using this paper it's possible to compare to the accuracy of the MUSL versions of I ask because both the CORE-MATH project and LLVM libc both provide correctly rounded (error <= 0.5 ULP) implementations of the functions that have competitive performance (a performance comparison with glibc is displayed on the CORE-MATH project website). All else being equal, it would be good to move towards Rust libm having correctly-rounded implementations where possible. |
I'm using I just tested if the errors are < 1 ulp. I have not yet computed the maximum error for each function. Wow, correctly rounded transcendental functions exist! I dare not dream about this because of the Table Maker's Dilemma. |
Re. the correctly rounded transcendental functions and the table maker's dilemma: this paper goes in to how the dilemma is dealt with. (For single-argument |
True, exhaustive computation for univariate If correct rounding is a goal, I don't think I can make anything better than CORE-MATH. Maybe we should port CORE-MATH or LLVM libc instead? I've read several math functions from CORE-MATH. These functions are already using my assumptions such as calling |
I've also been thinking of porting from CORE-MATH: the implementations seem to be self contained (making it easier to port) and well tested against the GNU MPFR library. FYI per rust-lang/rust#128386 (comment) I believe @alexpyattaev is currently looking into porting a new implementation of |
For note, Rust has good wrappers for MPFR. See rug |
I gain my confidence back! There is still room for optimization because we can ignore the floating-point environment. I'm upgrading my library to correct rounding. |
I also have a project that's semi-related to this issue: I have developed an implementation of the Lambert W function: https://crates.io/crates/lambert_w. Would integrating this capability be interesting? It is |
Thanks, but as far as I know Lambert's W is not in standard library, and this issue is about functions in std. Whether it belongs in std or not is a separate question entirely. |
Are you interested in non-musl implementations, especially
f32
functions faster on modern architectures? I am writing math functions in Rust from scratch, based on my own research since 2017:https://github.com/jdh8/metallic-rs
My functions are tested to be faithfully rounded (error < 1 ulp). Unlike most C libraries, I assume that
f64
instructions are available even forf32
functions and also try to use FMA if possible. I also keep LUTs to a minimum with WebAssembly in mind.Benchmarks show that my implementations are faster than musl (libm) and glibc (std on Linux) except for
libm::logf
https://github.com/jdh8/metallic-rs/actions/runs/10342894582/job/28626374065
The text was updated successfully, but these errors were encountered: