OffTarget

Observed issues › catalog/cce20-map-self-rejected

Appears not to supportRefused at compile time · Fortran · OpenMP · Changed in 21.0.3

ftn 20 rejects the self map-type modifier (OpenMP 6.0)

Legality: contested. An independent adjudicating reading finds the result not required: Both readings agree. In 6.0 self is a map-type-modifier and map-type is optional (default), so map(self: a) is syntactically valid and the compiler error reflects the pre-6.0 rule. A self map causes runtime error termination when the original item is not accessible from the target device and cannot be made so. With separate memory the allocatable a may not be accessible, so successful execution is not required. How this is checked

Affected variants

CompilerMI300A 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.0correctcorrectcorrectcorrectcorrectn/an/a
CCE 19.0.0fails another wayfails another wayfails another wayunknown
not run
unknown
not run
n/an/a
CCE 20.0.2not supportednot supportednot supportedunknown
not run
unknown
not run
n/an/a
CCE 21.0.3correctfails another wayfails another wayunknown
not run
unknown
not run
n/an/a
CCE 21.0.4correctfails another wayfails another wayunknown
not run
unknown
not run
n/an/a
NVHPC 25.11n/an/an/an/an/afails another wayfails another way
NVHPC 26.9n/an/an/an/an/afails another wayfails another way
GCC 16.2.0fails another wayfails another wayfails another wayfails another wayfails another wayfails another wayn/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

ResultCompiler and GPUMessage
not supportedCCE 20.0.2, MI300A unified
CCE 20.0.2, MI300A copy
CCE 20.0.2, MI250X
show
Warning:
 Headers and libraries from cray-libsci/25.09.0 will be ignored because depends on PE_MPICH which is unavailable..
  !$omp target map(self: a) map(from: b) map(tofrom: host_flag)
                   ^                                            
ftn-810 ftn: ERROR GEN_PROG, File = cce20-map-self-rejected.f90, Line = 16, Column = 20 
  On the OpenMP map clause, if a map-type-modifier is specified, a map-type must also be specified.
Cray Fortran : 25 source lines
Cray Fortran : 1 errors, 0 warnings, 0 other messages, 0 ansi
fails another wayCCE 19.0.0, MI300A unified
CCE 19.0.0, MI300A copy
CCE 19.0.0, MI250X
show
Warning:
 Headers and libraries from cray-libsci/25.03.0 will be ignored because depends on PE_MPICH which is unavailable..
  !$omp target map(self: a) map(from: b) map(tofrom: host_flag)
                   ^                                            
ftn-336 ftn: ERROR GEN_PROG, File = cce20-map-self-rejected.f90, Line = 16, Column = 20 
  Map-type specifier must be TO, FROM, TOFROM or ALLOC for directive !$OMP TARGET.
Cray Fortran : 25 source lines
Cray Fortran : 1 errors, 0 warnings, 0 other messages, 0 ansi
fails another wayCCE 21.0.3, MI300A copy
CCE 21.0.3, MI250X
CCE 21.0.4, MI300A copy
CCE 21.0.4, MI250X
show
ACC: libcrayacc/acc_runtime.c:896 CRAY_ACC_ERROR - Requested self map cannot be satisfied
fails another wayNVHPC 25.11, A100 separate
NVHPC 25.11, A100 managed
NVHPC 26.9, A100 separate
NVHPC 26.9, A100 managed
show
NVFORTRAN-S-1206-OpenMP GPU - 'target' is used with map-type 'self' that is other than 'to', 'from', 'tofrom',or 'alloc' (cce20-map-self-rejected.f90: 16)
NVFORTRAN-S-0155-map-type must be specified.  (cce20-map-self-rejected.f90: 16)
  0 inform,   0 warnings,   2 severes, 0 fatal for gen_prog
fails another wayGCC 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
show
cce20-map-self-rejected.f90:16:24:
   16 |   !$omp target map(self: a) map(from: b) map(tofrom: host_flag)
      |                        1
Error: Syntax error in OpenMP variable list at (1)
cce20-map-self-rejected.f90:21:18:
   21 |   !$omp end target
      |                  1
Error: Unexpected !$OMP END TARGET statement at (1)

Reproduce

CCE 20.0.2, MI300A unified

