GH-100485: Create an alternative code path when an accurate fma() implementation is not available (#101567)

This commit is contained in:
Raymond Hettinger 2023-02-04 17:54:44 -06:00 committed by GitHub
parent a89e6713c4
commit 5a2b984568
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 0 deletions

View file

@ -1450,6 +1450,11 @@ class MathTests(unittest.TestCase):
n = 20 # Length of vectors
c = 1e30 # Target condition number
# If the following test fails, it means that the C math library
# implementation of fma() is not compliant with the C99 standard
# and is inaccurate. To solve this problem, make a new build
# with the symbol UNRELIABLE_FMA defined. That will enable a
# slower but accurate code path that avoids the fma() call.
relative_err = median(Trial(math.sumprod, c, n) for i in range(times))
self.assertLess(relative_err, 1e-16)