Intel® Fortran Compiler

Developer Guide and Reference

ID 767251
Date 3/31/2025
Public
Document Table of Contents

WORKDISTRIBUTE

OpenMP* Fortran Compiler Directive: Divides a structured block of statements, including array assignment statement, into individual units of work. Each unit of work is executed by a thread of the enclosing team construct so each unit is only executed exactly once.

Syntax

!$OMP WORKDISTRIBUTE

   loosely-structured-block

!$OMP END WORKDISTRIBUTE

-or-

!$OMP WORKDISTRIBUTE

   strictly-structured-block

[!$OMP END WORKDISTRIBUTE]

loosely-structured-block

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

strictly-structured-block

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

Description

A statement in the block of a WORKDISTRIBUTE construct must be one of the following:

  • An intrinsic array assignment statement.

  • An intrinsic scalar assignment statement.

  • A call to a PURE or ELEMENTAL procedure (see the Note below).

Statements in the block of a WORKDISTRIBUTE construct must not reference procedures that are not PURE and ELEMENTAL, and must not reference THREADPRIVATE or GROUPPRIVATE variables.

A WORKDISTRIBUTE construct must be closely nested in a TEAMS construct; there can be no other construct nested in the TEAMS construct prior to the WORKDISTRIBUTE construct. The binding thread set for a WORKDISTRIBUTE construct is the enclosing teams region. The binding thread set is the set of initial threads executing the enclosing teams region.

The execution of the block of a WORKDISTRIBUTE construct is divided into separate units of work. The threads of the binding thread set share the units of work in a manner that each unit of work is executed once. The execution of statements is ordered to maintain Fortran semantics. The effects of each statement in the block must appear to complete execution before a subsequent statement executes. Evaluation of the right hand side of an assignment must effectively complete before assignment to the left hand side occurs. There is no implicit barrier at the end of a WORKDISTRIBUTE construct.

Statements in the block of a WORKDISTRIBUTE construct are divided into units of work as follows:

  • The assignment operation in a scalar assignment statement is a unit of work.

  • Assignment to each element of an array in an array assignment statement is a unit of work.

  • For array expressions in a statement, including computation of a scalar result from an transformational array intrinsic function:

    • Evaluation of each element of the array expression, including references to pure elemental procedures is a unit of work.

    • Evaluation of a transformational array intrinsic function may be subdivided into any number of units of work.

NOTE:
Currently, the occurrence of any procedure call in the block of a WORKDISTRIBUTE construct, with the exception of a call to MATMUL with fixed size array arguments, inhibits the work distribution property of the construct. Within the block of the construct, the value of an array expression that references the allocation status, the association status, or the value of a variable declared as PRIVATE is undefined unless the same value would be computed by every thread.