Parallel Programming Concepts

6.3 DO-LOOP

Since DO-loops are prime candidates for very effective parallelization, identification of dependence is very important, even more so the determination of whether or not the dependence found will render the loop incapable of the desired parallelization.

  • A LOOP-CARRIED DEPENDENCE exists when a storage location is used by a statement or statements, with at least one write, during different iterations of the loop.

    This cannot parallelize, because the order of execution of the loop's iterations is important for correct results.

    The important point, here, is that iteration-based parallelization, where different execution-streams are going to be responsible for different portions of the iteration-space of the loop, are going to wind up using incorrect values for the overlapping variable.

    Here's a piece of code demonstrating this:

    DO 500 J = 2,9
       A(J) = A(J-1) * 2.0
    500 CONTINUE
        
    DoLoop10

  • A LOOP-INDEPENDENT DEPENDENCE exists when a storage location is used by successive statements within an iteration, but not by different iterations.

    This can parallelize, because loop iterations can be executed independently and asynchronously. As all references to the same location are being executed by the same instruction stream, hence serially, there is no possibility for untimely access.