Observed issues › afar-flang-firstprivate-map-two-targets
amdflang: firstprivate(p1) on one target and map(to: p1) on a later target rejected as if on the same construct
Legality: independently confirmed. 2 independent readings find the program legal and the result required. How this is checked
Affected variants
| Compiler | MI300A gfx942 unified memory (XNACK 1) | MI300A gfx942 copy (XNACK 0) | MI250X gfx90a copy (XNACK 0) | MI300X gfx942 copy (XNACK 0) | MI350X gfx950 copy (XNACK 0) | A100 sm_80 separate memory | A100 sm_80 managed memory |
|---|---|---|---|---|---|---|---|
| AFAR 24.3.0 | not supported | not supported | not supported | not supported | not supported | n/a | n/a |
| CCE 19.0.0 | correct | correct | correct | unknown not run | unknown not run | n/a | n/a |
| CCE 20.0.2 | correct | correct | correct | unknown not run | unknown not run | n/a | n/a |
| CCE 21.0.3 | correct | correct | correct | unknown not run | unknown not run | n/a | n/a |
| CCE 21.0.4 | correct | correct | correct | unknown not run | unknown not run | n/a | n/a |
| NVHPC 25.11 | n/a | n/a | n/a | n/a | n/a | correct | correct |
| NVHPC 26.9 | n/a | n/a | n/a | n/a | n/a | correct | correct |
| GCC 16.2.0 | correct | correct | correct | correct | correct | correct | n/a |
"behaves incorrectly" / "not supported": this issue, confirmed in up to four environments (another build directory, another node, a repeat). "fails another way": a different failure, not counted as this issue. "unknown": not run there, or the runs disagree.
Messages
| Result | Compiler and GPU | Message |
|---|---|---|
| not supported | AFAR 24.3.0, MI300A unified AFAR 24.3.0, MI300A copy AFAR 24.3.0, MI250X AFAR 24.3.0, MI300X AFAR 24.3.0, MI350X | showerror: Semantic errors in afar-flang-firstprivate-map-two-targets.f90
afar-flang-firstprivate-map-two-targets.f90:5:29: error: Variable 'p1' may not appear on both MAP and FIRSTPRIVATE clauses on a TARGET construct
!$omp target firstprivate(p1) map(from: a)
^^ |
Reproduce
AFAR 24.3.0, MI300A unified
$AFAR/bin/amdflang -fopenmp --offload-arch=gfx942 -O2 repro.f90 -o repro HSA_XNACK=1 OMP_TARGET_OFFLOAD=mandatory ./repro
CCE 19.0.0, MI300A unified (runs correctly)
module load cce/19.0.0 craype-accel-amd-gfx942 rocm/6.4.3 module unload cray-mpich ftn -fopenmp -O2 repro.f90 -o repro HSA_XNACK=1 OMP_TARGET_OFFLOAD=mandatory ./repro
Program (27 lines)
program p
implicit none
integer :: a(10), i, p1
p1 = 3
!$omp target firstprivate(p1) map(from: a)
do i = 1, 10
a(i) = p1
end do
!$omp end target
!$omp target map(to: p1) map(tofrom: a)
do i = 1, 10
a(i) = a(i) + p1
end do
!$omp end target
print *, 'a(3) =', a(3)
end program p
! spec (requirement): The data environment of each target task is created from the data-sharing and data-mapping
! clauses on that one target construct, so clauses on different target constructs do not interact.
! "The data environment of the target task is created according to the data-sharing and data-mapping attribute clauses
! on the target construct" (5.2 §13.8 p.284 l.19-21)
! spec (requirement): A firstprivate list item on a target construct is initialized from the original list item that
! exists before that construct.
! "In addition, the new list item is initialized from the original list item that exists before the construct." (5.2
! §5.4.4 p.112 l.11-12)
! spec (this program): p1 is firstprivate on the first target construct and appears in map(to:) only on the second,
! separate target construct, so no list item has two attributes on one construct; amdflang rejects the second target
! as if both clauses were on the same construct.
Something to add? Dispute its legality · Report it fixed in a newer release · Report a mistake on this page
Expected and observed
Expected
a(3) = 6
Observed where it behaves incorrectly
error: Semantic errors in afar-flang-firstprivate-map-two-targets.f90
afar-flang-firstprivate-map-two-targets.f90:5:29: error: Variable 'p1' may not appear on both MAP and FIRSTPRIVATE clauses on a TARGET construct
!$omp target firstprivate(p1) map(from: a)
^^What the specification requires
The specification text this program relies on and the compiler is expected to support.
OpenMP 5.2 §13.8 p.284 l.19-21
The data environment of the target task is created according to the data-sharing and data-mapping attribute clauses on the target construct
OpenMP 5.2 §5.4.4 p.112 l.11-12
In addition, the new list item is initialized from the original list item that exists before the construct.
Evidence
Same compiler, one change
- map(to: p1) instead of firstprivate(p1) on the first target: AFAR 24.3.0: correct; CCE 19.0.0: correct; CCE 20.0.2: correct; CCE 21.0.3: correct; CCE 21.0.4: correct
Control program
program p implicit none integer :: a(10), i, p1 p1 = 3 !$omp target map(to: p1) map(from: a) do i = 1, 10 a(i) = p1 end do !$omp end target !$omp target map(to: p1) map(tofrom: a) do i = 1, 10 a(i) = a(i) + p1 end do !$omp end target print *, 'a(3) =', a(3) end program p
Other compilers run it correctly
CCE 19.0.0, CCE 20.0.2, CCE 21.0.3, CCE 21.0.4, NVHPC 25.11, NVHPC 26.9, GCC 16.2.0