This is an archive of the discontinued LLVM Phabricator instance.

[libc] Use nearest_integer instructions to improve expm1f performance.
ClosedPublic

Authored by lntue on Jul 25 2022, 10:46 AM.

Details

Summary

Use nearest_integer instructions to improve expf performance.

Performance tests with CORE-MATH's perf tool:

Before the patch:

$ ./perf.sh expm1f
LIBC-location: /home/lnt/experiment/llvm/llvm-project/build/projects/libc/lib/libllvmlibc.a
GNU libc version: 2.31
GNU libc release: stable
CORE-MATH reciprocal throughput   : 10.096
System LIBC reciprocal throughput : 44.036
LIBC reciprocal throughput        : 11.575

$ ./perf.sh expm1f --latency
LIBC-location: /home/lnt/experiment/llvm/llvm-project/build/projects/libc/lib/libllvmlibc.a
GNU libc version: 2.31
GNU libc release: stable
CORE-MATH latency   : 42.239
System LIBC latency : 122.815
LIBC latency        : 50.122

After the patch:

$ ./perf.sh expm1f
LIBC-location: /home/lnt/experiment/llvm/llvm-project/build/projects/libc/lib/libllvmlibc.a
GNU libc version: 2.31
GNU libc release: stable
CORE-MATH reciprocal throughput   : 10.046
System LIBC reciprocal throughput : 43.899
LIBC reciprocal throughput        : 9.179

$ ./perf.sh expm1f --latency
LIBC-location: /home/lnt/experiment/llvm/llvm-project/build/projects/libc/lib/libllvmlibc.a
GNU libc version: 2.31
GNU libc release: stable
CORE-MATH latency   : 42.078
System LIBC latency : 120.488
LIBC latency        : 41.528

Diff Detail

Event Timeline

lntue created this revision.Jul 25 2022, 10:46 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJul 25 2022, 10:46 AM
lntue requested review of this revision.Jul 25 2022, 10:46 AM
lntue edited the summary of this revision. (Show Details)Jul 25 2022, 10:47 AM
zimmermann6 accepted this revision.Jul 26 2022, 1:36 AM

I confirm that I get similar timings. Nice work!

This revision is now accepted and ready to land.Jul 26 2022, 1:36 AM