[comp.lang.fortran] NEW TOPIC: Consistency of execution environment

fouts@lemming.nas.nasa.gov.nas.nasa.gov (Marty Fouts) (09/16/88)

On a particular supercomputer I have access to, a certain C compiler
produces scalar code which is considerablly faster than the vector
code a certain Fortran compiler produces for some particular do loop.
Worse, the Fortran compiler produces *pathatic* scalar code when I
explicitly force it to not vectorize the loop in question.

I mentioned this to an analyst who mumbled some words about preserving
the execution environment, which vaugely reminded me of something, but
I'm not sure what. (;-(  So, a question:

Does the Fortran Standard require the consistency of in memory
representation of data items?  For instance, in the do loop:

      DO 10 I = 1, 100
        J = I
C
C other things which prevent assuming that J is an alias
C
  10  CONTINUE

I know that Fortran isn't required to keep a memory consistent version
of I around, but is it true that some part of the standard can be
interpretted as requiring that the value of J in memory be updated for
each pass through the loop?

Thanks,

Marty
+-+-+-+     I don't know who I am, why should you?     +-+-+-+
   |        fouts@lemming.nas.nasa.gov                    |
   |        ...!ames!orville!fouts                        |
   |        Never attribute to malice what can be         |
+-+-+-+     explained by incompetence.                 +-+-+-+

jlg@lanl.gov (Jim Giles) (09/16/88)

From article <995@amelia.nas.nasa.gov>, by fouts@lemming.nas.nasa.gov.nas.nasa.gov (Marty Fouts):
> 
>       DO 10 I = 1, 100
>         J = I
> C
> C other things which prevent assuming that J is an alias
> C
>   10  CONTINUE
> 
> I know that Fortran isn't required to keep a memory consistent version
> of I around, but is it true that some part of the standard can be
> interpretted as requiring that the value of J in memory be updated for

The Fortran standard doesn't require _anything_ of memory.  The standard
describes what constitutes a standard conforming program and what semantics
a standard conforming processor must provide.  If all the uses of I and
J are local enough for the compiler to identify them, the compiler is
free to put them both in registers and not allocate any memory at all
for them.  In fact, if I and J are always identical (as above) the compiler
is free to use only one register for both of them

CFT77 on the crays will probably not even allocate memory for I and
J if they are only used in the loop and arent passed as arguments to 
any subroutines.  CFT on the Cray _may_ have more of a problem with
these (CFT _always_ allocates memory for variables even if it's not
necessary).  Unfortunately CFT often vectorizes better than CFT77
does (although this is getting better).  Neither CFT nor CFT77 should
generate stores for I and J _within_ the loop unless they are passed
to some procedure call (either as arguments or through common - if
J is in a common block and the loop makes _any_ procedure calls, J will
be stored).

J. Giles

fpst@hubcap.UUCP (Steve Stevenson) (09/16/88)

From article <995@amelia.nas.nasa.gov>, by fouts@lemming.nas.nasa.gov.nas.nasa.gov (Marty Fouts):
> Does the Fortran Standard require the consistency of in memory
> representation of data items?  


I recently asked this about the storage in 8x for COMPLEX.  Note that
the hanging on of equivalencing requires that the Re,Im be interleaved.
This is certainly a disaster for certain types of processors.

-- 
Steve Stevenson                            fpst@hubcap.clemson.edu
(aka D. E. Stevenson),                     fpst@prism.clemson.csnet
Department of Computer Science,            comp.parallel
Clemson University, Clemson, SC 29634-1906 (803)656-5880.mabell

jlg@lanl.gov (Jim Giles) (09/17/88)

From article <2979@hubcap.UUCP>, by fpst@hubcap.UUCP (Steve Stevenson):
> I recently asked this about the storage in 8x for COMPLEX.  Note that
> the hanging on of equivalencing requires that the Re,Im be interleaved.
> This is certainly a disaster for certain types of processors.

The standard doesn't require this.  It only requires that the Re,Im
parts should _appear_ to be interleaved with respect to the EQUIVALENCE
statement.  Admittedly, this is not much help since it would require
quite an amount of compiler work to simulate interleaving on data
that really isn't.

J. Giles