This is an archive of the discontinued LLVM Phabricator instance.

[libc] Improve the performance of expm1f.
ClosedPublic

Authored by lntue on Mar 26 2022, 8:59 PM.

Details

Summary

Improve the performance of expm1f:

  • Rearrange the selection logic for different cases to improve the overall

throughput.

  • Use the same degree-4 polynomial for large inputs as expf

(https://reviews.llvm.org/D122418), reduced from a degree-7 polynomial.

Performance benchmark using perf tool from CORE-MATH project
(https://gitlab.inria.fr/core-math/core-math/-/tree/master):
Before this patch:

$ ./perf.sh expm1f

CORE-MATH reciprocal throughput   : 15.362
System LIBC reciprocal throughput : 53.288
LIBC reciprocal throughput        : 54.572

$ ./perf.sh expm1f --latency

CORE-MATH latency   : 57.759
System LIBC latency : 147.146
LIBC latency        : 118.057

After this patch:

$ ./perf.sh expm1f

CORE-MATH reciprocal throughput   : 15.359
System LIBC reciprocal throughput : 53.188
LIBC reciprocal throughput        : 14.600

$ ./perf.sh expm1f --latency

CORE-MATH latency   : 57.774
System LIBC latency : 147.119
LIBC latency        : 60.280

Diff Detail

Event Timeline

lntue created this revision.Mar 26 2022, 8:59 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptMar 26 2022, 8:59 PM
lntue requested review of this revision.Mar 26 2022, 8:59 PM
lntue updated this revision to Diff 418432.Mar 26 2022, 9:20 PM

Improve performance for exceptional cases.

lntue updated this revision to Diff 418849.Mar 29 2022, 5:46 AM

Final revision.

lntue retitled this revision from [libc] Improve the performance of expm1. to [libc] Improve the performance of expm1f..Mar 29 2022, 6:17 AM
lntue edited the summary of this revision. (Show Details)
lntue updated this revision to Diff 418858.Mar 29 2022, 6:21 AM

Remove redundant check.

zimmermann6 accepted this revision.Mar 29 2022, 6:31 AM

all values are still correctly rounded, and I confirm the speed improvement:

zimmerma@tomate:/tmp/core-math$ LIBM=/users/zimmerma/svn/core-math/libllvmlibc.a ./perf.sh expm1f # previous code
22.692
54.039
53.218
zimmerma@tomate:/tmp/core-math$ LIBM=/tmp/libllvmlibc.a ./perf.sh expm1f # new code
22.698
54.037
17.240

The llvm-libm results are the 3rd ones (first CORE-MATH, second GNU libc).

This revision is now accepted and ready to land.Mar 29 2022, 6:31 AM
lntue edited the summary of this revision. (Show Details)Mar 29 2022, 6:59 AM
santoshn accepted this revision.Mar 30 2022, 3:48 PM

Looks good to me.

This revision was automatically updated to reflect the committed changes.