Intel® Fortran Compiler 16.0 User and Reference Guide

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.

!$OMP WORKSHARE

   block

!$OMP END WORKSHARE [NOWAIT]

block

Is a structured block (section) of statements or constructs. No branching into or out of the block of code is allowed.

The 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 block:

  • It may contain statements which bind to lexically enclosed PARALLEL constructs. Statements in these PARALLEL constructs are not restricted.

  • It may contain ATOMIC directives and CRITICAL constructs.

  • It must only contain array assignment statements, scalar assignment statements, FORALL statements, FORALL constructs, WHERE statements, or WHERE constructs.

  • It must not contain any user defined function calls unless the function is ELEMENTAL.

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