OpenMP* 4.0 Features in Intel Fortran Composer XE 2013

OpenMP* 4.0 adds new features for controlling vectorization and execution on coprocessors. Intel® [Visual] Fortran Composer XE 2013 Update 2 (compiler version 13.1) supports most of these new features. Most of them provide functionality to existing Intel-specific compiler directives.

The product documentation will be updated to include the new features in a future major release. In the meantime, this article documents the new features. If you have questions, comments or concerns, please ask in our User Forums or at Intel® Premier Support.

NOTE: The syntax and descriptions below are taken from OpenMP Technical Report 1 on Directives for Attached Accelerators. It is possible that some syntax and functionality may change before the final approval of OpenMP 4.0. If the final standard makes changes, you may need to change your code accordingly.

New OpenMP Directives
OMP SIMD
OMP DECLARE SIMD
OMP DO SIMD
OMP PARALLEL DO SIMD
OMP TARGET DATA
OMP TARGET
OMP TARGET UPDATE
OMP DECLARE TARGET
OMP DECLARE TARGET MIRROR
OMP DECLARE TARGET LINKABLE

New OpenMP clauses for TARGET* directives:
SCRATCH
MAPTO
MAPFROM
MAP

New OpenMP routines

SIMD

OpenMP* Fortran Compiler Directive: Requires and controls SIMD vectorization of loops.

c$OMP SIMD [clause[[,] clause]…]
   do-loop
[c$OMP END SIMD]

c

Is one of the following: C (or c), !, or * (see Syntax Rules for Compiler Directives).

clause

Is an optional vectorization clause. It can be one or more of the following:

  • ALIGNED (list [: n])
    Specifies that all variables in list are aligned in a DO loop. Any variable that appears in list cannot appear in more than one ALIGNED clause.

    The n must be a constant positive integer expression; it indicates the number of bytes for the alignment. If n is not specified, the compiler uses the default alignment specified for SIMD instructions on the target platform.

    The ALIGNED clause overrides efficiency heuristics in the optimizer. It instructs the compiler to use aligned data movement instructions for all array references. This clause disables all the advanced alignment optimizations of the compiler, such as determining alignment properties from the program context or using dynamic loop peeling to make references aligned.

    Be careful when using the ALIGNED clause. Instructing the compiler to implement all array references with aligned data movement instructions will cause a runtime exception if some of the access patterns are actually unaligned.

  • COLLAPSE (n)
    Specifies how many loops are associated with the loop construct. The n must be a constant positive integer expression. If COLLAPSE is not specified, the only loop that is associated with the loop construct is the one that immediately follows the construct.

    If n is greater than one, the iterations of all associated loops are collapsed into one larger iteration, which is then executed with SIMD instructions. The sequential execution of the iterations in all associated loops determines the order of the iterations in the collapsed iteration.

    The iteration count for each associated loop is computed before entry to the outermost loop.

    Only one COLLAPSE clause may appear in a SIMD directive.

  • LASTPRIVATE (list)
    See existing documentation for this clause

  • LINEAR ( var1 [, var2 ]… [: step ] )

    var

    Is a scalar variable.

    step

    Is a compile-time positive, integer constant expression.

    For each iteration of a scalar loop, each var is incremented by step, so every iteration of the vector loop increments the variables by VL*step where VL is the Vector Length. If more than one step is specified for a var, a compile-time error occurs. Multiple LINEAR clauses can be used to specify different values for step.

    A variable in a LINEAR clause cannot appear in a REDUCTION, PRIVATE, or LASTPRIVATE, or another LINEAR clause.

  • PRIVATE (list)
    See existing documentation for this clause

  • REDUCTION (operator: list)
    See existing documentation for this clause

  • SAFELEN (n)
    Limits the number of iterations in a SIMD chunk (set of concurrent iterations).

    The n must be a constant positive integer expression; it indicates the number of iterations allowed in a SIMD chunk.

    When this clause is used, no two iterations executed concurrently with SIMD instructions can have a greater distance in the logical iteration space than its value n. The number of iterations that are executed concurrently at any given time is defined by the implementation.  Each concurrent iteration is executed by a different SIMD vector lane.

    Only one SAFELEN clause can appear in a SIMD directive.

do-loop

Is one or more DO iterations (DO loops). The DO iteration cannot be a DO WHILE or a DO loop without loop control. The DO loop iteration variable must be of type integer.

