** Next:** Visualization of INDEPENDENT
**Up:** The INDEPENDENT Directive
** Previous:** The INDEPENDENT Directive

!HPF$ INDEPENDENT
FORALL ( i=2:n ) a(i) = b(i-1) + b(i) + b(i+1)
This example is equivalent in all respects to the first example.

!HPF$ INDEPENDENT, NEW (i2)
DO i1 = 1,n1
!HPF$ INDEPENDENT, NEW (i4)
DO i3 = 1,n3
DO i4 = 1,n4 ! The inner loop is NOT independent!
a(i1,i2,i3) = a(i1,i2,i3) + b(i1,i2,i4)*c(i2,i3,i4)
END DO
END DO
END DO
END DO
The inner loop is not independent because each element of is
assigned repeatedly. However, the three outer loops are independent
because they access different elements of . The `NEW` clauses
are required, since the inner loop indices are assigned and used in
different iterations of the outermost loops.

!HPF$ INDEPENDENT, NEW(vl, vr, ul, ur)
DO j = 2 , 100, 2
vl = p(i,j) - p(i-1,j)
vr = p(i+1,j) - p(i,j)
ul = p(i,j) - p(i,j-1)
ur = p(i,j+1) - p(i,j)
p(i,j) = f(i,j) + p(i,j) + 0.25 * (vr - vl + ur - ul)
END DO
END DO
Without the `NEW` option on the loop,
neither loop would be independent,
because an interleaved execution of loop iterations might cause other
values of , , , and to be used in the
assignment of than those computed in the same iteration of
the loop. The `NEW` option, however, specifies that this is not
true if distinct storage units are used in each iteration of the loop.
Using this implementation makes iterations of the loops independent of
each other.
Note that there is no interference due to accesses of the array
because of the stride of the DO loop (i.e. and are always
even, therefore , etc. are always odd.)

!HPF$ INDEPENDENT
DO i = 1, 10
WRITE (iounit(i),100) a(i)
END DO
100 FORMAT ( F10.4 )
If evaluates to a different value for every
, then the loop writes to a different I/O unit
(and thus a different file) on every iteration. The loop is then
properly described as independent. On the other hand, if
for all , then the assertion is in error and the loop
is not HPF-conforming.

** Next:** Visualization of INDEPENDENT
**Up:** The INDEPENDENT Directive
** Previous:** The INDEPENDENT Directive

*paula@erc.msstate.edu *

Thu Dec 8 16:17:11 CST 1994