module load cce/20.0.2 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

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 (60 lines)
! # Draft finding: omp60-clause-map-self on cce20
!
! - compiler: cce20
! - toolchain: cce20; arch: gfx942; machine: tuolumne; memory mode: unified; opt: -O2
! - program: catalog omp60-clause-map-self (f90, version 60, sha256 bae4dcecdf58e771)
! - expected: None (None; )
! - actual: rejected  (diagnostic: ftn-810 ftn: ERROR GEN_PROG, File = ../../omp60-clause-map-self.f90, Line = 26, Column = 20 | On
!   the OpenMP map clause, if a map-type-modifier is specified, a map-type must also be specifi)
! - verdict: compiler_bug by rule R11-compile-rejection: a legal program the compiler rejects with a diagnostic (or whose link fails
!   on symbols the compiler's own code needs, or whose compile does not finish) while another compiler family compiles it
! - reason: 
! - citations: RUL-COMPILE-TIME (rulings.md)
! - legality: legal (legal by construction: offload.engine.gen / c_gen / acc_gen check every program against the catalog rules
!   and the
!   offload scope as it is built (no compiler))
! - witnesses: none
! - withdrawn: none
!
! Generated by compliance.gen (OpenMP 6.0, free-form Fortran). Do not edit.
! id: omp60-clause-map-self
! primary atom: omp.clause.map.self
! legal: yes
! observable: no (unverified: the check covers the device kernel, not the atom)
! ran_on_host: inside the target region of interest
! evidence: unverified
! needs: zero_copy
! std: f2008
! unverified (oracle_not_written): re-categorised (was implementation_defined): a self map is 'a mapping
!   operation for
! which the corresponding storage is the same as its original storage' (6.0 Glossary p.95), and a map-entering self map of storage
! the device cannot access must end in runtime error termination (6.0 §7.9.6 p.285), so the spec fixes the behaviour: in copy mode
! (HSA_XNACK=0) a device write of a self-mapped a must be seen by the host, or the run must stop; without self the write stays on
! the device. That check is not written: the program needs zero-copy memory as generated, and AFAR at HSA_XNACK=0 copies even with
! self (probe 2026-10-18: map(self, to: a) with a device write of a leaves the host's a unchanged), which the check would report as
! a wrong answer
program gen_prog
  use omp_lib, only: omp_is_initial_device
  implicit none
  integer, parameter :: n = 64
  integer, allocatable, target :: a(:), b(:)
  integer :: ref(n)
  integer :: i, host_flag
  logical :: ok
  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
  !$omp target map(self: a) map(from: b) map(tofrom: host_flag)
    host_flag = merge(1, 0, omp_is_initial_device())
    do i = 1, n
      b(i) = 2*a(i) + 1
    end do
  !$omp end target
  ok = all(b == ref)
  print '(a,i0,a,a)', 'RESULT ran_on_host=', host_flag, ' check=', merge('pass', 'fail', ok)
  deallocate(a, b)
end program gen_prog

Source in the repository

Something to add? Dispute its legality · Report it fixed in a newer release · Report a mistake on this page

Expected and observed

Observed where it behaves incorrectly

Warning:
 Headers and libraries from cray-libsci/25.09.0 will be ignored because depends on PE_MPICH which is unavailable..
  !$omp target map(self: a) map(from: b) map(tofrom: host_flag)
                   ^                                            
ftn-810 ftn: ERROR GEN_PROG, File = cce20-map-self-rejected.f90, Line = 16, Column = 20 
  On the OpenMP map clause, if a map-type-modifier is specified, a map-type must also be specified.
Cray Fortran : 25 source lines
Cray Fortran : 1 errors, 0 warnings, 0 other messages, 0 ansi

What the specification requires

The specification text this program relies on and the compiler is expected to support.

OpenMP 6.0 §7.9.6 p.285

Evidence

Same compiler, one change

  • map(to: a) instead of map(self: a): 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 gen_prog
      use omp_lib, only: omp_is_initial_device
      implicit none
      integer, parameter :: n = 64
      integer, allocatable, target :: a(:), b(:)
      integer :: ref(n)
      integer :: i, host_flag
      logical :: ok
      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
      !$omp target map(to: a) map(from: b) map(tofrom: host_flag)
        host_flag = merge(1, 0, omp_is_initial_device())
        do i = 1, n
          b(i) = 2*a(i) + 1
        end do
      !$omp end target
      ok = all(b == ref)
      print '(a,i0,a,a)', 'RESULT ran_on_host=', host_flag, ' check=', merge('pass', 'fail', ok)
      deallocate(a, b)
    end program gen_prog
    

Other compilers run it correctly

AFAR 24.3.0