* g77 problems
@ 1998-09-01 10:56 Dr P. Caleb Dhanasekaran
1998-09-02 1:48 ` Michal Jaegermann
1998-09-02 4:23 ` Wes Bauske
0 siblings, 2 replies; 15+ messages in thread
From: Dr P. Caleb Dhanasekaran @ 1998-09-01 10:56 UTC (permalink / raw)
To: axp-list; +Cc: Caleb Dhanasekaran
Hi all`,
I have installed RedHat 5.1 on my Alpha UX4,600Mhz PC. I have
upgraded the compilers egcs.1.0.3 and g77-1.0.3 downloading the
rpm files.
My FORTRAN program works fine using fort77 but fails due to
Floating Exception when I use g77 compiler. I have been debugging
this program and when I insert a write(*,*) statement
in one of the subroutines the programs executes fine. I used
xxgdb to debug the program and it showed problem in cosine function
(libm).
Could anybody tell me what causes this type of Floating Exception
problem using g77 on Alpha? Is there any fix to this? This program works
fine on IBM Aix 4.1, HP, Silcon Graphics systems, and g77 on Intel
platform.`
Thanks,
Caleb
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: g77 problems
@ 1998-09-02 1:27 Greg Lindahl
0 siblings, 0 replies; 15+ messages in thread
From: Greg Lindahl @ 1998-09-02 1:27 UTC (permalink / raw)
To: axp-list
> My FORTRAN program works fine using fort77 but fails due to
> Floating Exception when I use g77 compiler. I have been debugging
> this program and when I insert a write(*,*) statement
> in one of the subroutines the programs executes fine. I used
> xxgdb to debug the program and it showed problem in cosine function
> (libm).
A floating point exception that comes and goes when you insert a
write(*,*) is usually a sign of an incorrect program. Different
compilers will then give different answers. Try turning on bounds
checking in fort77, etc, to try to find your bug. If you are
overwriting memory, writing an integer value into a floating point
variable sometimes produces a denormalized number, which results in
a crash on the alpha.
On the other hand, you may be really generating a denorm. In that
case compiling with g77 -mieee may be the fix. But in that case fort77
should also be showing a floating exception.
-- g
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: g77 problems
1998-09-01 10:56 Dr P. Caleb Dhanasekaran
@ 1998-09-02 1:48 ` Michal Jaegermann
1998-09-02 4:23 ` Wes Bauske
1 sibling, 0 replies; 15+ messages in thread
From: Michal Jaegermann @ 1998-09-02 1:48 UTC (permalink / raw)
To: axp-list
Dr P. Caleb Dhanasekaran wrote:
>
> but fails due to
> Floating Exception when I use g77 compiler.
Try to compile with -mieee flag. It is possible that you will
have to recompile your library(libraries) with this flag as well.
Probably you pass something which is causing overflow or underflow
and exception handling is quite interesting on Alpha. :-)
Compiling with -mieee is not without a considerable cost.
--mj
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: g77 problems
1998-09-01 10:56 Dr P. Caleb Dhanasekaran
1998-09-02 1:48 ` Michal Jaegermann
@ 1998-09-02 4:23 ` Wes Bauske
1998-09-02 15:34 ` David Alan Gilbert
1 sibling, 1 reply; 15+ messages in thread
From: Wes Bauske @ 1998-09-02 4:23 UTC (permalink / raw)
To: axp-list
Dr P. Caleb Dhanasekaran wrote:
>
> Hi all`,
>
> I have installed RedHat 5.1 on my Alpha UX4,600Mhz PC. I have
> upgraded the compilers egcs.1.0.3 and g77-1.0.3 downloading the
> rpm files.
>
> My FORTRAN program works fine using fort77 but fails due to
> Floating Exception when I use g77 compiler. I have been debugging
> this program and when I insert a write(*,*) statement
> in one of the subroutines the programs executes fine. I used
> xxgdb to debug the program and it showed problem in cosine function
> (libm).
>
> Could anybody tell me what causes this type of Floating Exception
> problem using g77 on Alpha? Is there any fix to this? This program works
> fine on IBM Aix 4.1, HP, Silcon Graphics systems, and g77 on Intel
> platform.`
Alpha's are VERY strict with respect to arguments of FP operations.
You cannot use un-normalized numbers! One normally gets those
by indexing in an array incorrectly or used an un-initialized
stack variable. If you run your code under gdb, and look at the
arguments to the FP operation, you most likely will find a
non-FP number. Now, if you REALLY intended to do this, you can
use the flag '-mieee', I believe, to have SW trap and handle these
sorts of problems. No guarantees that it will work but others
have reported success with it.
The correct thing to do is to fix the code though. I have never
seen code nor written code where it was intended to cause this
sort of argument to be used. (I've done FORTRAN for a long
time)
One other thing. There is an off chance you hit an edge problem
in the cos() function but I thought the safe code was being
used in RH5.1. Some older libm.a routines had edge problems.
Wes
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: g77 problems
1998-09-02 4:23 ` Wes Bauske
@ 1998-09-02 15:34 ` David Alan Gilbert
1998-09-03 6:23 ` Wes Bauske
0 siblings, 1 reply; 15+ messages in thread
From: David Alan Gilbert @ 1998-09-02 15:34 UTC (permalink / raw)
To: axp-list
Wes Bauske wrote:
> Alpha's are VERY strict with respect to arguments of FP operations.
> You cannot use un-normalized numbers! One normally gets those
> by indexing in an array incorrectly or used an un-initialized
> stack variable. If you run your code under gdb, and look at the
> arguments to the FP operation, you most likely will find a
> non-FP number. Now, if you REALLY intended to do this, you can
> use the flag '-mieee', I believe, to have SW trap and handle these
> sorts of problems. No guarantees that it will work but others
> have reported success with it.
What happens with numbers which are so small/large that they can not
be normalised (sorry I can't remember the term); as far as I understood
they were valid numbers, but perhaps I'm confused.
Dave
--
----------------------------------------------------------------------
- Dr. David Alan Gilbert - WARNING! This is a beta release .signature-
- Work: dg @ cogency.co.uk - +44-(0)161-428-9444 -
- Home: gro.gilbert @ treblig.org - -
----------------------------------------------------------------------
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: g77 problems
1998-09-02 15:34 ` David Alan Gilbert
@ 1998-09-03 6:23 ` Wes Bauske
1998-09-04 0:41 ` Richard Henderson
0 siblings, 1 reply; 15+ messages in thread
From: Wes Bauske @ 1998-09-03 6:23 UTC (permalink / raw)
To: axp-list
David Alan Gilbert wrote:
>
> Wes Bauske wrote:
>
> > Alpha's are VERY strict with respect to arguments of FP operations.
> > You cannot use un-normalized numbers! One normally gets those
> > by indexing in an array incorrectly or used an un-initialized
> > stack variable. If you run your code under gdb, and look at the
> > arguments to the FP operation, you most likely will find a
> > non-FP number. Now, if you REALLY intended to do this, you can
> > use the flag '-mieee', I believe, to have SW trap and handle these
> > sorts of problems. No guarantees that it will work but others
> > have reported success with it.
>
> What happens with numbers which are so small/large that they can not
> be normalised (sorry I can't remember the term); as far as I understood
> they were valid numbers, but perhaps I'm confused.
>
Underflows are set to zero according to the architecture
stuff I read. Don't know about overflows. I have an
algorithm that can underflow and is working correctly but
haven't tried it on an Alpha so I can't say it really works
from experience. You'd still have valid inputs to the FP
op though. Most problems I see in code are trying to feed
junk into a FP op.
If a number cannot be represented normalized, you're in
trouble because IEEE FP format has an implied 1 bit in the
mantissa. I use 8 byte floats if I need a larger range of
numbers. Most stuff I do works with 4 byte floats though.
(Digital signal processing)
Wes
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: g77 problems
@ 1998-09-03 21:08 Greg Lindahl
0 siblings, 0 replies; 15+ messages in thread
From: Greg Lindahl @ 1998-09-03 21:08 UTC (permalink / raw)
To: axp-list
> Underflows are set to zero according to the architecture
> stuff I read.
However, if you're reading garbage memory, you might get a denorm.
This is what we were suggesting in this case.
> If a number cannot be represented normalized, you're in
> trouble because IEEE FP format has an implied 1 bit in the
> mantissa.
If a number can't be normalized, it is expressed by a denorm, which
does not have an implied 1 bit. The alpha neither generates nor
consumes denorms unless you specify the -mieee flag and pay a big
penalty.
-- g
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: g77 problems
1998-09-03 6:23 ` Wes Bauske
@ 1998-09-04 0:41 ` Richard Henderson
1998-09-05 19:57 ` Wes Bauske
0 siblings, 1 reply; 15+ messages in thread
From: Richard Henderson @ 1998-09-04 0:41 UTC (permalink / raw)
To: axp-list
On Thu, Sep 03, 1998 at 06:23:55AM +0000, Wes Bauske wrote:
> > What happens with numbers which are so small/large that they can not
> > be normalised (sorry I can't remember the term); as far as I understood
> > they were valid numbers, but perhaps I'm confused.
>
> Underflows are set to zero according to the architecture
It's called a "denormal".
Underflows _may_ be set to zero. In that there is an fpcr bit that
one may set to enable this. If it isn't, the processor traps for
software emulation of the denormal, which of course looses if you
havn't compiled with -mieee.
> If a number cannot be represented normalized, you're in
> trouble because IEEE FP format has an implied 1 bit in the
> mantissa.
No, exponent == 0 and mantessa != 0 is a denormal, and does not
have the implied 1 bit.
r~
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: g77 problems
1998-09-04 0:41 ` Richard Henderson
@ 1998-09-05 19:57 ` Wes Bauske
1998-09-05 20:50 ` Richard Henderson
0 siblings, 1 reply; 15+ messages in thread
From: Wes Bauske @ 1998-09-05 19:57 UTC (permalink / raw)
To: Richard Henderson; +Cc: axp-list@redhat.com
Richard Henderson wrote:
>
> On Thu, Sep 03, 1998 at 06:23:55AM +0000, Wes Bauske wrote:
> > > What happens with numbers which are so small/large that they can not
> > > be normalised (sorry I can't remember the term); as far as I understood
> > > they were valid numbers, but perhaps I'm confused.
> >
> > Underflows are set to zero according to the architecture
>
> It's called a "denormal".
>
> Underflows _may_ be set to zero. In that there is an fpcr bit that
> one may set to enable this. If it isn't, the processor traps for
> software emulation of the denormal, which of course looses if you
> havn't compiled with -mieee.
>
Humm. What is the default mode for g77/gcc for undeflow,
terminate or zero? Thought Alphas cannot generate denormalized
outputs, at least with HW.
> > If a number cannot be represented normalized, you're in
> > trouble because IEEE FP format has an implied 1 bit in the
> > mantissa.
>
> No, exponent == 0 and mantessa != 0 is a denormal, and does not
> have the implied 1 bit.
Yeah. That's an edge case. I usually call those things
integers!! Means you need to increase your bits.
If you're already at 64bit, you're in for major headaches.
While '-mieee' handles these things, it is much more
likely a code bug than a useful FP number. All the
complaining about povray was due to bad code, not really
a need for '-mieee' to get the 'right' answer. All
'-mieee' usually does is mask bugs from what I've
seen in my own code/other's code, and heard on this
list.
I would not recommend that flag in 99.99% of the
cases where FP exceptions are found in code. There
are always cases where it may be needed, but by far
it should not be used. Course I also care how fast
the code runs so practically nothing I do could
tolerate the trap stuff it inserts in the assembly
code. I also like getting the 'right' answer so
hiding un-initialized variables and screwed up
indexing is not helpful from my point of view...
Wes
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: g77 problems
1998-09-05 19:57 ` Wes Bauske
@ 1998-09-05 20:50 ` Richard Henderson
1998-09-06 20:22 ` Dave Gilbert
1998-09-06 20:28 ` Richard Hadsell
0 siblings, 2 replies; 15+ messages in thread
From: Richard Henderson @ 1998-09-05 20:50 UTC (permalink / raw)
To: Wes Bauske, Richard Henderson; +Cc: axp-list@redhat.com
On Sat, Sep 05, 1998 at 07:57:11PM +0000, Wes Bauske wrote:
> Humm. What is the default mode for g77/gcc for undeflow, terminate or zero?
The default is trap, I believe.
> Thought Alphas cannot generate denormalized outputs, at least with HW.
This is true.
> I also like getting the 'right' answer so
> hiding un-initialized variables and screwed up
> indexing is not helpful from my point of view...
Yes indeed. It is amazing how many people so want to bury
their heads in the sand over this.
r~
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: g77 problems
1998-09-05 20:50 ` Richard Henderson
@ 1998-09-06 20:22 ` Dave Gilbert
1998-09-06 21:05 ` Wes Bauske
1998-09-06 22:41 ` Richard Henderson
1998-09-06 20:28 ` Richard Hadsell
1 sibling, 2 replies; 15+ messages in thread
From: Dave Gilbert @ 1998-09-06 20:22 UTC (permalink / raw)
To: Richard Henderson; +Cc: Wes Bauske, axp-list@redhat.com
On Sat, 5 Sep 1998, Richard Henderson wrote:
> > Thought Alphas cannot generate denormalized outputs, at least with HW.
>
> This is true.
Is it valid code to use another architecture to generate some floating
point data, save it in a binary file and then load it back on an Alpha?
If so, would it be valid for that file to contain denormalised data
values?
Dave
--------------------------------------------------------------------
/ Dr. David Alan Gilbert | Running Linux on Alpha(LX) | Happy \
\ gro.gilbert @ treblig.org | & ARM(EBSA285,old Arc) | In Hex /
\____________________________|___ http://www.treblig.demon.co.uk __/
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: g77 problems
1998-09-05 20:50 ` Richard Henderson
1998-09-06 20:22 ` Dave Gilbert
@ 1998-09-06 20:28 ` Richard Hadsell
1998-09-06 20:57 ` Wes Bauske
1 sibling, 1 reply; 15+ messages in thread
From: Richard Hadsell @ 1998-09-06 20:28 UTC (permalink / raw)
To: Richard Henderson; +Cc: Wes Bauske, axp-list@redhat.com
Richard Henderson wrote:
>
> On Sat, Sep 05, 1998 at 07:57:11PM +0000, Wes Bauske wrote:
> > Humm. What is the default mode for g77/gcc for undeflow, terminate or zero?
>
> The default is trap, I believe.
>
> > Thought Alphas cannot generate denormalized outputs, at least with HW.
>
> This is true.
>
> > I also like getting the 'right' answer so
> > hiding un-initialized variables and screwed up
> > indexing is not helpful from my point of view...
>
> Yes indeed. It is amazing how many people so want to bury
> their heads in the sand over this.
It's actually quite easy to generate a denormalized number using exp().
When the argument is barely more negative than required to exceed the
representation limits in the result, the library function gives you a
denormalized number. Then your code has to be compiled with -mieee, or
it traps when you try to use the result.
--
Dick Hadsell 914-381-8400 x5446 Fax: 914-381-9790
Reply-to: hadsell@blueskystudios.com
Blue Sky | VIFX http://www.bluesky-vifx.com
1 South Road, Harrison, NY 10528
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: g77 problems
1998-09-06 20:28 ` Richard Hadsell
@ 1998-09-06 20:57 ` Wes Bauske
0 siblings, 0 replies; 15+ messages in thread
From: Wes Bauske @ 1998-09-06 20:57 UTC (permalink / raw)
To: axp-list@redhat.com
Richard Hadsell wrote:
>
> Richard Henderson wrote:
> >
> > On Sat, Sep 05, 1998 at 07:57:11PM +0000, Wes Bauske wrote:
> > > Humm. What is the default mode for g77/gcc for undeflow, terminate or zero?
> >
> > The default is trap, I believe.
> >
> > > Thought Alphas cannot generate denormalized outputs, at least with HW.
> >
> > This is true.
> >
> > > I also like getting the 'right' answer so
> > > hiding un-initialized variables and screwed up
> > > indexing is not helpful from my point of view...
> >
> > Yes indeed. It is amazing how many people so want to bury
> > their heads in the sand over this.
>
> It's actually quite easy to generate a denormalized number using exp().
> When the argument is barely more negative than required to exceed the
> representation limits in the result, the library function gives you a
> denormalized number. Then your code has to be compiled with -mieee, or
> it traps when you try to use the result.
>
Actually, wouldn't the exp() function have to be '-mieee' then,
not just your application? '-mieee' actually adds asm
instructions/directives to your code to stop pipelining to handle
exactly the instruction that runs into trouble so if
exp() returns them, it has to have those extra bits.
I'm not saying you can't think of a way to generate them
though. I'm saying most applications don't use numbers
in that range and if they do, you should increase your
FP word size, if possible. When your app generates them,
you should be looking at why it's doing that. The only
case I've seen that's useful is underflow in a recursive
algorithm and setting the result to zero is the 'right'
thing to do for that sort of condition in the alogrithms
I've worked with.
Wes
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: g77 problems
1998-09-06 20:22 ` Dave Gilbert
@ 1998-09-06 21:05 ` Wes Bauske
1998-09-06 22:41 ` Richard Henderson
1 sibling, 0 replies; 15+ messages in thread
From: Wes Bauske @ 1998-09-06 21:05 UTC (permalink / raw)
To: axp-list@redhat.com
Dave Gilbert wrote:
>
> On Sat, 5 Sep 1998, Richard Henderson wrote:
>
> > > Thought Alphas cannot generate denormalized outputs, at least with HW.
> >
> > This is true.
>
> Is it valid code to use another architecture to generate some floating
> point data, save it in a binary file and then load it back on an Alpha?
> If so, would it be valid for that file to contain denormalised data
> values?
>
Sounds plausible but if I have algorithms that
might do that, I always look for a switch to set
underflows to zero, which would avoid the problem.
Ask yourself under what sort of conditions would a
de-normalized number be more useful to an algorithm
than just forcing it to zero??
Also, how would the answer change if you increased your
FP precision vs using de-normalized numbers or zeros?
Wes
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: g77 problems
1998-09-06 20:22 ` Dave Gilbert
1998-09-06 21:05 ` Wes Bauske
@ 1998-09-06 22:41 ` Richard Henderson
1 sibling, 0 replies; 15+ messages in thread
From: Richard Henderson @ 1998-09-06 22:41 UTC (permalink / raw)
To: Dave Gilbert, Richard Henderson; +Cc: Wes Bauske, axp-list@redhat.com
On Sun, Sep 06, 1998 at 09:22:17PM +0100, Dave Gilbert wrote:
> Is it valid code to use another architecture to generate some floating
> point data, save it in a binary file and then load it back on an Alpha?
Sure, as long as you are careful about endianness.
> If so, would it be valid for that file to contain denormalised data
> values?
That entirely depends on the domain, now doesn't it.
r~
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~1998-09-06 22:41 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-09-02 1:27 g77 problems Greg Lindahl
-- strict thread matches above, loose matches on Subject: below --
1998-09-03 21:08 Greg Lindahl
1998-09-01 10:56 Dr P. Caleb Dhanasekaran
1998-09-02 1:48 ` Michal Jaegermann
1998-09-02 4:23 ` Wes Bauske
1998-09-02 15:34 ` David Alan Gilbert
1998-09-03 6:23 ` Wes Bauske
1998-09-04 0:41 ` Richard Henderson
1998-09-05 19:57 ` Wes Bauske
1998-09-05 20:50 ` Richard Henderson
1998-09-06 20:22 ` Dave Gilbert
1998-09-06 21:05 ` Wes Bauske
1998-09-06 22:41 ` Richard Henderson
1998-09-06 20:28 ` Richard Hadsell
1998-09-06 20:57 ` Wes Bauske
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox