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

Examples of INDEPENDENT

!HPF$ INDEPENDENT FORALL ( i=2:n ) a(i) =index.html 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 =index.html 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 index.html is assigned repeatedly. However, the three outer loops are independent because they access different elements of index.html. 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 =index.html 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 index.html loop, neither loop would be independent, because an interleaved execution of loop iterations might cause other values of index.html, index.html, index.html, and index.html to be used in the assignment of index.html 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 index.html because of the stride of the DO loop (i.e. index.html and index.html are always even, therefore index.html, etc. are always odd.)

!HPF$ INDEPENDENT DO i =index.html 1, 10 WRITE (iounit(i),100) a(i) END DO 100 FORMAT ( F10.4 ) If index.html evaluates to a different value for every index.html, 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 index.html for all index.html, 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