Path: utzoo!attcan!uunet!husc6!bloom-beacon!gatech!ncar!ames!hc!lanl!beta!jlg From: jlg@beta.lanl.gov (Jim Giles) Newsgroups: comp.lang.fortran Subject: Re: Should I convert FORTRAN code to C? Message-ID: <20518@beta.lanl.gov> Date: 1 Jul 88 16:01:55 GMT References: <2742@utastro.UUCP> <20008@beta.UUCP> <224@raunvis.UUCP> <2130@pt.cs.cmu.edu> Organization: Los Alamos National Laboratory Lines: 35 In article <2130@pt.cs.cmu.edu>, jgk@speech2.cs.cmu.edu (Joe Keane) writes: > Whether an array is static or dynamic has nothing to do with whether > it contains arrays or pointers. > You haven't been reading this discussion at all! The C gurus all have been saying that a static multidimensional array is implemented as pointer to array, but that a dynamic multidimensional array is implemented as pointer to pointer (to pointer ... etc for the number of dimensions). I have no reason to dispute this claim since it is the same as the statements made in a recent issue of _Computer Language_ magazine. > >By the way, I've not seen any C compilers which optimize static 2-d >arrays anyway. > > So you've not seen any C compilers. Given `static foo[10][10][10]' > the reference `foo[2][0][7]' is a single address. If foo were a > parameter the reference would be a single offset. But see for > yourself. What you just described is constant folding (the constant subscript expressions were done at compile time). Now, show how this relates to the issue which was being discussed - vectorization or pipelining. > > >As a result, very similar code is actually > >generated whether the array was statically or dynamically allocated. > > Yes, the same code. Exactly!! The same bad code. It was neither vectorized nor unrolled for pipelining. Hence it is not the same code that Fortran compilers generally produce. The Fortran generally runs faster because its conception of array is better suited to these types of optimization. J. Giles Los Alamos