Subject: hpff-distribute: local computations, NEW clause and so.

From: Fabien COELHO <[email-masked]>
Date: Thu, 2 Nov 95 14:49:31 +0100

---------------------------------------------------------------------------
[email-masked] is a mailing list for discussion of data
distribution in High Performance Fortran.  Instructions for adding or
deleting yourself from this list appear at the bottom of this message.
---------------------------------------------------------------------------

Hi out there !

  A little problem solved by 
  a little hack that could be 
  a little directive:-)

The independent and new directives state that a loop is parallel, possibly
based on the private status of some scalar variables. With an "owner
computes rule"-based implementation in a compiler, it also allows to
express indirectly that only a subset of the processors are involved in a
computation. 

I have a nice data-parallel code that performs some 2D seismic
wave-propagation in an heterogeneous field. Different formulae are applied
for the inner region, for the borders... and up to the corners, which have
their own formulae.

For a given corner, I would like the compiler to figure out simply that a
set of assignments should only be computed on the processor that deals
with that corner, and that's all. For sure, the same scalar variables are
used at each corner, while these corners may be handled by different
processors. In order to express that these variables are local to a
processor and thus to avoid unnecessary synchronization and communications
at run-time, I used the following hack:

chpf$ independent(i), new(C3,W)
      do i=0,0
         C3          = 4/((1/V(NP,NP))+(1/V(NP,NP-1)) +
     $        (1/V(NP-1,NP))+(1/V(NP-1,NP-1)) )
         W           = C3*DELTAT
         BS(NP-1,1) = 2*W/(4*W+3*H)
         BS(NP-1,2) = 3*H/(4*W+3*H)
         V(NP,NP-1)  = C3
      enddo

The stupid 1 element loop allows to use the new directive, and the
do/enddo construction provides a scope for the private scalar variables. 

Now I think that allowing something like 

chpf$ local, new(C3,W)
         C3          = 4/((1/V(NP,NP))+(1/V(NP,NP-1)) +
     $        (1/V(NP-1,NP))+(1/V(NP-1,NP-1)) )
         W           = C3*DELTAT
         BS(NP-1,1) = 2*W/(4*W+3*H)
         BS(NP-1,2) = 3*H/(4*W+3*H)
         V(NP,NP-1)  = C3
chpf$ endlocal

although not essential to the language, would give a pretty-looking piece
of code, compared to the previous one that looks just stupid.

On the language point of view, it just means that variables with 
a local scope are welcome. The new directive states that the variables
have a local scope/visibility/liveness, and the local/endlocal provides
the needed scope, which cannot be expressed in Fortran 77. The C block {}
with local variables are mimicked this way. With this information, the
compiler finds quite easily that the other variables referenced are
distributed, and that the references are aligned one to the other. The
generated code selects the right processor and simply performs the
required computations on local data. 

That's all for 
   the little problem, 
   the little hack and 
   the little directive:-) 

Fabien.

Fabien COELHO __ http://www.cri.ensmp.fr/~coelho __ [email-masked]
  CRI, ENSMP, 35, rue Saint Honoré, 77305 Fontainebleau Cedex, France
     phone: 33 1 64 69 {voice: 48 52, fax: 47 09, standard: 47 08}
       ________  All opinions expressed here are mine  ________
---------------------------------------------------------------------------
To (un)subscribe to this list, send mail to
[email-masked].
Leave the subject line blank, and in the body put the line
(un)subscribe <email-address>
---------------------------------------------------------------------------