This is sources Bugzilla
Bugzilla Version 2.17.5
Bugzilla Bug 6406
  Improve performance of libm wrapper functions. Last modified: 2008-06-27 15:34
     Query page      Enter new bug
Bug#: 6406   Hardware:   Reporter: Steven Munroe <sjmunroe@us.ibm.com>
Host: Target: Build:
Product:     Add CC:
Component:   Version:   CC:
Remove selected CCs
Status: NEW   Priority:  
Resolution:   Severity:  
Assigned To: Andreas Jaeger <aj@suse.de>   Target Milestone:  
Flags: Requestee:
  backport ()
  examined ()
  testsuite ()
Summary:
Keywords:

Attachment Description Type Created Actions
ppc-math-private-20080413.txt A proposed method for inlining range checks in libm wrappers patch 2008-04-15 02:00 Edit | Diff
x8664-math-private-20080413.txt Example implementation of the x86_64 platform patch 2008-04-15 02:27 Edit | Diff
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 6406 depends on: Show dependency tree
Show dependency graph
Bug 6406 blocks:

Additional Comments:


Leave as NEW 
Mark bug as waiting for feedback
Mark bug as suspended
Accept bug (change status to ASSIGNED)
Resolve bug, changing resolution to
Resolve bug, mark it as duplicate of bug #
Reassign bug to
Reassign bug to owner of selected component

View Bug Activity   |   Format For Printing


Description:   Last confirmed: 0000-00-00 00:00 Opened: 2008-04-15 01:51
Many math lib functions have a wrapper function in front of the ieee754
implementation. This wrapper function will check for specific error conditions
and set errno as required by C99 or Posix.

This wrapper function can add significant path length and is composed of often
redundant isnan, isinf, finite tests which is incur the call overhead to that
function. Also since we are using the general purpose functions, the same value
is  transfered and manipulated in the same or similar ways multiple times.

Performance could be improved by making these tests inline, allowing the
compiler and optimize out data transfers and common subexpressions.

------- Additional Comment #1 From Steven Munroe 2008-04-15 02:00 -------
Created an attachment (id=2691)
A proposed method for inlining range checks in libm wrappers

This method defines macros in math_private.h that; declare transfer variables
(unions), transfer FP parms to a convenient (int) form for manipulation, 
defines macros for inline versions of ISNAN, ISINF, FINITE, SIGNBIT. 
the the DCL and XFER macros are separate to allow the flexibility for
scheduling.
This version includes the default math/math_private.h, examples uses for
w_exp.c w_log.c and w_pow.c and a platform specific override for powerpc.

------- Additional Comment #2 From Steven Munroe 2008-04-15 02:16 -------
The implementation above returns a performance improvement at the micro
benchmark level of 4% (w_exp), 8% (w_log), and 15% (w_pow) for power5 and power6
systems. based on GCC-4.3 and todays GLIBC cvs.

------- Additional Comment #3 From Steven Munroe 2008-04-15 02:27 -------
Created an attachment (id=2692)
Example implementation of the x86_64 platform

This is an example for x86_64. So far it returns mixed results. the results are
disappointing for w_exp and w_log but an impressive 43% improvement for w_pow.
Not sure why the simpler w_exp and w_log case do not improve. As far as I can
tell the total path is shorter with this test patch.

This is only test and without this patch ./math/math_privated.h from the
previous patch maintains the existing implementation.

I am sure someone more skilled in x86_64 can devise a solution that retains the
gains for w_pow and resolves the problems with w_exp and w_log.

------- Additional Comment #4 From Steven Munroe 2008-04-15 16:07 -------
marked the severity as enhancement

------- Additional Comment #5 From Steven Munroe 2008-06-26 14:12 -------
HJ this is the proposal I mentioned to you at GCC Summit. It way for each
platform to inline the isnan, isinf, finite, etc test in the libm function
wrappers (i.e w_pow.c)

Is uses macros defined in math-private.h to inline the various (redundent) tests
required to set errno (if needed). The generic ./math/math_private.h maintains
the status quo, but a platform can override math_private.h to define macros that
work best for them.

------- Additional Comment #6 From H.J. Lu 2008-06-27 15:34 -------
(In reply to comment #5)
> HJ this is the proposal I mentioned to you at GCC Summit. It way for each
> platform to inline the isnan, isinf, finite, etc test in the libm function
> wrappers (i.e w_pow.c)
> 
> Is uses macros defined in math-private.h to inline the various (redundent) tests
> required to set errno (if needed). The generic ./math/math_private.h maintains
> the status quo, but a platform can override math_private.h to define macros that
> work best for them.

I will take a look at x86-64.

     Query page      Enter new bug
Actions: New | Query | bug # | Reports | Requests   New Account | Log In