Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* What takes care about optimization options ?
@ 1999-03-08 12:12 Andrei A. Dergatchev
  1999-03-08 19:10 ` Joachim Wesner
  0 siblings, 1 reply; 10+ messages in thread
From: Andrei A. Dergatchev @ 1999-03-08 12:12 UTC (permalink / raw)
  To: axp-list

Hi,

I found a rather funny bug and I'm not sure whom
to report. I have a package written in Fortran 77
and I found that compiling with -O5 always causes
FPE during run-time, while compilation of the same
package with -g or -O doesn't. There are some
variables which are used depending on options,
otherwise they're 0.0. They're provided within a package
as subroutines' parameters. It seems -O5 option does
something wrong regarding subnormality issue as
a program generates FPE printing variable which must
be exactly 0.0.

My question is is it g77, gcc(egcs) or linker related ?

Rgds,

Andrei


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: What takes care about optimization options ?
  1999-03-08 12:12 What takes care about optimization options ? Andrei A. Dergatchev
@ 1999-03-08 19:10 ` Joachim Wesner
  1999-03-08 19:32   ` Greg Lindahl
  1999-03-08 19:41   ` Andrei A. Dergatchev
  0 siblings, 2 replies; 10+ messages in thread
From: Joachim Wesner @ 1999-03-08 19:10 UTC (permalink / raw)
  To: axp-list

Andrei A. Dergatchev wrote:
> 
> Hi,
> 
> I found a rather funny bug and I'm not sure whom
> to report. I have a package written in Fortran 77
> and I found that compiling with -O5 always causes
> FPE during run-time, while compilation of the same
> package with -g or -O doesn't. There are some
> variables which are used depending on options,
> otherwise they're 0.0. They're provided within a package
> as subroutines' parameters. It seems -O5 option does
> something wrong regarding subnormality issue as
> a program generates FPE printing variable which must
> be exactly 0.0.
> 
> My question is is it g77, gcc(egcs) or linker related ?
> 

Can you give an example of the code ?? What compiler (version)exactly do
you use ? Some high optim. levels can cause code reordering that will no
be what you want/need ! Did you check the machine code generated ??
Which math lib ?


Joachim


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: What takes care about optimization options ?
  1999-03-08 19:10 ` Joachim Wesner
@ 1999-03-08 19:32   ` Greg Lindahl
  1999-03-08 19:49     ` Andrei A. Dergatchev
  1999-03-08 19:41   ` Andrei A. Dergatchev
  1 sibling, 1 reply; 10+ messages in thread
From: Greg Lindahl @ 1999-03-08 19:32 UTC (permalink / raw)
  To: axp-list

> It seems -O5 option does
> something wrong regarding subnormality issue as
> a program generates FPE printing variable which must
> be exactly 0.0.

It's worth poiting out that the g77 I/O libraries can't print out the
value of a denorm, they get a FPE. They would probably work (and not
get much slower) if compiled with -mieee.

As for your problem, remember that g77 + libffm or libcpml will never
generate a denorm. So if you see one, there's a serious bug. If you
are using libm, on the other hand, denorms can creep in from the math
library. The best fix for you is probably to use libcpml, since you
don't seem to want those denorms. Obviously there are a lot of
particular issues with your code...

-- g


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: What takes care about optimization options ?
  1999-03-08 19:10 ` Joachim Wesner
  1999-03-08 19:32   ` Greg Lindahl
@ 1999-03-08 19:41   ` Andrei A. Dergatchev
  1999-03-08 19:52     ` Greg Lindahl
  1 sibling, 1 reply; 10+ messages in thread
From: Andrei A. Dergatchev @ 1999-03-08 19:41 UTC (permalink / raw)
  To: axp-list

Hi,

Thanks for your response.

[snip]

> Can you give an example of the code ?? What compiler (version)exactly do
> you use ?

