Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Sep 1997 16:18:06 +0000 (GMT)
From:      Terry Lambert <tlambert@primenet.com>
To:        kuku@gilberto.physik.RWTH-Aachen.DE (Christoph Kukulies)
Cc:        tlambert@primenet.com, kuku@gilberto.physik.RWTH-Aachen.DE, freebsd-hackers@freefall.FreeBSD.org
Subject:   Re: FPE problem
Message-ID:  <199709181618.JAA17494@usr03.primenet.com>
In-Reply-To: <19970918163531.11717@gil.physik.rwth-aachen.de> from "Christoph Kukulies" at Sep 18, 97 04:35:31 pm

next in thread | previous in thread | raw e-mail | index | archive | help
> A little bit more info now:
>   
> 	ret_val = -z__ * (spint_1.a1 * z__ * (spint_1.a2 * z__ * (spint_1.a3 *
> 		 z2 * (spint_1.a4 * z2 * (spint_1.a5 * z2 * (spint_1.a6 * z2 *
> 		 (spint_1.a7 * z2 * (spint_1.a8 * z2 * (spint_1.a9 * z2 * (
> 		spint_1.a10 * z2 + 1.) + 1.) + 1.) + 1.) + 1.) + 1.) + 1.) + 
> 		1.) + 1.) + 1.) + spint_1.zeta2 + z__ * log(1. - *x);
> 
> 
> (xxgdb) info float
> u: status 0x82e1: exceptions: INVALID LOS FPSTACK; flags: 0010; top 0
> e: status 0x200: flags: 0010; top 0
> control 0x1272: compute to 53 bits; round NEAREST; mask: DENORM UNDERF LOS;
> last instruction: opcode 0x1d0; pc 0x8:0xf01f9a96; operand 0x27:0x92844

[ ... ]

> What is LOS ? Loss of significance?

Uh, an acronym.  8-).  I'd actually have to break out my Intel book to
tell you for sure.  It's something that means about that anyway.  It
could be "Loss Of Signal" knowing Intel...


> When I'm seeing such a few steps before the exception occurs, does it mean
> that an exception is pending?
> ---------------------------vvv
> status 0x3920: exceptions: LOS; flags: 0001; top 7
> control 0x1272: compute to 53 bits; round NEAREST; mask: DENORM UNDERF LOS;
> last instruction: opcode 0x6d9; pc 0x1f:0x1b280; operand 0x27:0x1aca0

Floating point values are stored as sign, exponent, and mantisa.

It means that given the exponent, the value that can be expressed by
any given mantisa is domain limited.  That is, it has the same range
it's always had, but the effects are amplified to the degree that
there is a loss of precision as a result.

You can think of any given mantisa as a slow clockwise spiral from
an exponenet of 1 out to the highest possible positive exponent, and
a negative spiral from an exponent of 1 to 0.

If you plot two adjacent mantisa'a in say a multiply operation, the
arms of the spiral spread out the further out you get.  The number
space is basically quantized, with a decreasing radial density.  Have
you ever seen a circular log-decilog slide-rule with the top off?
Another analogy might be a fixed number of sectors on all tracks
on a hard drive.


In the multiplicative and divisive underflow examples I gave in my
previous mail, you were looking at the number of bits at which point
the curve of the spiral became tangential to a bounding circle (in
the counterclockwise direction).  Binary numbers don't understand
Zeno's paradox. ;-).

When you are dealing with a small real number X, 1 > fabs(X) > 0, in
an equation with associative properties, you should do the divides
before you do the multiplies to keep the result "centered" in the
highest precision area of the graph I described.  Basically, you
should dictate order of associativity.

Since this is physics code, this should be easy; after all, you
never do a physics problem where you don't have an expectation
about the answer.  If you did, you'd be a mathematician, not a
physicist testing a model's ability to predict empirical data.  8-).

For the original code, you can dictate order of associativity by
putting parenthesis in the original FORTRAN code based on the quantities
you expect to be multiplying or dividing.  These should carry over to
the post-translation C code.

If it's any consolation, I was stumped for a good week the first
time this happened to me.  That's about 1.0e13 Proton-Proton pair
production collisions on the very expensive hardware I was using.  8-(.


					Regards,
					Terry Lambert
					terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199709181618.JAA17494>