WORKSHARE

OpenMP* Fortran Compiler Directive: Divides the work of executing a block of statements or constructs into separate units. It also distributes the work of executing the units to threads of the team so each unit is only executed once.

Syntax

!$OMP WORKSHARE

   loosely-structured-block

!$OMP END WORKSHARE [NOWAIT]

-or-

!$OMP WORKSHARE

   strictly-structured-block

!$OMP END WORKSHARE [NOWAIT]

loosely-structured-block

Is a structured block (section) of statements or constructs. You cannot branch into or out of the block.

strictly-structured-block

Is a Fortran BLOCK construct. You cannot branch into or out of the BLOCK construct.

The loosely-structured-block or strictly-structured-block is executed so that each statement is completed before the next statement is started and the evaluation of the right hand side of an assignment is completed before the effects of assigning to the left hand side occur.

The following are additional rules for the block:

The binding thread set for a WORKSHARE construct is the current team. A workshare region binds to the innermost enclosing parallel region.

If you do not specify the NOWAIT keyword, synchronization is implied following the code.

Multithreaded code is not always generated for the statements inside the block of an OMP WORKSHARE construct. Some statements parallelize; others do not parallelize and instead execute sequentially inside an OMP SINGLE construct to preserve the correct semantics of WORKSHARE. Some specific details follow:

See Also