Consider,
!HPF$ INDEPENDENT DO i = 1, n a(i) = b(i-1) + b(i) + b(i+1) END DO
Can perform all iterations in parallel. Also,
!HPF$ INDEPENDENT FORALL (i=1:n) & a(i) = b(i-1) + b(i) + b(i+1)
don't have to calculate whole RHS before assignment.
The above DO loop is similar to the last loop of the previous examples section. The object b is not assigned to within the loop body which means that assuming there is no `hidden' connection between a and b such as storage association, then no dependence can arise. The FORALL statement is independent for the very same reason, here, each processor can perform its local calculations without having to check on the progress of other processors; it is able to perform all its assignments to a before having to synchronise.
Can also use INDEPENDENT with vector subscripts,
!HPF$ INDEPENDENT DO i = 1, n a(index(i)) = b(i-1) + b(i) + b(i+1) END DO
This illustrates how a DO loop which involves assignment to a vector subscripted (indirectly addressed) object can be parallelised. The INDEPENDENT directive asserts that all values of index(1:n) are unique. This DO loop could be rewritten as an array assignment:
A(INDEX) = B(0:n-1) + B(1:n) + B(2:n+1)
to achieve the same effect.
Return to corresponding overview page