* denorms on the alpha
@ 1998-07-20 19:24 Greg Lindahl
1998-07-20 20:24 ` Jim Paradis
1998-07-20 20:37 ` Wes Bauske
0 siblings, 2 replies; 7+ messages in thread
From: Greg Lindahl @ 1998-07-20 19:24 UTC (permalink / raw)
To: axp-list
I've been beating on my people claiming kernel bugs on the alphas and
I've found that at least some of their fp exceptions are derministic
and are due to denormalized values. For example:
#include <stdio.h>
main () {
union {
long long i;
double f;
} bob;
bob.i = 2725351540;
printf ("The value is %g.\n", bob.f );
bob.f *= 2;
printf ("The value is %g.\n", bob.f );
}
This program crashes when I multiply a denorm by 2. Is it the case
under Linux/Alpha that denorms should never be generated and cause fp
exceptions when you do any operations with them?
-- g
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: denorms on the alpha
1998-07-20 19:24 denorms on the alpha Greg Lindahl
@ 1998-07-20 20:24 ` Jim Paradis
1998-07-20 20:37 ` Wes Bauske
1 sibling, 0 replies; 7+ messages in thread
From: Jim Paradis @ 1998-07-20 20:24 UTC (permalink / raw)
To: axp-list
> This program crashes when I multiply a denorm by 2. Is it the case
> under Linux/Alpha that denorms should never be generated and cause fp
> exceptions when you do any operations with them?
Well... depends on how you want to handle things. Ideally, yes; floating
point calculations should always take place with valid numbers, never
overflow, never divide by zero, never do anything that'll generate an
exception. In the real world, though, this isn't always the case. I
just read an article about the US Navy ship Yorktown. They're running
the whole ship on a non-UNIX operating system (I am Not Telling which
one...). An officer entered a zero into a field, which caused a divide
by zero error, which wasn't handled by the application or the OS (the
article wasn't clear). The resulting crash shut down the ship's propulsion
system; they were dead in the water for a couple of hours until they
could reboot everything.
If you want "quiet" exception behavior according to the IEEE spec (i.e.
FP ops on denorms or NaNs or infinities produce the appropriate NaN
results but otherwise don't affect program execution flow) then you have
to specify "-mieee" to the compiler and pay a performance penalty.
If you can scrub your code so that these things *don't* happen, then
you can take advantage of Alpha pipelining, omit the "-mieee", and
run much faster.
--
Jim Paradis (paradis@linux01.hlo.dec.com) "The early bird gets the worm.
Compaq Computer Corporation If you want something else for
(508)841-3243 breakfast, get up later."
http://www.tiac.net/users/jrp/index.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: denorms on the alpha
1998-07-20 19:24 denorms on the alpha Greg Lindahl
1998-07-20 20:24 ` Jim Paradis
@ 1998-07-20 20:37 ` Wes Bauske
1998-07-20 22:27 ` denorms on the alpha - confusion Phil Marsden
1 sibling, 1 reply; 7+ messages in thread
From: Wes Bauske @ 1998-07-20 20:37 UTC (permalink / raw)
To: axp-list
Greg Lindahl wrote:
>
> I've been beating on my people claiming kernel bugs on the alphas and
> I've found that at least some of their fp exceptions are derministic
> and are due to denormalized values. For example:
>
> #include <stdio.h>
>
> main () {
>
> union {
> long long i;
> double f;
> } bob;
>
> bob.i = 2725351540;
> printf ("The value is %g.\n", bob.f );
>
> bob.f *= 2;
>
> printf ("The value is %g.\n", bob.f );
> }
>
> This program crashes when I multiply a denorm by 2. Is it the case
> under Linux/Alpha that denorms should never be generated and cause fp
> exceptions when you do any operations with them?
>
The HW manual I looked at says this is not maskable. It
will always interrupt. The more common case is a FP
array being overwritten by something non-FP and then
attempting to do FP ops on it, or a non-initialized stack
variable being used. All cases I've found in my
code and others this was a bug in the code, not an
intended calculation. Intel seems to just treat this as
a real small number, effectively zero, so it has little
effect on the FP op, except maybe if you try divide by one.
I think Uncle George had a case where he thought it
was a valid calculation but I haven't.
A bug is a bug. If it were my code, I'd just fix it.
Only other choice is to slow down the code with -mieee.
Wes
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: denorms on the alpha - confusion...
1998-07-20 20:37 ` Wes Bauske
@ 1998-07-20 22:27 ` Phil Marsden
1998-07-20 22:18 ` Jim Paradis
0 siblings, 1 reply; 7+ messages in thread
From: Phil Marsden @ 1998-07-20 22:27 UTC (permalink / raw)
To: axp-list
Okay.. this seem resonable, but...
I have a peice of code which uses one of Numerical Recipies ODE
integration routines (the one with the clever step size). Works fine on an
intel box, but when run on the alpha, even with -mieee it produces a
floating point exception.
I can now see myself going through this all of tomorrow to discover the
bug, but _should_ it work? Am I being really dumb? Is there a better way
to approach this?
Beginning to regret getting an alpha...
Phil.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: denorms on the alpha - confusion...
1998-07-20 22:27 ` denorms on the alpha - confusion Phil Marsden
@ 1998-07-20 22:18 ` Jim Paradis
1998-07-21 9:05 ` Richard Henderson
0 siblings, 1 reply; 7+ messages in thread
From: Jim Paradis @ 1998-07-20 22:18 UTC (permalink / raw)
To: axp-list
> I have a peice of code which uses one of Numerical Recipies ODE
> integration routines (the one with the clever step size). Works fine on an
> intel box, but when run on the alpha, even with -mieee it produces a
> floating point exception.
Which version of redhat and gcc are you using? There was a bug in
gcc where it did not handle cvttq instructions correctly, even with
-mieee enabled. This bug was fixed in egcs.
What you should do is compile the code with -mieee, then run it
under gdb and catch the sigfpe. Then take the faulting PC and
disassemble the dozen instructions around it and see if you can
spot a likely candidate (e.g. a floating point instruction that
does not have the "/s" flag specified). Let us know what you find.
--
Jim Paradis (paradis@linux01.hlo.dec.com) "The early bird gets the worm.
Compaq Computer Corporation If you want something else for
(508)841-3243 breakfast, get up later."
http://www.tiac.net/users/jrp/index.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: denorms on the alpha - confusion...
1998-07-20 22:18 ` Jim Paradis
@ 1998-07-21 9:05 ` Richard Henderson
1998-07-21 10:44 ` Phil Marsden
0 siblings, 1 reply; 7+ messages in thread
From: Richard Henderson @ 1998-07-21 9:05 UTC (permalink / raw)
To: axp-list
On Mon, Jul 20, 1998 at 06:18:54PM -0400, Jim Paradis wrote:
> Which version of redhat and gcc are you using? There was a bug in
> gcc where it did not handle cvttq instructions correctly, even with
> -mieee enabled. This bug was fixed in egcs.
And which kernel. There were bugs present in the kernel's side of
things at least through 2.0.33.
r~
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: denorms on the alpha - confusion...
1998-07-21 9:05 ` Richard Henderson
@ 1998-07-21 10:44 ` Phil Marsden
0 siblings, 0 replies; 7+ messages in thread
From: Phil Marsden @ 1998-07-21 10:44 UTC (permalink / raw)
To: Alphalist
> On Mon, Jul 20, 1998 at 06:18:54PM -0400, Jim Paradis wrote:
> > Which version of redhat and gcc are you using? There was a bug in
> > gcc where it did not handle cvttq instructions correctly, even with
> > -mieee enabled. This bug was fixed in egcs.
I was using gcc 2.7.3 which caused an FP exception even with -mieee now I
get a runtime error with gcc 2.8.1 so I guess I will try egcs at
lunchtime and see what happens then.
>
> And which kernel. There were bugs present in the kernel's side of
> things at least through 2.0.33.
I am now using 2.0.34 (straight out of the box, I think (can't remember
whether I patched or not)). How do I check this and will it cause a
problem?
Many thanks to everyone for the help so far.
Phil.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~1998-07-21 9:09 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-07-20 19:24 denorms on the alpha Greg Lindahl
1998-07-20 20:24 ` Jim Paradis
1998-07-20 20:37 ` Wes Bauske
1998-07-20 22:27 ` denorms on the alpha - confusion Phil Marsden
1998-07-20 22:18 ` Jim Paradis
1998-07-21 9:05 ` Richard Henderson
1998-07-21 10:44 ` Phil Marsden
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox