Observed issues › harvest/gcc-same-item-two-maps-rejected
The same variable in two map clauses of one target construct is rejected
Legality: not independently confirmed. no independent review yet How this is checked
Same issue as harvest/gcc-c-same-item-two-maps-rejected; this program is another reproducer of it.
OpenMP 5.2 allows a list item in more than one map clause of one directive. GCC 16.2 rejects a target construct with map(alloc: x) map(tofrom: x) for both offload targets; its documentation does not list the gap.
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 | correct | correct | unknown not run | correct | correct | n/a | n/a |
| CCE 19.0.0 | correct | correct | unknown not run | unknown not run | unknown not run | n/a | n/a |
| CCE 20.0.2 | correct | correct | unknown not run | unknown not run | unknown not run | n/a | n/a |
| CCE 21.0.3 | correct | correct | unknown not run | unknown not run | unknown not run | n/a | n/a |
| CCE 21.0.4 | correct | correct | unknown not run | 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 | not supported | not supported | not supported | not supported | not supported | not supported | 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 | GCC 16.2.0, MI300A unified GCC 16.2.0, MI300A copy GCC 16.2.0, MI300X GCC 16.2.0, MI350X | showsite-harvest--gcc-same-item-two-maps-rejected.f90:33:42:
33 | !$omp target map(alloc: x) map(tofrom: x) map(tofrom: host_flag)
| 1
Error: Symbol ‘x’ present on multiple clauses at (1) |
| not supported | GCC 16.2.0, MI250X GCC 16.2.0, A100 separate | showsite-harvest--gcc-same-item-two-maps-rejected.f90:27:42:
27 | !$omp target map(alloc: x) map(tofrom: x) map(tofrom: host_flag)
| 1
Error: Symbol ‘x’ present on multiple clauses at (1) |
Reproduce
GCC 16.2.0, MI300A unified
export LD_LIBRARY_PATH=$GCC_16_2/lib64:/opt/rocm-7.2.1/lib $GCC_16_2/bin/gfortran -fopenmp -foffload=amdgcn-amdhsa -foffload-options=amdgcn-amdhsa=-march=gfx942 -O2 repro.f90 -o repro HSA_XNACK=1 OMP_TARGET_OFFLOAD=mandatory ./repro
GCC 16.2.0, A100 separate
export PATH=/usr/local/cuda/bin:$PATH export LD_LIBRARY_PATH=$GCC_16_2/lib64 $GCC_16_2/bin/gfortran -fopenmp -foffload=nvptx-none -foffload-options=nvptx-none=-march=sm_80 -foffload-options=nvptx-none=-latomic -O2 repro.f90 -o repro OMP_TARGET_OFFLOAD=mandatory ./repro
AFAR 24.3.0, MI300A unified (runs correctly)
$AFAR/bin/amdflang -fopenmp --offload-arch=gfx942 -O2 repro.f90 -o repro HSA_XNACK=1 OMP_TARGET_OFFLOAD=mandatory ./repro
Program (39 lines)
! # Finding (GCC 16.2, harvests): the same variable in two map clauses of one target construct is rejected
!
! - toolchains: gcc_g90 (GCC 16.2.0, AMD Instinct MI250X gfx90a, Tioga) and gcc_sm80 (GCC 16.2.0, NVIDIA A100 sm_80, wingtip);
! separate memory only; -O2
! - build: gfortran -fopenmp -foffload=amdgcn-amdhsa -foffload-options=amdgcn-amdhsa=-march=gfx90a -O2 (gcc_g90);
! -foffload=nvptx-none -foffload-options=nvptx-none=-march=sm_80 -foffload-options=nvptx-none=-latomic -O2 (gcc_sm80)
! - failure: rejected: Error: Symbol 'x' present on multiple clauses at (1)
! - observed: `Error: Symbol 'x' present on multiple clauses at (1)` at the target directive, on both targets
! - expected: compiles; prints `x= 112` and `RESULT ran_on_host=0 check=pass`
! - rule: "A list item may appear more than once in the map clauses that are specified on the same directive" (5.2 §5.8.3 p.151
! l.14-15).
! - same-compiler control (compiles; correct, gcc_sm80: mandatory pass 5 of 5; unset pass 5 of 5; gcc_g90: mandatory pass 5 of 5;
! unset pass 5 of 5 (results/parity/<machine>/<tc>/probes.jsonl)): the variable in one map clause, map(tofrom: x)
! (controls/gcc-same-item-two-maps-control.f90).
! - GCC's documentation: no row of libgomp.texi's tables names it (undocumented). GCC's own development testsuite has programs of
! this form (libgomp target-map-multi-*, harvested from gcc master 9e5dc385 into harvest2), so later GCC accepts it. On a target
! data construct the same form ends in an internal compiler error instead (gcc-c-target-data-two-maps-ice.c).
! - other families: AFAR, CCE 19/20/21/21.0.4 and NVHPC 25.11/26.9 compile and run this file correctly (site matrix); on the
! harvested programs AFAR and CCE are correct, NVHPC fails them another way. The site's finding matrix runs this file on every
! compiler.
! - harvested programs (8 cells (5 gcc_g90, 3 gcc_sm80); gate: confirmed 8; confirmer: compiler_bug (R11-compile-rejection) 6, gate
! only 2): h2-gomp-f-target-map-multi-1, h2-gomp-f-target-map-multi-4, h2-gomp-f-target-map-multi-5, sections-omp-1024-1,
! sections-omp-64-1
! - legality: the pre-run check (offload.engine.prerun.check: the rules and AFAR's front end, two witnesses) accepts the harvested
! programs. GCC is a compiler under test only and never a legality witness.
program map_same_item_twice
use omp_lib, only: omp_is_initial_device
implicit none
integer :: x, host_flag
x = 111
host_flag = 1
! the same list item in two map clauses of one construct
!$omp target map(alloc: x) map(tofrom: x) map(tofrom: host_flag)
host_flag = merge(1, 0, omp_is_initial_device())
x = x + 1
!$omp end target
print '(a,i0)', 'x= ', x
print '(a,i0,a,a)', 'RESULT ran_on_host=', host_flag, ' check=', merge('pass', 'fail', x == 112)
end program map_same_item_twice
Something to add? Dispute its legality · Report it fixed in a newer release · Report a mistake on this page
Expected and observed
Expected
check=pass
Observed where it behaves incorrectly
site-harvest--gcc-same-item-two-maps-rejected.f90:33:42:
33 | !$omp target map(alloc: x) map(tofrom: x) map(tofrom: host_flag)
| 1
Error: Symbol ‘x’ present on multiple clauses at (1)What the specification requires
The specification text this program relies on and the compiler is expected to support.
OpenMP 5.2 §5.8.3 p.151 l.14-15
A list item may appear more than once in the map clauses that are specified on the same directive
Evidence
Same compiler, one change
- the variable in one map clause, map(tofrom: x): not run yet
Control program
! Control of harvest/gcc-same-item-two-maps-rejected.f90: the variable in one map clause, map(tofrom: x) (compiles; ! correct on gcc_g90 and gcc_sm80). program map_same_item_once use omp_lib, only: omp_is_initial_device implicit none integer :: x, host_flag x = 111 host_flag = 1 ! control: the list item in one map clause !$omp target map(tofrom: x) map(tofrom: host_flag) host_flag = merge(1, 0, omp_is_initial_device()) x = x + 1 !$omp end target print '(a,i0)', 'x= ', x print '(a,i0,a,a)', 'RESULT ran_on_host=', host_flag, ' check=', merge('pass', 'fail', x == 112) end program map_same_item_once
Other compilers run it correctly
AFAR 24.3.0, CCE 19.0.0, CCE 20.0.2, CCE 21.0.3, CCE 21.0.4, NVHPC 25.11, NVHPC 26.9