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

ID 767251
Date 7/13/2023
Public

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

Document Table of Contents

fopenmp-declare-target-scalar-defaultmap, Qopenmp-declare-target-scalar-defaultmap

Determines which implicit data-mapping/sharing rules are applied for a scalar variable referenced in a TARGET directive. This feature is only available for ifx.

Syntax

Linux:

-fopenmp-declare-target-scalar-defaultmap=keyword

macOS:

None

Windows:

/Qopenmp-declare-target-scalar-defaultmap:keyword

Arguments

keyword

Is the rule to be applied for a scalar variable referenced in a target pragma.TARGET directive.. Possible values are:

default

Specifies that the compiler should apply implicit data-mapping/sharing rules according to the OpenMP* specification.

Thus, when a scalar variable referenced in a TARGET construct appears in a TO clause in a DECLARE TARGET directive, and the TARGET construct's clauses do not define explicit data-mapping/sharing for this variable, then the compiler should treat it as if it had appeared in a MAP clause with a map-type of TOFROM.

firstprivate

Specifies that when a scalar variable referenced in a TARGET construct appears in a TO clause in a DECLARE TARGET directive, and the TARGET construct's clauses do not define explicit data-mapping/sharing for this variable, then the scalar variable is not mapped, but instead has an implicit data-sharing attribute of FIRSTPRIVATE.

Default

-fopenmp-declare-target-scalar-defaultmap=default
or /Qopenmp-declare-target-scalar-defaultmap:default

The compiler applies implicit data-mapping/sharing rules according to OpenMP specification.

Description

This option determines which implicit data-mapping/sharing rules are applied for a scalar variable referenced in a TARGET directive, when that scalar variable appears in a DECLARE TARGET directive that has a TO clause.

It tells the compiler to assume that a scalar DECLARE TARGET variable with implicit data-mapping/sharing referenced in a TARGET construct has the same value before the TARGET construct (in the host environment) and at the beginning the target region (in the device environment). This may enable some optimizations in the host code invoking the target region for execution.

The option only affects data-mapping/sharing rules for scalar variables referenced in a TARGET construct that do not appear in one of the TARGET clauses MAP, IS_DEVICE_PTR, or HAS_DEVICE_ADDR.

For more information about implicit data-mapping/sharing rules, see the OpenMP 5.2 specification. For example, see section 5.8.1 in that specification.

IDE Equivalent

None

Alternate Options

None

Examples

Consider the following:

module data
  integer :: N
  !$omp declare target(N)
end module data
...
program main
  use data
  !$omp target teams distribute parallel do
  do i = 1, N
...
  enddo

Specifying -fopenmp-declare-target-scalar-defaultmap=firstprivate (or /Qopenmp-declare-target-scalar-defaultmap:firstprivate) or an explicit "FIRSTPRIVATE(N)" lets the compiler generate efficient host code that issues the most appropriate number of teams and threads to execute the iterations of the DISTRIBUTE PARALLEL DO loop, assuming that N does not change its value between the beginning of the TARGET region and the beginning of the DISTRIBUTE PARALLEL DO region.

If the compiler option (or "FIRSTPRIVATE(N)") is not specified, then the value of N in the host code (before the TARGET construct) may be different from the value of N in the DO statement. To compute the right number of teams/threads on the host, the value of N must be transferred from the device to the host, which may result in a performance penalty.

The option may not behave correctly for all OpenMP programs. In particular, it may behave incorrectly for programs that allow different values of the same DECLARE TARGET scalar variables on entry to TARGET regions.

For example, consider the following:

module data
  integer :: x = 0 ! host 'x' is 0, target 'x' is 0
  !$omp declare target(x)
end module data
program main
  use data
  x = -1

  ! host 'x' is -1, target 'x' is 0
  !$omp target
  x = 1
  !$omp end target

  ! host 'x' is -1, target 'x' is 1
  !$omp target
  print *, 'target: ', x, ' == 1'
  !$omp end target

  !$omp target update from(x)

  ! host 'x' is 1, target 'x' is 1
  print *, 'host: ', x, ' == 1'
end program main

The following is the correct output for the above code:

target: 1 == 1
host: 1 == 1

However, this is the output when option -fopenmp-declare-target-scalar-defaultmap=firstprivate (or /Qopenmp-declare-target-scalar-defaultmap:firstprivate) is specified:

target: -1 == 1
host: 0 == 1

target: -1 == 1

host: 0 == 1

See Also