[XCSSA] gcc 2.9.5 vs gcc 3.4.3

xcssa@xcssa.org xcssa@xcssa.org
Fri, 02 Feb 2007 15:56:48 -0600


I'm seeing a very strange problem with gcc 3.4.3 which is the latest 
version we have (provided by Sun) on our Solaris x86 systems.  It is 
also what we use on our slightly outdated Red Hat Enterprise machine I 
use for porting our program to linux.

When our program is compiled with old gcc 2.9.5, it runs 3 times (!!!) 
faster (for a particular test case) than when it is compiled with 
3.4.3.  Identical source code, identical Makefile (using -O2 
optimization, roughly same results with -O3).  This test case involves 
gazillions of floating point calculations and runs 6-20 minutes with 
minimal I/O.

Some background on our program: it combines C++ and Fortran and little 
C.  Roughly speaking, C++ calls Fortran (to do the real work) and then 
Fortran often calls back into C++ (to get parameters, etc.)  Most of the 
work done involves double precision floating point calculations done in 
Fortran.  The g77 compiler is used for the Fortran (not g95 or 
gfortran).  The program is very large and complicated (representing 
decades of scientific research and programming).

I see the same slowdown with the later 3.4.3 compiler suite on both 
linux (Red Hat) and Solaris x86.  (3.4.2 works the same as 3.4.3 BTW.)

One thing I've tried has been the -malign-double option.  Using 
-malign-double makes performance even worse on 3.4.3.  Strangely, using 
-mno-align-double makes it worse also.  The default alignment must be 
some happy medium.  But I haven't yet found any switches to make 3.4.3 
create a program that works significantly better than 3 times slower 
than when the 2.9.5 compilers were used.

Any ideas?  What was the big difference (assuming there was one) between 
the gcc 2.x compilers and the gcc 3.x compilers?  Was there some 
particular change to either the handling of floating point, to the 
handling of subroutine calls, or to Fortran in general?

I'm not the first person to see this kind of slowdown with the 3.x 
compilers.  But supposedly the code generation problems have now been 
fixed.  As far as the 4.x compilers, I haven't tested them yet, our 
sysadmin hasn't set them up yet.

Charles