インテル® Fortran コンパイラー 19.0 デベロッパー・ガイドおよびリファレンス

DECLARE TARGET

OpenMP* Fortran Compiler Directive: Specifies that named variables, common blocks, functions, and subroutines are mapped to a device. This directive only applies when targeting Intel® Xeon Phi™ products.

It takes one of the following forms:

!$OMP DECLARE TARGET [(extended-list)]

!$OMP DECLARE TARGET[clause[[,]clause]...]

extended-list

Is a list of one or more variables, functions, subroutines, data pointers, procedure pointers, or common blocks. If you specify more than one extended-list item, they must be separated by commas. A common block name must appear between slashes (/ /); you cannot specify a blank common block. The specified extended-list items can be used inside a target region that executes on the device.

If the extended-list item is a function or subroutine, it must not be a generic name or entry name. A device-specific version of the routine is created that can be called from a target region.

If the extended-list item is a variable:

  • It is mapped to a corresponding variable in the device data environment. If the variable is initialized, the corresponding variable in the device data environment is initialized with the same value.

  • It can only appear in the scope in which it is declared.

  • It must be declared in the Fortran scope of a module, or it must have the SAVE attribute (explicitly or implicitly).

You cannot specify the following variables in the DECLARE TARGET directive:

  • A THREADPRIVATE variable

  • A variable that is part of another variable (for example, an element in an array or a field of a structure)

  • A variable that is an element of a common block

  • A variable that appears in an EQUIVALENCE statement

If the extended-list item is a common block:

  • It must be declared to be a common block in the same scoping unit in which the DECLARE TARGET directive appears.

  • If the DECLARE TARGET directive specifying the common block name appears in one program unit, a DECLARE TARGET directive must also appear in every other program unit that contains a COMMON statement specifying the same common block name. The directive must appear after the last relevant COMMON statement in the program unit.

clause

Is one of the following:

  • TO (extended-list)

    Is a comma-separated collection of one or more list items or procedures.

    If a list item is a routine then a device-specific version of the routine is created that can be called from a target region.

    If a list item is a variable then the original variable is mapped to a corresponding variable in the device data environment as if it had appeared in a MAP clause with the map-type TO on the implicit TARGET DATA construct for each device.

    The list item is never removed from those device data environments.

  • LINK (list)

    The list items of a LINK clause are not mapped by the DECLARE TARGET directive. Instead, their mapping occurs only when they are mapped by TARGET DATA or TARGET constructs.

If you specify list, this directive can only appear in a specification part of a subroutine, function, program, or module.

If you do not specify list, the directive must appear in the specification part of the relevant subroutine, function, or interface block.

If a DECLARE TARGET directive is specified in an interface block for a procedure, it must match a DECLARE TARGET directive in the definition of the procedure.

If a procedure is declared in a procedure declaration statement, any DECLARE TARGET directive containing the procedure name must appear in the same specification part.

The following additional rules apply to variables and common blocks:

The same list item must not appear multiple times in clauses on the same directive.

The same list item must not appear in both a TO clause on one DECLARE TARGET directive and a LINK clause on another DECLARE TARGET directive.

Variables with static storage and procedures used in an OMP TARGET region are implicitly treated as OMP DECLARE TARGET:

MODULE VARS
  INTEGER X
END MODULE

REAL FUNCTION FOO()
END FUNCTION

!$OMP TARGET 
  X = FOO()       ! X and FOO are implicitly DECLARE TARGET
!$OMP END TARGET

See Also