------- Comment #6 from burnus at gcc dot gnu dot org  2006-12-01 00:04 -------
> You misunderstood me.
> const int NODES = 2500;
> float f[NODES];
> causes a VLA to happen because in C, NODES is not a constant expression.
> You can do instead:
> #define NODES 2500
> to get the non VLA.

I should really read a good C book.

gcc: 0m1.390s
icc: 0m2.439s

Thus converting such VLA arrays into normal arrays seems to be indeed what icc
does -- and GCC should do!?

The next question is of cause whether this has anything to do with my Fortran
slowness. Using oprofile, I found with for gfortran in gas_dyn.f90:
150879 51.8663 :          CS(:NODES) = SQRT(CGAMMA*PRES(:NODES)/DENS(:NODES))

In any case, for the following program I get:
gfortran -O4 -msse3 -ftree-vectorize -funroll-loops -march=opteron -ffast-math
 0m7.281s
ifort -O3 -xW
 0m2.633s

program main
  implicit none
  integer, parameter :: NODES = 25000
  real :: CGAMMA
  real :: DENS(NODES), CS(NODES), PRES(NODES)
  integer :: i
  CGAMMA = sqrt(2.0)
  DENS = sqrt(3.0)
  PRES = sin(0.25)
  CGAMMA = 3.0
  do i=1,20000
     call EOS(NODES,CGAMMA, DENS,PRES,CS)
     CGAMMA = CGAMMA + CS(1)
  end do
  print *,CS(1)
contains
       SUBROUTINE EOS(NODES, CGAMMA, DENS, PRES, CS)
      IMPLICIT NONE
      integer :: i
      INTEGER NODES
      REAL CGAMMA
      REAL, DIMENSION(NODES) :: DENS, PRES, CS
      do i = 1,NODES
        CS(i) = sqrt(cgamma*PRES(i)/Dens(i))
      end do
end subroutine
end program main


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30032

Reply via email to