Observed issues › gcc/gcc-declare-mapper-rejected
gfortran: declare mapper is not accepted ("Unclassifiable OpenMP directive")
Legality: independently confirmed. 2 independent readings find the program legal and the result required. How this is checked
GCC 16.2's Fortran front end does not parse the declare mapper directive ("Unclassifiable OpenMP directive"), so no Fortran program can name a mapper in map, to or from. Its implementation status table says declare mapper has initial support for C and C++ only.
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 | fails another way | fails another way |
| NVHPC 26.9 | n/a | n/a | n/a | n/a | n/a | fails another way | fails another way |
| 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, MI250X GCC 16.2.0, MI300X GCC 16.2.0, MI350X GCC 16.2.0, A100 separate | showsite-gcc--gcc-declare-mapper-rejected.f90:45:9:
45 | !$omp declare mapper(mm: dt :: q) map(to: q%v)
| 1
Error: Unclassifiable OpenMP directive at (1)
site-gcc--gcc-declare-mapper-rejected.f90:68:50:
68 | !$omp target map(to: a) map(from: b) map(mapper(mm), tofrom: s) map(tofrom: host_flag)
| 1
Error: Syntax error in OpenMP variable list at (1) |
| fails another way | NVHPC 25.11, A100 separate NVHPC 25.11, A100 managed NVHPC 26.9, A100 separate NVHPC 26.9, A100 managed | showNVFORTRAN-W-0287-Unrecognized OpenMP directive - declare (site-gcc--gcc-declare-mapper-rejected.f90: 45) NVFORTRAN-S-0034-Syntax error at or near : (site-gcc--gcc-declare-mapper-rejected.f90: 68) 0 inform, 1 warnings, 1 severes, 0 fatal for gen_prog |
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 (79 lines)
! # Finding (GCC 16.2): gfortran does not accept declare mapper; the reproducer is the catalog program omp52-clause-map-mapper
!
! - 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; OMP_TARGET_OFFLOAD=mandatory
! - 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: Unclassifiable OpenMP directive
! - observed: `Error: Unclassifiable OpenMP directive at (1)` at the declare mapper directive, on both GPUs; every Fortran map, to
! and from program with a mapper fails the same way.
! - expected: compiles; `RESULT ran_on_host=0 check=pass`
! - GCC 16.2 documentation (libgomp.texi of the GCC 16.2.0 release tarball, "OpenMP Implementation Status", OpenMP 5.0 table):
! "declare mapper directive": P, "Initial support and for C/C++, only".
! - spec: the declare mapper directive (5.2 §5.8.8 p.162).
! - other families: AFAR runs the program correctly; CCE 21 runs it (CCE 19/20 lose a copy-back after the mapper,
! cce-mapper-next-map-copy-back.f90); NVHPC rejects it.
! - gate and confirmer: 18 cells (9 gcc_g90, 9 gcc_sm80), each confirmed in the gate's four environments (a-d;
! results/gcc/gate-tioga/ and gate-wingtip/ verdicts.jsonl); confirmer verdicts (results/gcc/confirm/batch.gcc_*.jsonl):
! compiler_bug (R11-compile-rejection) 12, unsupported (R11a-newer-form-unclaimed) 6
! - catalog programs (9): omp50-clause-from-mapper, omp50-clause-map-mapper, omp50-clause-to-mapper, omp52-clause-from-mapper,
! omp52-clause-map-mapper, omp52-clause-to-mapper, omp60-clause-from-mapper, omp60-clause-map-mapper, omp60-clause-to-mapper
! - legality: the catalog programs are legal by construction (offload.engine.gen, c_gen and acc_gen
! check every program against the catalog rules and the offload scope as it is built; no
! compiler). GCC is a compiler under test only: never a legality witness, here or for another
! family's case (catalog/machines.yaml under_test_only).
! Generated by compliance.gen (OpenMP 5.2, free-form Fortran). Do not edit.
! id: omp52-clause-map-mapper
! primary atom: omp.clause.map.mapper
! legal: yes
! observable: yes
! ran_on_host: inside the target region of interest
! evidence: copy_mode_only
! needs: none
! std: f2008
! derivation (check=pass): mapper mm maps q%v with map type to; map(mapper(mm), tofrom: s) applies it with the decayed map type:
! mapper to with clause tofrom gives to (5.2 §5.8.8 p.163 (Table 5.3)); so s%v (1) is copied to the device and not back: the device
! writes b(i) = 2*a(i) + s%v = 2*i + 1 = ref(i), then s%v = 7 on the device only; in copy mode the host's s%v stays 1 (the
! copy-mode-only check), under shared storage that check is skipped; the check accepts
program gen_prog
use omp_lib, only: omp_is_initial_device
use, intrinsic :: iso_c_binding, only: c_loc
implicit none
type :: dt
integer :: v
end type dt
!$omp declare mapper(mm: dt :: q) map(to: q%v)
integer, parameter :: n = 64
integer, allocatable, target :: a(:), b(:)
integer :: ref(n)
integer :: i, host_flag
logical :: ok
type(dt) :: s
logical :: pres, shared_mem
integer :: zc(1)
allocate(a(n), b(n))
do i = 1, n
a(i) = i
b(i) = 0
ref(i) = 2*i + 1
end do
host_flag = 1
s%v = 1
pres = .true.
zc = 0
!$omp target map(to: zc)
zc(1) = 1
!$omp end target
shared_mem = zc(1) == 1
!$omp target map(to: a) map(from: b) map(mapper(mm), tofrom: s) map(tofrom: host_flag)
host_flag = merge(1, 0, omp_is_initial_device())
do i = 1, n
b(i) = 2*a(i) + s%v
end do
s%v = 7
!$omp end target
if (.not. shared_mem) pres = pres .and. (s%v == 1)
ok = all(b == ref) .and. pres
print '(a,i0,a,a)', 'RESULT ran_on_host=', host_flag, ' check=', merge('pass', 'fail', ok)
deallocate(a, b)
end program gen_prog
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-gcc--gcc-declare-mapper-rejected.f90:45:9:
45 | !$omp declare mapper(mm: dt :: q) map(to: q%v)
| 1
Error: Unclassifiable OpenMP directive at (1)
site-gcc--gcc-declare-mapper-rejected.f90:68:50:
68 | !$omp target map(to: a) map(from: b) map(mapper(mm), tofrom: s) map(tofrom: host_flag)
| 1
Error: Syntax error in OpenMP variable list 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.8 p.162
OpenMP 5.2 §5.8.8 p.163
Evidence
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