All loops associated with the construct must be structured and perfectly nested; that is, there must be no intervening code and no other OpenMP* Fortran directives between any two loops.

The iterations of the DO loop are distributed across the existing team of threads. The values of the loop control parameters of the DO loop associated with a DO directive must be the same for all the threads in the team.

You cannot branch out of a DO loop associated with a SIMD directive.

If used, the END SIMD directive must appear immediately after the end of the loop. If you do not specify an END SIMD directive, an END SIMD directive is assumed at the end of do-loop.
The SIMD construct enables the execution of multiple iterations of the associated loops concurrently by means of SIMD instructions. No other OpenMP* Fortran construct may appear in a SIMD directive.

A SIMD region binds to the current task region. The binding thread set of the SIMD region is the current team.


DECLARE SIMD

OpenMP* Fortran Compiler Directive: Generates a SIMD procedure.

c$OMP DECLARE SIMD (routine-name) [clause[[,] clause]…]

c

Is one of the following: C (or c), !, or * (see Syntax Rules for Compiler Directives).

routine-name

Is the name of a routine (a function or subroutine). It cannot be a generic name; it must be a specific name.
You cannot branch into or out of the routine and the The routine cannot contain an ENTRY statement.

clause

Is one or more of the following:

    • ALIGNED (list [: n])

      Specifies that all variables in list are aligned. Any variable that appears in list cannot appear in more than one ALIGNED clause.

      The n must be a constant positive integer expression; it indicates the number of bytes for the alignment. If n is not specified, the compiler uses the default alignment specified for SIMD instructions on the target platform.

      The ALIGNED clause overrides efficiency heuristics in the optimizer. It instructs the compiler to use aligned data movement instructions for all array references. This clause disables all the advanced alignment optimizations of the compiler, such as determining alignment properties from the program context or using dynamic loop peeling to make references aligned.

      Be careful when using the ALIGNED clause. Instructing the compiler to implement all array references with aligned data movement instructions will cause a runtime exception if some of the access patterns are actually unaligned.

    • INBRANCH | NOTINBRANCH

      The INBRANCH clause specifies that the routine must always be called from inside a conditional statement of a SIMD loop.

      The NOTINBRANCH clause specifies that the routine must never be called from inside a conditional statement of a SIMD loop.

      If neither clause is specified, then the routine may or may not be called from inside a conditional statement of a SIMD loop.

      You can only specify INBRANCH or OUTBRANCH; you cannot specify both.

    • LINEAR ( var1 [, var2 ]… [: step ] )

      var

      Is a scalar variable.

      step

      Is a compile-time positive, integer constant expression.

      For each iteration of a scalar loop, each var is incremented by step, so every iteration of the vector loop increments the variables by VL*step where VL is the Vector Length. If more than one step is specified for a var, a compile-time error occurs. Multiple LINEAR clauses can be used to specify different values for step.

      A variable in a LINEAR clause cannot appear in a REDUCTION, PRIVATE, or LASTPRIVATE, or another LINEAR clause.

    • REDUCTION (operator: list)

      See existing documentation for this clause

    • SIMDLEN (n)

      Specifies the number of concurrent arguments (n) for the SIMD version of routine-name. The n must be a constant positive integer expression.

If SIMDLEN is not specified, the number of concurrent arguments for the routine-name is implementation defined.

Only one SIMDLEN clause can appear in a DECLARE SIMD directive.

    • UNIFORM (list)

      Tells the compiler that the values of the specified arguments have an invariant value for all concurrent invocations of the routine in the execution of a single SIMD loop.

The list is one or more scalar variables that are dummy arguments in the specified routine.

Multiple UNIFORM clauses are merged as a union.

The DECLARE SIMD construct enables the creation of a SIMD versions of the specified subroutine or function.  This These versions can be used to process multiple arguments from a single invocation from a SIMD loop concurrently.

When routine-name is executed, it cannot have any side-effects that would change its execution for concurrent iterations of a SIMD chunk. When the routine is called from a SIMD loop, it cannot cause the execution of any OpenMP* Fortran construct.

If a DECLARE SIMD directive is specified for a routine name with explicit interface and for the definition of the routine, they must match. Otherwise, the result is unspecified.

You cannot use procedure pointers to access routines created by the DECLARE SIMD directive.

You can only specify a particular variable in at most one instance of a UNIFORM or LINEAR clause.


DO SIMD

OpenMP* Fortran Compiler Directive: Specifies a loop that can be executed concurrently using SIMD instructions.

