Visible to Intel only — GUID: GUID-B846E956-A5A6-47C8-853D-2B2124423F39
Visible to Intel only — GUID: GUID-B846E956-A5A6-47C8-853D-2B2124423F39
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.
Linux: |
-fopenmp-declare-target-scalar-defaultmap=keyword |
macOS: |
None |
Windows: |
/Qopenmp-declare-target-scalar-defaultmap:keyword |
keyword |
Is the rule to be applied for a scalar variable referenced in a target pragma.TARGET directive.. Possible values are:
|
-fopenmp-declare-target-scalar-defaultmap=default |
The compiler applies implicit data-mapping/sharing rules according to OpenMP specification. |
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.
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