3.2.3 PARALLEL DO Directive

The PARALLEL DO directive tells KAP the next statement begins an iterative DO loop that can be executed using multiple processors. Each processor applied to the DO loop can execute one or more iterations. The following syntax example shows the PARALLEL DO directive inside a PARALLEL REGION.

C*KAP*  PARALLEL REGION
C*KAP*&    [ IF(logical expression) ]
C*KAP*&    [ SHARED(shared_name,...) ]
C*KAP*&    [ LOCAL(local_name,...) ]
C*KAP*          PARALLEL DO
C*KAP*&          [ STATIC ]
C*KAP*&          [ LAST LOCAL(local_name,...) ] ]
C*KAP*&          [ BLOCKED [ (integer constant expression) ] ]
C*KAP* END PARALLEL REGION

In the syntax example, LAST LOCAL(local_name) creates a "local_name " type variable that is used during execution of the PARALLEL DO loop. During the last PARALLEL DO loop iteration, the final value of "local_name " is copied into an identically named variable created by SHARED(shared_ name) in the enclosing PARALLEL REGION. For example, the final value of variable LAST LOCAL(x) would be copied into variable SHARED(x) , as follows:

C*KAP*  PARALLEL REGION
C*KAP*&    SHARED(x)
C*KAP*          PARALLEL DO
C*KAP*&          LAST LOCAL(x)
                 DO 10
                 .
                 .
                 .
            10   CONTINUE
C*KAP*  END PARALLEL REGION

Since the LAST LOCAL() variable inside the PARALLEL DO implies the SHARED() variable inside the PARALLEL REGION, it is legal to use both PCF directives.

Currently, the only scheduling method supported by the parallel run-time library is static. If [ BLOCKED [ (integer constant expression) ] ] is specified in a PARALLEL DO, loop iterations are assigned to run-time "workers." A "worker" is a logical processor, that is, a processor, a process, or a thread in blocks of that size.

If BLOCKED is omitted in a PARALLEL DO directive, the default is even scheduling where loop iterations are evenly divided among run-time "workers." If BLOCKED is specified without a number, the default block size is 1.


Previous Page | Next Page | Contents | Index |
Command-Line Qualifiers