glibc/sysdeps
Siddhesh Poyarekar 2506109403 Set/restore rounding mode only when needed
The most common use case of math functions is with default rounding
mode, i.e. rounding to nearest.  Setting and restoring rounding mode
is an unnecessary overhead for this, so I've added support for a
context, which does the set/restore only if the FP status needs a
change.  The code is written such that only x86 uses these.  Other
architectures should be unaffected by it, but would definitely benefit
if the set/restore has as much overhead relative to the rest of the
code, as the x86 bits do.

Here's a summary of the performance improvement due to these
improvements; I've only mentioned functions that use the set/restore
and have benchmark inputs for x86_64:

Before:

cos(): ITERS:4.69335e+08: TOTAL:28884.6Mcy, MAX:4080.28cy, MIN:57.562cy, 16248.6 calls/Mcy
exp(): ITERS:4.47604e+08: TOTAL:28796.2Mcy, MAX:207.721cy, MIN:62.385cy, 15543.9 calls/Mcy
pow(): ITERS:1.63485e+08: TOTAL:28879.9Mcy, MAX:362.255cy, MIN:172.469cy, 5660.86 calls/Mcy
sin(): ITERS:3.89578e+08: TOTAL:28900Mcy, MAX:704.859cy, MIN:47.583cy, 13480.2 calls/Mcy
tan(): ITERS:7.0971e+07: TOTAL:28902.2Mcy, MAX:1357.79cy, MIN:388.58cy, 2455.55 calls/Mcy

After:

cos(): ITERS:6.0014e+08: TOTAL:28875.9Mcy, MAX:364.283cy, MIN:45.716cy, 20783.4 calls/Mcy
exp(): ITERS:5.48578e+08: TOTAL:28764.9Mcy, MAX:191.617cy, MIN:51.011cy, 19071.1 calls/Mcy
pow(): ITERS:1.70013e+08: TOTAL:28873.6Mcy, MAX:689.522cy, MIN:163.989cy, 5888.18 calls/Mcy
sin(): ITERS:4.64079e+08: TOTAL:28891.5Mcy, MAX:6959.3cy, MIN:36.189cy, 16062.8 calls/Mcy
tan(): ITERS:7.2354e+07: TOTAL:28898.9Mcy, MAX:1295.57cy, MIN:380.698cy, 2503.7 calls/Mcy

So the improvements are:

cos: 27.9089%
exp: 22.6919%
pow: 4.01564%
sin: 19.1585%
tan: 1.96086%

The downside of the change is that it will have an adverse performance
impact on non-default rounding modes, but I think the tradeoff is
justified.
2013-06-12 10:36:48 +05:30
..
generic Set/restore rounding mode only when needed 2013-06-12 10:36:48 +05:30
gnu Avoid trailing whitespace in sysdeps/gnu/errlist.c. 2013-06-08 14:55:32 +00:00
i386 Set/restore rounding mode only when needed 2013-06-12 10:36:48 +05:30
ieee754 Fix leading whitespaces. 2013-06-06 20:36:07 +02:00
init_array Add sysdeps/init_array to produce empty crt[in].o and use .preinit_array for gcrt1.o 2013-03-12 12:50:13 -07:00
mach Use (void) in no-arguments function definitions. 2013-06-08 00:22:23 +00:00
posix Fix symbol definitions for __clock_* functions 2013-06-11 11:11:11 +05:30
powerpc PowerPC: Merge ports/ dl-procinfo.[ch] with base. 2013-06-11 10:13:39 -05:00
pthread BZ#15361: Make aio_fsync not check open modes. 2013-04-12 13:11:20 -07:00
s390 Remove trailing whitespace. 2013-06-05 20:44:03 +00:00
sh Remove trailing whitespace. 2013-06-05 20:44:03 +00:00
sparc Fix leading whitespaces. 2013-06-06 20:36:07 +02:00
unix Fix symbol definitions for __clock_* functions 2013-06-11 11:11:11 +05:30
wordsize-32 Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
wordsize-64 Move dummy glob64.c alongside glob.c that defines glob64. 2013-05-06 16:11:11 -07:00
x86 Avoid use of "register" as optimization hint. 2013-06-07 22:24:35 +00:00
x86_64 Remove trailing whitespace. 2013-06-05 20:44:03 +00:00