An introduction to SMP directives

The SMP directives described in this section allow you to exert control over parallelization. For example, the PARALLEL DO directive specifies that the loop immediately following the directive should be run in parallel. All SMP directives are comment form directives. For more information on rules and syntax for comment form directives, see Comment and noncomment form directives .

XL Fortran supports a number of SMP directives, divided as follows. To ensure the greatest portability of code, OpenMP directives are recommended where possible. Use the OpenMP trigger_constant, $OMP for OpenMP directives, but do not use this trigger_constant with any other directive. OpenMP directives must not appear in PURE and ELEMENTAL procedures.

Parallel region construct

Parallel constructs form the foundation of OpenMP based parallel execution in XL Fortran. The PARALLEL/END PARALLEL directive pair forms a basic parallel construct. Each time an executing thread enters a parallel region, it creates a team of threads and becomes master of that team. This allows parallel execution to take place within that construct by the threads in that team. The following directives are necessary for a parallel region:

PARALLEL END PARALLEL

Work-sharing constructs

Work-sharing constructs divide the execution of code enclosed by the construct between threads in a team. For work-sharing to take place, the construct must be enclosed within the dynamic extent of a parallel region. For further information on work-sharing constructs, see the following directives:

DO END DO
SECTIONS END SECTIONS
WORKSHARE END WORKSHARE

Combined parallel work-sharing constructs

A combined parallel work-sharing construct allows you to specify a parallel region that already contains a single work-sharing construct. These combined constructs are semantically identical to specifying a parallel construct enclosing a single work-sharing construct. For more information on implementing combined constructs, see the following directives:

PARALLEL DO END PARALLEL DO
PARALLEL SECTIONS END PARALLEL SECTIONS
PARALLEL WORKSHARE END PARALLEL WORKSHARE

Synchronization constructs

The following directives allow you to synchronize the execution of a parallel region by multiple threads in a team:

ATOMIC
BARRIER
CRITICAL END CRITICAL
FLUSH
ORDERED END ORDERED
SINGLE END SINGLE

Other OpenMP Directives

The following OpenMP directives provide additional SMP functionality:

MASTER END MASTER
THREADPRIVATE

Non-OpenMP SMP directives

The following directives provide additional SMP functionality:

DO SERIAL
SCHEDULE
THREADLOCAL