Should I convert FORTRAN code to C?

Mike Coffin mike at arizona.edu
Fri Jul 1 11:05:12 AEST 1988


>From article <20454 at beta.lanl.gov>, by jlg at beta.lanl.gov (Jim Giles):
> By the way, I've not seen any C compilers which optimize static 2-d
> arrays anyway.  An early step in the compiler usually turns the array
> reference into a linear function on the indices - this throws out the
> dependency information.

This is not true.  How can information be lost by changing "a[i]" to
"*(a+i)"?  In fact at least one very fancy FORTRAN compiler converts
array references to exactly that form to extract dependency
information that is difficult to recognize otherwise.  See
"Interprocedural Dependency Analysis and Parallelization" by Michael
Burke and Ron Cytron, in the 1986 SIGPLAN Symposium on Compiler
Construction, pp 162-175.

For instance they are able to parallelize a loop with the following
references:

	DO i = 1 to N
		A(2i,2i+1) = ...
		... = A(i,i)
		END

They say (page 166) 
    "Existing techniques separately analyze the two dimensions of A,
    and so separately consider two dependence equations, neither of
    which can demonstrate independence.  However, the dependencies
    that exist independently in each dimension cannot hold
    simultaneously: for any value of i, the expressions at the
    definition (2i and 2i+1) are never equal but the expressions at
    the use (i and i) are equivalent.  Since the dependencies cannot
    hold simultaneously, no dependence exists between the definition
    and use of A.  By linearizing the references to A, we couple the
    two equations into one, allowing us to determine the independence
    of the accessed regions."
-- 

Mike Coffin				mike at arizona.edu
Univ. of Ariz. Dept. of Comp. Sci.	{allegra,cmcl2,ihnp4}!arizona!mike
Tucson, AZ  85721			(602)621-4252



More information about the Comp.lang.c mailing list