c$OMP DO SIMD [clause[[,] clause]…]
   do-loop
[c$OMP END DO SIMD [NOWAIT]]

c

Is one of the following: C (or c), !, or * (see Syntax Rules for Compiler Directives).

clause

Can be any of the clauses accepted by the DO or SIMD directives.

do-loop

Is one or more DO iterations (DO loops). The DO iteration cannot be a DO WHILE or a DO loop without loop control. The DO loop iteration variable must be of type integer.

All loops associated with the construct must be structured and perfectly nested; that is, there must be no intervening code and no other OpenMP* Fortran directives between any two loops.

The iterations of the DO loop are distributed across the existing team of threads. The values of the loop control parameters of the DO loop associated with a DO directive must be the same for all the threads in the team.

You cannot branch out of a DO loop associated with a DO SIMD directive.

If you do not specify an END DO SIMD directive, an END DO SIMD directive is assumed at the end of do-loop.

The DO SIMD construct converts the associated DO loop to a SIMD loop in a way that is consistent with any clauses that apply to the SIMD construct. The resulting SIMD chunks and any remaining iterations will be distributed across the implicit tasks of the parallel region in a way that is consistent with any clauses that apply to the DO construct.


PARALLEL DO SIMD

OpenMP* Fortran Compiler Directive: Specifies a loop that can be executed concurrently using SIMD instructions.

c$OMP PARALLEL DO SIMD [clause[[,] clause]…]
   do-loop
[c$OMP END PARALLEL DO SIMD]

c

Is one of the following: C (or c), !, or * (see Syntax Rules for Compiler Directives).

clause

Can be any of the clauses accepted by the PARALLEL, DO, or SIMD directives, with identical meanings and restrictions. [PARALLEL, DO, and SIMD will be links to the directive descriptions.]

do-loop

Is one or more DO iterations (DO loops). The DO iteration cannot be a DO WHILE or a DO loop without loop control. The DO loop iteration variable must be of type integer.

All loops associated with the construct must be structured and perfectly nested; that is, there must be no intervening code and no other OpenMP* Fortran directives between any two loops.

The iterations of the DO loop are distributed across the existing team of threads. The values of the loop control parameters of the DO loop associated with a DO directive must be the same for all the threads in the team.

You cannot branch out of a DO loop associated with a DO SIMD directive.

If you do not specify an END PARALLEL DO SIMD directive, an END PARALLEL DO SIMD directive is assumed at the end of do-loop.

You cannot specify NOWAIT in a PARALLEL DO SIMD construct.


TARGET DATA

OpenMP* Fortran Compiler Directive: Creates a device data environment for the extent of the region. This directive only applies to Intel® MIC Architecture.

c$OMP TARGET DATA [clause[[,] clause]…]
   block
[c$OMP END TARGET DATA]

c

Is one of the following: C (or c), !, or * (see Syntax Rules for Compiler Directives).

clause

Is one or more of the following:

  • DEVICE (integer-expression)

    Specifies the target device.

    The integer-expression must evaluate to a positive integer value.

    If DEVICE is not specified, the default device is determined by the ICV named device-num-var.

    Only one DEVICE clause can appear in a TARGET DATA directive.

  • MAP (list)

    See description below

  • MAPTO (list)

    See description below

  • MAPFROM (list)

    See description below

  • SCRATCH (list)

    See description below

  • IF (expression)

    Specifies a conditional statement.

    The expression is a scalar logical expression that evaluates to .TRUE. or .FALSE..

    When an IF clause is specified and the expression evaluates to .FALSE., the new device data environment is not created.

    At most one IF clause can appear in a TARGET DATA directive.

block

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

If used, the END TARGET DATA directive must appear immediately after the end of the block. If you do not specify an END TARGET DATA directive, an END TARGET DATA directive is assumed at the end of block.

The binding task region for a TARGET DATA construct is the encountering task. The target region binds to the enclosing parallel or task region.

When a TARGET DATA construct is encountered, a new device data environment is created, and the encountering task executes the target data region.

The new device data environment is constructed from the enclosing data environment and any MAP, MAPTO, MAPFROM, or SCRATCH clauses specified in the construct.

A program must not depend on any ordering of the evaluations of the clauses of the TARGET DATA directive, or on any side effects of the evaluations of the clauses.


TARGET

OpenMP* Fortran Compiler Directive: Creates a device data environment and executes the construct on the same device. This directive only applies to Intel® MIC Architecture.

c$OMP TARGET [clause[[,] clause]…]
   construct
[c$OMP END TARGET]

c

Is one of the following: C (or c), !, or * (see Syntax Rules for Compiler Directives).

clause

Is one or more of the following:

  • DEVICE (integer-expression)

    Specifies the target device.

    The integer-expression must evaluate to a positive integer value.

    If DEVICE is not specified, the default device is determined by the Internal Control Variable (ICV) named device-num-var.

    Only one DEVICE clause can appear in a TARGET DATA directive.

  • MAP (list)

    See description below

  • MAPTO (list)

    See description below

  • MAPFROM (list)

    See description below

  • NUM_THREADS (list)

    Indicates values to be assigned to the ICV nthreads-var in the new device data environment. list is the name of one or more variables or common blocks that are accessible to the scoping unit.

The NUM_THREADS clause overrides the initial values for ICV nthreads-var.

  • SCRATCH (list)

    See description below

  • IF (expression)

    Specifies a conditional statement.

    The expression is a scalar logical expression that evaluates to .TRUE. or .FALSE..

    When an IF clause is specified and the expression evaluates to .FALSE., the target region is not executed by the device. It is executed by the encountering task.

    At most one IF clause can appear in a TARGET DATA directive.

construct

Is a PARALLEL DO construct or a PARALLEL SECTIONS construct. [includes links to each construct]

If used, the END TARGET directive must appear immediately after the end of the block. If you do not specify an END TARGET directive, an END TARGET DATA directive is assumed at the end of block.

The binding task for a TARGET construct is the encountering task. The target region binds to the enclosing parallel or task region.

This construct provides a superset of the functionality provided by the TARGET DATA construct.

The TARGET construct also specifies that the region is executed by a device. The encountering task waits for the device to complete the target region at the end of the construct.

If a TARGET, TARGET DATA, or TARGET UPDATE construct appears within a target region, the construct is ignored.


TARGET UPDATE

OpenMP* Fortran Compiler Directive:  Makes the list items in the device data environment consistent with their corresponding original list items. This directive only applies to Intel® MIC Architecture.

c$OMP TARGET UPDATE [clause[[,] clause]…]

c

Is one of the following: C (or c), !, or * (see Syntax Rules for Compiler Directives).

clause

Is one or more of the following:

  • DEVICE (integer-expression)

    Specifies the target device.

    The integer-expression must evaluate to a positive integer value.

    If DEVICE is not specified, the default device is determined by the ICV named device-num-var.

    Only one DEVICE clause can appear in a TARGET UPDATE directive.

  • MAPTO (list)

    See description below

  • MAPFROM (list)

    See description below

  • IF (expression)

    Specifies a conditional statement.

    The expression is a scalar logical expression that evaluates to .TRUE. or .FALSE..

    When an IF clause is specified and the expression evaluates to .FALSE., the TARGET UPDATE construct is ignored.

    At most one IF clause can appear in a TARGET UPDATE directive.

The binding task for a TARGET UPDATE construct is the encountering task. The target region binds to the enclosing parallel or task region. A TARGET UPDATE construct must not appear inside of a target region.

If the corresponding original list item does not exist in the device data environment, the list item is ignored in the MAPTO or MAPFROM clause.

A list item that appears in a MAPTO clause cannot appear in a MAPFROM clause, and vice versa.


DECLARE TARGET

OpenMP* Fortran Compiler Directive:  Causes the creation of a device-specific version of a named routine that can be called from a target region. This directive only applies to Intel® MIC Architecture.

c$OMP DECLARE TARGET (routine-name)

c

Is one of the following: C (or c), !, or * (see Syntax Rules for Compiler Directives).

routine-name

Is the name of a function or subroutine.

The specified subroutine or function can be used inside a target region that executes on the device.

You cannot use a procedure pointer to access a routine version created by the DECLARE TARGET directive.


DECLARE TARGET MIRROR

OpenMP* Fortran Compiler Directive:  Specifies that variables are replicated, and a device has its own copy. This directive only applies to Intel® MIC Architecture.

c$OMP DECLARE TARGET MIRROR  (list)

c

Is one of the following: C (or c), !, or * (see Syntax Rules for Compiler Directives).

list

Is the name of one or more variables or common blocks that are accessible to the scoping unit.  Subobjects cannot be specified. Each name must be separated by a comma, and a named common block must appear between slashes (/ /).

