-
Notifications
You must be signed in to change notification settings - Fork 100
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
Internal usage of f64 in some f32 functions #118
Comments
I saw that the kernel in |
I did a quick benchmark of the kernel over the The maximum error is |
I extended it for cos as well and added relative error (10M steps): https://gist.github.com/korken89/6a219e0cf87be244009086072816b524 Max error sin = |
These implementations from musl library. |
What I am trying to point out is that there is no difference when the max error is 0.000000168585, it is at the edge of precision for |
copy pasting some of my IRC comments here for posteriority / visibility:
|
I would expect it is to avoid cancellation errors. |
From the internal kernel of the |
@korken89 could your run your test again measuring the max error in ULPs or percent error instead of in absolute? Absolute error seems like it could be misleading here when the results are potentially small. |
Please see my previous response, take the relative error *100 and you have percent. And is on the order of 0.000017% worst case. :) |
Ah, my bad, I misread what you were doing, thank you. |
I slightly modified your test bench to get the error in ULPs (maybe someone check my work…): https://gist.github.com/porglezomp/3ec824f07d15ba5383992f573e6be120 The max error in |
Thank you for adding! ULPs really shows how close the kernels are writhin it's designed bounds. |
I found this look into sine approximation (in Rust) utilizing Chebychev polynomials, but over the [-pi, pi] domain. However, this is not the current issue, but still a good read. |
I looked at We could use the newlib implementations of some f32 functions but we would have to tweak the test system to generate the expected outputs using newlib. |
@japaric I think this would be a really good idea! |
Hi, I have been looking into the argument reduction and why they need the immense amount of bits of pi. The math behind the implementation they have done, and the need for all the bits is described here: https://www.csee.umbc.edu/~phatak/645/supl/Ng-ArgReduction.pdf More or less, to make an argument reduction correctly of very large inputs (let say However, the implementation used here is for |
@korken89 I think it would be easier to test the accuracy of a 1:1 port of newlib. |
I already ported sinf and cosf from newlib with dependencies and can add them in 1 day. |
@burrbull nice! Do you also have looked into adding testing support for newlib? If not, I can take a stab at it. |
The test generator now supports testing against newlib. I have created several issues to track porting some of the newlib implementations. They are all under the newlib milestone. newlib's implementation of fmaf also uses f64 operations so we'll need to port some other implementation or write one ourselves -- I have also created an issue for that task in #140. I'm going to close this issue in favor of the individual issues. |
Hi, I had a look over the library and something struck me as odd.
For example in
sinf
andk_sinf
the input arguments are being cast up intof64
, which will incur a significant run-time cost onno_std
systems which only has an single precision floating point unit.Moreover, the calculation being done in, for example here:
https://github.com/japaric/libm/blob/3932e2ea8e7e8f782cea6b243c3032d415b8afeb/src/math/sinf.rs#L62
The
f64
is only used for sums, which does not need the extra precision given byf64
.This looks like a copy/paste bug to me, but I would like to hear your reasoning about this.
The text was updated successfully, but these errors were encountered: