Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[libc][math][c23] Add rsqrtf16() function #137545

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

amemov
Copy link
Contributor

@amemov amemov commented Apr 27, 2025

Addresses #132818
Part of #95250

- Defined and declared rsqrtf16
- Added entrypoints to support rsqrt in float16 format
- Added tests - both unit and exhaustive
- Added MPFR support for Rsqrt to verify the test results

TODO:
- Write computation as a polynomial in the end of rsqrtf16.cpp
- Check if errors are generated correctly (Reference from C23: The rsqrt functions compute the reciprocal of the nonnegative square root of the argument. A domain error occurs if the argument is less than zero. A pole error may occur if the argument equals zero.)
Copy link

github-actions bot commented Apr 27, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@amemov
Copy link
Contributor Author

amemov commented Apr 30, 2025

Trying to figure out what would be the best option to compute the result.
I found that the current polynomial produces the least errors ( bigger ones yield negligible results )
P = fpminimax(1/sqrt(x), [|0,1,2,3,4,5|], [|SG...|], [0.5, 1]);
And has ULP Error = 1.0

Also found this already existing implementation:

// P = fpminimax(sqrt(x), 1, [|8, 8|], [i * 2^-4, (i + 1)*2^-4],

It has some other interesting points that I found when I was doing my research: specifically, Newton's method. I tried adding one iteration of it, but same: it didn't help much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant