public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* egcs 1.0.1 and fortran optimization
@ 1998-01-19  2:45 Vladimir Eltsov
  1998-01-20  9:08 ` Jeffrey A Law
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Vladimir Eltsov @ 1998-01-19  2:45 UTC (permalink / raw)
  To: egcs

Hello,

I successfully built and installed egcs-1.0.1 on Linux RedHat-5.0 system
in the fully standard config. Then I compiled my simulation programs: one
in fortran, other in c++ and compared execution times to variants compiled
with g++/g77 2.7.2.3.f.1. Compilation options were '-O3 -m486
-fomit-frame-pointer -ffast-math' for gcc and '-O9 -mpentiumpro
-fomit-frame-pointer -ffast-math' for egcc in both cases (I have
PentiumII). egcs compiler produces correct code, as for execution time I
obtained: C++ program run 42% faster when compiled with egcs (GREAT!
thanks!), but fortran program run 20% _slower_. 

Am I missing some compilation option(s) for egcs g77 compiler or is it
a known problem? (I remember that when I tried one of the first pg77
snapshots situation was the same with several different fortran programs).

Vladimir Eltsov
ve@boojum.hut.fi

PS: I am not on the list, so please CC replies to me.


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

* Re: egcs 1.0.1 and fortran optimization
  1998-01-19  2:45 egcs 1.0.1 and fortran optimization Vladimir Eltsov
@ 1998-01-20  9:08 ` Jeffrey A Law
  1998-01-20 14:54 ` Toon Moene
  1998-01-20 14:54 ` Dave Love
  2 siblings, 0 replies; 6+ messages in thread
From: Jeffrey A Law @ 1998-01-20  9:08 UTC (permalink / raw)
  To: Vladimir Eltsov; +Cc: egcs

  In message < Pine.LNX.3.96.980119122740.24675A-100000@slon.hut.fi >you write:
  > PentiumII). egcs compiler produces correct code, as for execution time I
  > obtained: C++ program run 42% faster when compiled with egcs (GREAT!
  > thanks!), but fortran program run 20% _slower_. 
I suspect this is the alignment of doubles problem.  

jeff

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

* Re: egcs 1.0.1 and fortran optimization
  1998-01-19  2:45 egcs 1.0.1 and fortran optimization Vladimir Eltsov
  1998-01-20  9:08 ` Jeffrey A Law
@ 1998-01-20 14:54 ` Toon Moene
  1998-01-21  9:54   ` Vladimir Eltsov
  1998-01-20 14:54 ` Dave Love
  2 siblings, 1 reply; 6+ messages in thread
From: Toon Moene @ 1998-01-20 14:54 UTC (permalink / raw)
  To: Vladimir Eltsov; +Cc: egcs

>  I successfully built and installed egcs-1.0.1 on Linux
>  RedHat-5.0 system in the fully standard config. Then I
>  compiled my simulation programs: one in fortran, other
>  in c++ and compared execution times to variants compiled
>  with g++/g77 2.7.2.3.f.1. Compilation options were '-O3
>  -m486 -fomit-frame-pointer -ffast-math' for gcc and '-O9
>  -mpentiumpro -fomit-frame-pointer -ffast-math' for egcc
>  in both cases (I have PentiumII). egcs compiler produces
>  correct code, as for execution time I obtained: C++
>  program run 42% faster when compiled with egcs (GREAT!
>  thanks!), but fortran program run 20% _slower_.

Is most of the data in the Fortran program declared DOUBLE PRECISION ?
The basic problem with the Pentium, Pentium Pro and Pentium II is  
that you have to be *absolutely* sure that all DOUBLE PRECISION data  
is aligned on 8-byte boundaries for performance, period.  In egcs  
(and gcc-2.[78].x) this is partly accomplished using the (ix86  
specific) option -malign-double.  Without this option, it's  
anybody's guess whether you get *any* performance out of your code  
(I've seen differences of a factor 3 on PPro's).  If most of your  
data is scalar variables or arrays with less than 4000 elements,  
-fno-automatic might also help.

Another thing that might be hampering your code is the fact that  
strength reduction is much more voracious of registers for array  
elements than it was in gcc-2.7.2.3.f.1, which - given the dearth of  
integer registers on a ix86 - is a bad sign.  Efforts are under way  
to remedy this.

HTH,
Toon.

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

* Re: egcs 1.0.1 and fortran optimization
  1998-01-19  2:45 egcs 1.0.1 and fortran optimization Vladimir Eltsov
  1998-01-20  9:08 ` Jeffrey A Law
  1998-01-20 14:54 ` Toon Moene
@ 1998-01-20 14:54 ` Dave Love
  1998-01-22  1:45   ` Richard Henderson
  2 siblings, 1 reply; 6+ messages in thread
From: Dave Love @ 1998-01-20 14:54 UTC (permalink / raw)
  To: Vladimir Eltsov; +Cc: egcs

>>>>> "Vladimir" == Vladimir Eltsov <ve@boojum.hut.fi> writes:

 Vladimir> Am I missing some compilation option(s) for egcs g77
 Vladimir> compiler

-malign-double and -fforce-addr (see the manual).  Maybe also
-funroll-loops.  If you're using double precision what you see may be
affected by random non-alignment of the doubles (see the manual
again).  I haven't seen slowdown between gcc 2.7 fortran and egcs on a
pentium (586).

I've no idea whether -mpentiumpro is appropriate for a pentium II --
can anyone say for future reference?

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

* Re: egcs 1.0.1 and fortran optimization
  1998-01-20 14:54 ` Toon Moene
@ 1998-01-21  9:54   ` Vladimir Eltsov
  0 siblings, 0 replies; 6+ messages in thread
From: Vladimir Eltsov @ 1998-01-21  9:54 UTC (permalink / raw)
  To: egcs

Thank you for all who replied to my question why egcs f77 compiler
produces slower code on pentiumII than gf77 2.7.2.3.f.1 when c++ compiler
produces much faster code with the same set of compiler options. The most 
imperative answer was to always use -malign-double for double precision
fortran programs. So I want to post my experience which contradicts this
conclusion. After playing with various optimization options I found the
best result for one paticular fortran program which solves system of
ODE's using the standard rksuit package (from www.netlib.org). The best
options for egcs are
-O9 -mcpu=pentiumpro -fomit-frame-pointer -ffast-math 
 -funroll-loops -fforce-mem
while for gnu f77 
-O3 -m486 -fomit-frame-pointer -ffast-math -malign-double -funroll-loops

With these options egcs compiled program runs 2.5% faster than gf77
compiled. However, adding -malign-double to egcs options slows down the
resulting program by 17% (-fno-automatic and -fforce-addr also have
negative effects, others mentioned in the g77 manual have no effect). All
real variables in the program are DP and all common blocks are arranged
form longest to shortest.

Best regards,

   Vladimir Eltsov


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

* Re: egcs 1.0.1 and fortran optimization
  1998-01-20 14:54 ` Dave Love
@ 1998-01-22  1:45   ` Richard Henderson
  0 siblings, 0 replies; 6+ messages in thread
From: Richard Henderson @ 1998-01-22  1:45 UTC (permalink / raw)
  To: Dave Love; +Cc: Vladimir Eltsov, egcs

On Tue, Jan 20, 1998 at 10:49:05PM +0000, Dave Love wrote:
> I've no idea whether -mpentiumpro is appropriate for a pentium II --
> can anyone say for future reference?

Yes, the PII contains the PPro core, without some of the extra
on-module cache.


r~

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

end of thread, other threads:[~1998-01-22  1:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-01-19  2:45 egcs 1.0.1 and fortran optimization Vladimir Eltsov
1998-01-20  9:08 ` Jeffrey A Law
1998-01-20 14:54 ` Toon Moene
1998-01-21  9:54   ` Vladimir Eltsov
1998-01-20 14:54 ` Dave Love
1998-01-22  1:45   ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).