[498] in linux-announce channel archive

home help back first fref pref prev next nref lref last post

inline-math

daemon@ATHENA.MIT.EDU (Lars Wirzenius)
Tue Apr 25 11:49:45 1995

Date: Tue, 25 Apr 1995 15:56:10 +0300
From: Lars Wirzenius <wirzeniu@cc.helsinki.fi>
To: linux-activists@niksula.hut.fi, linux-announce@vger.rutgers.edu

X-Mn-Key: announce

From: bowman@hagar.ph.utexas.edu (John Bowman)
Newsgroups: comp.os.linux.announce
Subject: inline-math
Keywords: inline floating-point math libm
Organization: ?
Approved: linux-announce@news.ornl.gov (Lars Wirzenius)
Followup-to: comp.os.linux.development.system

Version 1.0 of inline-math.tar.gz has been uploaded to sunsite:/pub/Linux/libs.

Inline-math is a gcc macro package that inlines the floating-point math
routines found in libm. It can typically improve execution speed by 10%.
These inline routines avoid using the flawed algorithms for sinh, tanh,
asinh, and atanh found in libm (which produce incorrect results for small
arguments).  The inlined math macros have been extensively tested against
the math libraries of other platforms, taylor series expansions, and various
self-consistency checks.

Several weeks ago, a posting by David Liu <liu@csb.yale.edu> complained
about gcc floating-point math errors. Like others, I could not reproduce
the erroneous results reported in that posting.  However, I could reproduce
the poor optimization. It appears that there is indeed a problem in the way
that gcc optimizes subroutine calls. In this case, inlining can be used to
circumvent the problem. However, it appears that the gcc optimizer could
still stand some improvement.

Here are the test results (reporting CPU, now wall clock, time) for
gcc 2.5.8 on a 486DX2-66 (using -m486):

libm:
-O0: Time: 63 seconds, sum: 59121281.784975.
-O2: Time: 73 seconds, sum: 59121281.784975.

inline-math:
-O0: Time: 65 seconds, sum: 59121281.784975.
-O2: Time: 55 seconds, sum: 59121281.784975.


Here is the README file from inline-math.tar.gz:

Instructions for using the inline floating-point macros for the 80387/80486
written by John C. Bowman (bowman@hagar.ph.utexas.edu).

To enable, simply add the lines

#if defined(__i386__)
# include </usr/local/include/i386/__math.h>
#endif

before the final #endif in /usr/include/math.h

Notes:

1.	The accuracy of the sinh, tanh, asinh, and atanh functions have been
	dramatically improved (relative to the poorly written libm versions)
	for arguments of small magnitude. For example, sinh(1.0e-7) now returns
	the correct value 1.0000000000000017e-07 (the libm routine incorrectly
	returns 9.9999999999975326e-08). The error in the libm routine can
	become very large: it returns 9.7578195523695399e-19 for sinh(1.0e-18)
	(the correct value is 1.0e-18).

2.	This macro package includes the functions coshm1(x)=cosh(x)-1
	and acosh1p(x)=acosh(1+x). Unlike acosh(x) and cosh(x), these functions
	are exact inverses of each other (to within machine precision). 

3.	Inlining may be disabled at compile time with the GCC option
	-D__NO_MATH_INLINES.


-- John Bowman
Institute for Fusion Studies, RLM 11.222           
The University of Texas at Austin           
Austin, TX 78712
Email: bowman@hagar.ph.utexas.edu

--
Send submissions for comp.os.linux.announce to: linux-announce@news.ornl.gov
PLEASE remember Keywords: and a short description of the software.


home help back first fref pref prev next nref lref last post