This is an archive of the discontinued LLVM Phabricator instance.

[libc] Add implementation of expm1f.
ClosedPublic

Authored by lntue on Apr 22 2021, 9:46 PM.

Details

Summary

Use expm1f(x) = exp(x) - 1 for |x| > ln(2).
For |x| <= ln(2), divide it into 3 subintervals: [-ln2, -1/8], [-1/8, 1/8], [1/8, ln2]
and use a degree-6 polynomial approximation generated by Sollya's fpminmax for each interval.
Errors < 1.5 ULPs when we use fma to evaluate the polynomials.

Diff Detail

Event Timeline

lntue created this revision.Apr 22 2021, 9:46 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 22 2021, 9:46 PM
lntue requested review of this revision.Apr 22 2021, 9:46 PM

LGTM but I have added a comment to add a sollya script. Good to go after that.

libc/src/math/generic/expm1f.cpp
29

I think we should add a sollya script for this under a directory named utils/mathtools so that future tuning can have a starting point to play with. And then, instead of inline comments like this, you can point to that sollya script at the top of this function.

libc/test/src/math/expm1f_test.cpp
32

Nitty nit: The name should probably be LlvmLibcExpm1fTest (ie. with the Exmpm1 capitalized.)

lntue updated this revision to Diff 341415.Apr 29 2021, 12:00 AM
lntue marked an inline comment as done.

Add more detail about generating polynomial coefficients with Sollya to utils/mathtools/expm1f.sollya.
Add differential and perf tests.

lntue updated this revision to Diff 341417.Apr 29 2021, 12:02 AM

Fix unit test name.

lntue marked an inline comment as done.Apr 29 2021, 12:03 AM
lntue edited the summary of this revision. (Show Details)
sivachandra accepted this revision.May 13 2021, 2:45 PM

fma and fmaf have been enabled on the bots so this is ready to go.

libc/utils/mathtools/expm1f.sollya
2

Add LLVM license header.

10

Do we really need the > in the script?

39

Can we use print commands to make this nicer?

This revision is now accepted and ready to land.May 13 2021, 2:45 PM
lntue updated this revision to Diff 351231.Jun 10 2021, 12:03 PM

[libc] Add implementation of expm1f.

This revision was landed with ongoing or failed builds.Jun 10 2021, 12:05 PM
This revision was automatically updated to reflect the committed changes.