next up previous contents
Next: New Variables Example 2 Up: INDEPENDENT NEW Loops Previous: INDEPENDENT NEW Loops

 

New Variables Example 1

Consider,

    DO i = 1, n
     DO j = 1, m
      x = A(j)
      y = B(j)
      C(i,j) = x+y
     END DO
    END DO

with a nested loop such as this, it is the inner loops that must be examined first. Inspection of the j loop reveals that if copies were made of x and y for each iteration the loop would be INDEPENDENT. In order to parallelise, the directive:

  !HPF$ INDEPENDENT, NEW (x,y)

should prefix the inner loop.

Attention can now turn to the outermost loop. We could perform all the i iterations at the same time if there was a separate DO j loop for each iteration. Specifying j to be a NEW variable would do exactly this, viz:

    !HPF$ INDEPENDENT, NEW (j)
    DO i = 1, n
     !HPF$ INDEPENDENT, NEW (x,y)
     DO j = 1, m
      x = A(j)
      y = B(j)
      C(i,j) = x+y
     END DO
    END DO

After the loop x, y and j will have an undetermined value so cannot be used before being assigned a new value. (In regular Fortran they could be.)

 

Looking at the outermost leaves of Figure 55 will illustrate what can be performed in parallel. It can be seen that all tex2html_wrap_inline29636 iterations can be performed independently. There is no interaction between any iterations.

   figure16892
Figure 55: Visualisation of Double Nested Independent New Loop

Now try this question gif

Return to corresponding overview page gif


next up previous contents
Next: New Variables Example 2 Up: INDEPENDENT NEW Loops Previous: INDEPENDENT NEW Loops

©University of Liverpool, 1997
Wed May 28 20:20:27 BST 1997
Not for commercial use.