Subject: hpff-interpret: INDEPENDENT

From: [email-masked]
Date: Thu, 21 Dec 1995 19:11:48 -0800

---------------------------------------------------------------------------
[email-masked] is a mailing list for corrections,
clarifications, and interpretations related to High Performance Fortran.
Instructions for adding or deleting yourself from this list appear at the
bottom of this message.
---------------------------------------------------------------------------

Given a data layout:

      real, dimension(25) :: a,b,c
!HPF$ DISTRIBUTE a (*)
!HPF$ DISTRIBUTE b (*)
!HPF$ DISTRIBUTE c (*)

Is the following legal syntax and could an implementor choose to
compute this in parallel even though the arrays have been declared
"serial"?

!HPF$ INDEPENDENT
      do i=1,25
         a(i) = b(i) + c(i)
      enddo

[The motivation for the inquiry - it would be nice if the INDEPENDENT
directive would be honored over the DISTRIBUTE directive to
parallelize execution on an SMP type system if the cost of data motion
on the bus is cheap, but the same code would honor the DISTRIBUTE
directive over the INDEPENDENT directive to run code serially on a
distributed memory system where the cost of data motion over the
network may be expensive.  Realizing that that is a bit much to ask of
implementors, it would be nice to know if there are any thoughts on
a defined behavior for this combination of directives.]

thanks
-dave
---------------------------------------------------------------------------
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>
---------------------------------------------------------------------------

---

From: [email-masked] (Chuck Koelbel)
Date: Fri, 22 Dec 1995 10:57:36 -0600 (CST)

>a defined behavior for this combination of directives.]

The quick answer:

Yes, the syntax is legal.
Yes, this is a correct use of INDEPENDENT.
Yes, a compiler could implement INDEPENDENT as you suggest.
No, it is not written in stone that the compiler must implement INDEPENDENT
this way.

A bit of philosophy:

INDEPENDENT makes a statement about side effects of loop iterations (i.e.
it states that there aren't any side effects on other iterations).  There
is language in the specification to the effect that "The compiler can use
this information in any way that it sees fit."  With that in mind, I hope
it's clear that INDEPENDENT and DISTRIBUTE are basically orthogonal
constructs; you can mix and match them as needed.

The implementation you suggest is (IMHO) an excellent compiler heuristic
for handling INDEPENDENT.  I hope that SMP vendors are listening to you.
However, HPF bends over backwards to keep from requiring any particular
implementation.  (Similarly, you won't find many implementation hints in
the F90 standard, or most other language definitions.)  In part, this is
because HPF is supposed to run on many platforms which may need different
implementations.  In part, this is because we don't want HPF to be locked
into an old implementation technique if new research comes along.  And, of
course, it's hard enough to get agreement on a language without debating
"should this be implemented the APR way or the PGI way?"

So, HPF doesn't define a "behavior" for INDEPENDENT, in the sense that it
is legal for a given compiler to ignore the directive (in some cases, or in
all cases).  Or the compiler can use the INDEPENDENT information in ways
you haven't thought of (for example, INDEPENDENT implies you can turn off
cache coherency protocols for data assigned in the loop, if you turn
coherence back on at the right time).  I argue this is what you want for
portable programs, where each platform can treat INDEPENDENT the way that
it needs to.

If you really want/need to define a program's behavior, you may want to
look at the ON HOME directive being discussed in HPF 2.  (I promise, the
revised proposal is coming!)

                                                Chuck