g77 -v:
Reading specs from /usr/lib/gcc-lib/alpha-redhat-linux/egcs-2.90.29/specs
gcc version egcs-2.90.29 980515 (egcs-1.0.3 release)

> Some high optim. levels can cause code reordering that will no
> be what you want/need !

In this case I'd prefer to be able to save my debugging time :-)
A couple of hours only to find out that -O5 is responsible :-(
Compiling the same code with -O makes my packages run
happily.

I guess that reordering&real 0 combo produces my FPE,
that's why I'm sure it's a bug.

> Did you check the machine code generated ??

Not yet, I suppose someone working with the subj can do it
more efficiently ;-)

> Which math lib ?

With -lm I found that it doesn't matter whether I use -mieee
or not. -lffm gives the same. Haven't tried cmpl yet.

>
> Joachim
>

I can put a whole package - 5 *.f files (~100K compressed) - on
my ftp-site if anyone is interested.

Regards,

Andrei


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: What takes care about optimization options ?
  1999-03-08 19:32   ` Greg Lindahl
@ 1999-03-08 19:49     ` Andrei A. Dergatchev
  1999-03-08 20:01       ` Greg Lindahl
  0 siblings, 1 reply; 10+ messages in thread
From: Andrei A. Dergatchev @ 1999-03-08 19:49 UTC (permalink / raw)
  To: axp-list

> It's worth poiting out that the g77 I/O libraries can't print out the
> value of a denorm, they get a FPE. They would probably work (and not
> get much slower) if compiled with -mieee.

Well, I specially tried a "-mieee" option and it doesn't have any effect
if -O5 is used.

> As for your problem, remember that g77 + libffm or libcpml will never
> generate a denorm.

Somehow, using libffm I've got the same FPE at exactly the same
place.

It seems rather strange to me, might it be that I'm compiling my project
in a wrong way ?? I use g77 -c -{g,O,O5} filename{1-5}.f and link
g77 -{g,O,O5} (all 5 *.o) -mieee -l{m/ffm}.

> So if you see one, there's a serious bug. If you
> are using libm, on the other hand, denorms can creep in from the math
> library. The best fix for you is probably to use libcpml, since you
> don't seem to want those denorms. Obviously there are a lot of
> particular issues with your code...
>
> -- g
>

Regards,

Andrei


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: What takes care about optimization options ?
  1999-03-08 19:41   ` Andrei A. Dergatchev
@ 1999-03-08 19:52     ` Greg Lindahl
  1999-03-08 21:45       ` Andrei A. Dergatchev
  0 siblings, 1 reply; 10+ messages in thread
From: Greg Lindahl @ 1999-03-08 19:52 UTC (permalink / raw)
  To: axp-list

> I guess that reordering&real 0 combo produces my FPE,
> that's why I'm sure it's a bug.

You actually can't be sure. A program which is not standard-conforming
might not generate the FPE until high optimization. For example, if
you have aliased arguments (illegal), this might not generate the
wrong answer until high optimization levels.

> With -lm I found that it doesn't matter whether I use -mieee
> or not. -lffm gives the same. Haven't tried cmpl yet.

This rules out my earlier theory...

With -mieee you should be able to get a stack trace out of gdb.
Any luck with that?

-- g


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: What takes care about optimization options ?
  1999-03-08 19:49     ` Andrei A. Dergatchev
@ 1999-03-08 20:01       ` Greg Lindahl
  0 siblings, 0 replies; 10+ messages in thread
From: Greg Lindahl @ 1999-03-08 20:01 UTC (permalink / raw)
  To: axp-list

> > It's worth poiting out that the g77 I/O libraries can't print out the
> > value of a denorm, they get a FPE. They would probably work (and not
> > get much slower) if compiled with -mieee.
> 
> Well, I specially tried a "-mieee" option and it doesn't have any effect
> if -O5 is used.

I mean "compile the g77 I/O libraries with -mieee". Then they would
successfully print those denorms and your code would still be wrong ;-)