For each list item that appears in a declare target mirror directive, a corresponding list item is available in the device data environment for the extent of the program. If the original list item is initialized, the corresponding list item in the device data environment is initialized with the same value.


DECLARE TARGET LINKABLE

OpenMP* Fortran Compiler Directive:  Specifies that the named list items will be made available on the device. This directive only applies to Intel® MIC Architecture.

c$OMP DECLARE TARGET LINKABLE  (list)


c

Is one of the following: C (or c), !, or * (see Syntax Rules for Compiler Directives).

list

Is the name of one or more variables or common blocks that are accessible to the scoping unit.  Subobjects cannot be specified. Each name must be separated by a comma, and a named common block must appear between slashes (/ /).

The DECLARE TARGET LINKABLE construct does not move the variable to the device. You must specify a TARGET DATA or TARGET construct to move the variable to the device.


New OpenMP clauses for TARGET directives:

The TARGET directives are only available on Intel® MIC Architecture.

MAP, MAPTO, MAPFROM, and SCRATCH clauses are used in OpenMP* Fortran TARGET directives. They are called data motion clauses.

List items that appear in these clauses may have corresponding new list items created in the device data environment that is associated with the construct. If a new list item is created, a new list item of the same type, kind, and rank is allocated. The initial value of the new list item is undefined.

The original list items and new list items may share storage.  This means that data races can occur. Data races are caused by unintended sharing of data; for example, when WRITEs to either item by one task or device are followed by a READ of the other item by another task or device without intervening synchronization.

These clauses do not modify the values of any of the internal control variables (ICVs).

The following are individual clause descriptions:

SCRATCH Clause

Parallel Directive Clause:  Declares that one or more list items are available in the new device data environment. This clause only applies to the TARGET directives, which are only available on Intel® MIC Architecture.

SCRATCH (list)

list

Is the name of one or more variables or common blocks that are accessible to the scoping unit.  Subobjects cannot be specified. Each name must be separated by a comma, and a named common block must appear between slashes (/ /).

If a corresponding list item of the original list item is in the enclosing device data environment, the new device data environment uses the corresponding list item from the enclosing device data environment.

If a corresponding list item is not in the enclosing device data environment, a new list item with language-specific attributes is derived from the original list item and created in the new device data environment. This new list item becomes the corresponding list item to the original list item in the new device data environment.

If overlapped variables are used, the behavior is unspecified.

MAP Clause

Parallel Directive Clause:  Provides both MAPTO and MAPFROM functionality. This clause only applies to the TARGET directives, which are only available on Intel® MIC Architecture.

MAP (list)

list

Is the name of one or more variables or common blocks that are accessible to the scoping unit. Subobjects cannot be specified. Each name must be separated by a comma, and a named common block must appear between slashes (/ /).

This clause provides the functionality provided both by the MAPTO and by the MAPFROM clauses.

MAPFROM Clause

Parallel Directive Clause:  Declares one or more list items to be available in the new device data environment and causes the original list item to be assigned the corresponding list item's value after the end of the region. This clause only applies to the TARGET directives, which are only available on Intel® MIC Architecture.

MAPFROM (list)

list

Is the name of one or more variables or common blocks that are accessible to the scoping unit. Subobjects cannot be specified. Each name must be separated by a comma, and a named common block must appear between slashes (/ /).

This clause provides a superset of the functionality provided by the SCRATCH clause.

MAPTO Clause

Parallel Directive Clause:  Declares one or more list items to be available in the new device data environment. On entry to the region, each new corresponding list item is initialized with the original list item's value. This clause only applies to the TARGET directives, which are only available on Intel® MIC Architecture.

MAPTO (list)


list

Is the name of one or more variables or common blocks that are accessible to the scoping unit. Subobjects cannot be specified. Each name must be separated by a comma, and a named common block must appear between slashes (/ /).

This clause provides a superset of the functionality provided by the SCRATCH clause.

The map initialization is done as if by assignment.


New OpenMP Routines

The following are new OpenMP routines

Summary of OpenMP Fortran Parallel Routines

 

Name

Description

 

OMP_GET_DEVICE_NUM

Gets the value of the internal control variable (ICV) named device-num-var, which determines the default device number.

 

OMP_GET_PROC_BIND

Gets the thread affinity policy that should be used for the next most closely nested parallel region.

 

OMP_SET_DEVICE_NUM

Sets the value of the internal control variable (ICV) named device-num-var, which determines the default device number.

 

For more complete information about compiler optimizations, see our Optimization Notice.