Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 11/07/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

TEAMS

OpenMP* Fortran Compiler Directive: Creates a league of thread teams to execute a structured block in the primary thread of each team. This feature is only available for ifx.

Syntax

!$OMP TEAMS [clause[[,] clause]... ]

   loosely-structured-block

!$OMP END TEAMS

-or-

!$OMP TEAMS [clause[[,] clause]... ]

   strictly-structured-block

[!$OMP END TEAMS]

clause

Is one of the following:

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 binding thread set for a TEAMS construct is the encountering thread.

If a TEAMS construct appears within a TARGET construct, the enclosing TARGET construct must contain no other statements or directives outside of the TEAMS construct. The following are the only OpenMP* constructs that can be nested in the team's region:

  • DISTRIBUTE

  • PARALLEL

  • PARALLEL SECTIONS

  • PARALLEL WORKSHARE

  • PARALLEL DO

  • PARALLEL DO SIMD

The thread that encounters this directive constructs a league of thread teams that execute the block in the primary thread of each team. After the teams are created, the number of teams remains constant for the duration of the team's parallel region.

The region following the TEAMS construct is executed by the primary thread of each team. Other threads do not begin execution until the primary thread encounters a parallel region. After the teams complete execution of the TEAMS construct region, the encountering thread resumes execution of the enclosing target region.

If NUM_TEAMS is not specified, the default number of teams is one. If THREAD_LIMIT is not specified, the default number of threads is the-number-of-available-hardware-threads / NUM_TEAMS.

A program must not depend on any side effects or any ordering of the evaluation of clauses in the TEAMS directive.

Each team has a unique team number. You can use the OpenMP* runtime library routine OMP_GET_TEAM_NUM to get the team number of the calling thread.

Each thread within the team has a unique thread identifier returned by the OpenMP runtime library routine OMP_GET_THREAD_NUM. As in any thread team, the thread identifier starts at zero for the primary thread up to THREAD_LIMIT - 1 for the remaining threads.

Immediately after this directive, only the primary threads in each team are executing, the other team members will only start to execute at the next (nested) parallel region. Therefore, there are only NUM_TEAMS threads executing, and each of them has OMP_GET_THREAD_NUM() == 0.