-- g


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: What takes care about optimization options ?
  1999-03-08 19:52     ` Greg Lindahl
@ 1999-03-08 21:45       ` Andrei A. Dergatchev
  1999-03-09 13:50         ` Greg Lindahl
  1999-03-09 13:52         ` Johannes G.D. Hausmann
  0 siblings, 2 replies; 10+ messages in thread
From: Andrei A. Dergatchev @ 1999-03-08 21:45 UTC (permalink / raw)
  To: axp-list

Hi,


> > I guess that reordering&real 0 combo produces my FPE,
> > that's why I'm sure it's a bug.
>
> You actually can't be sure. A program which is not standard-conforming
> might not generate the FPE until high optimization. For example, if
> you have aliased arguments (illegal), this might not generate the
> wrong answer until high optimization levels.

I've just tried a set of different options to compile with and I finally
got as granted that compilation with any optimization setting
higher than O1 gives me FPE at the same place :-(

> > With -lm I found that it doesn't matter whether I use -mieee
> > or not. -lffm gives the same. Haven't tried cmpl yet.
>
> This rules out my earlier theory...
>
> With -mieee you should be able to get a stack trace out of gdb.
> Any luck with that?

Yeah, I can see a list ...->fio->wrt_F-><handler>->sig but what
I can do with that if higher optimization decided to touch my lovely
variable wavelen=0.0 given as subroutine parameter and put
a denorm instead ???

>
> -- g
>

Regards,

Andrei


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: What takes care about optimization options ?
  1999-03-08 21:45       ` Andrei A. Dergatchev
@ 1999-03-09 13:50         ` Greg Lindahl
  1999-03-09 13:52         ` Johannes G.D. Hausmann
  1 sibling, 0 replies; 10+ messages in thread
From: Greg Lindahl @ 1999-03-09 13:50 UTC (permalink / raw)
  To: axp-list

> > With -mieee you should be able to get a stack trace out of gdb.
> > Any luck with that?
> 
> Yeah, I can see a list ...->fio->wrt_F-><handler>->sig

That just means that it died in the write statement.

Now move the write statement around to find out exactly where the
denorm appears. Cut your source code down to a minimal example and
submit a bug report, if your program is standard-conforming. This
isn't that hard of a process to go through...

-- g


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: What takes care about optimization options ?
  1999-03-08 21:45       ` Andrei A. Dergatchev
  1999-03-09 13:50         ` Greg Lindahl
@ 1999-03-09 13:52         ` Johannes G.D. Hausmann
  1 sibling, 0 replies; 10+ messages in thread
From: Johannes G.D. Hausmann @ 1999-03-09 13:52 UTC (permalink / raw)
  To: axp-list

Hi,

> I've just tried a set of different options to compile with and I finally
> got as granted that compilation with any optimization setting
> higher than O1 gives me FPE at the same place :-(
> 

IIRC, this happened with the LAPACK/BLAS stuff I worked on a while ago
because some of the "expensive-optimizations" didn't work together.
Did you try using -fno-expensive-optimizations"?

Jo
-- 
-----------------------------------------
Johannes Hausmann
Carl von Ossietzky Universitaet Oldenburg
FB Physik -- AG Komplexe Systeme

EMail : joe@neuro.uni-oldenburg.de
-----------------------------------------


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~1999-03-09 13:57 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-03-08 12:12 What takes care about optimization options ? Andrei A. Dergatchev
1999-03-08 19:10 ` Joachim Wesner
1999-03-08 19:32   ` Greg Lindahl
1999-03-08 19:49     ` Andrei A. Dergatchev
1999-03-08 20:01       ` Greg Lindahl
1999-03-08 19:41   ` Andrei A. Dergatchev
1999-03-08 19:52     ` Greg Lindahl
1999-03-08 21:45       ` Andrei A. Dergatchev
1999-03-09 13:50         ` Greg Lindahl
1999-03-09 13:52         ` Johannes G.D. Hausmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox