OffTarget

Observed issues › nvhpc-defaultmap-firstprivate-explicit-map

Appears to behave incorrectlyWrong answer · Fortran · OpenMP · Open · regression

Defaultmap(firstprivate) drops the copy-back of explicitly mapped variables

Legality: independently confirmed. 2 independent readings find the program legal and the result 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.0fails another wayfails another wayunknown
not run
fails another wayfails another wayn/an/a
CCE 19.0.0behaves incorrectlybehaves incorrectlyunknown
not run
unknown
not run
unknown
not run
n/an/a
CCE 20.0.2correctcorrectunknown
not run
unknown
not run
unknown
not run
n/an/a
CCE 21.0.3behaves incorrectlybehaves incorrectlyunknown
not run
unknown
not run
unknown
not run
n/an/a
CCE 21.0.4behaves incorrectlybehaves incorrectlyunknown
not run
unknown
not run
unknown
not run
n/an/a
NVHPC 25.11n/an/an/an/an/abehaves incorrectlybehaves incorrectly
NVHPC 26.9n/an/an/an/an/abehaves incorrectlybehaves incorrectly
GCC 16.2.0correctcorrectcorrectcorrectcorrectcorrectn/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
behaves incorrectlyCCE 19.0.0, MI300A unified
CCE 19.0.0, MI300A copy
show
 sum 0 host_flag 0
behaves incorrectlyCCE 21.0.3, MI300A unified
CCE 21.0.3, MI300A copy
CCE 21.0.4, MI300A unified
CCE 21.0.4, MI300A copy
show
 sum 2144 host_flag 1
behaves incorrectlyNVHPC 25.11, A100 separate
NVHPC 25.11, A100 managed
NVHPC 26.9, A100 separate
NVHPC 26.9, A100 managed
show
 sum            0 host_flag            1
fails another wayAFAR 24.3.0, MI300A unified
AFAR 24.3.0, MI300A copy
AFAR 24.3.0, MI300X
AFAR 24.3.0, MI350X
show
error: loc("nvhpc-defaultmap-firstprivate-explicit-map.f90":8:9): /__w/TheRock/TheRock/compiler/amd-llvm/flang/lib/Lower/OpenMP/OpenMP.cpp:1797: not yet implemented: Firstprivate is currently unsuppor
LLVM ERROR: aborting

Reproduce

CCE 19.0.0, MI300A unified

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

CCE 21.0.3, MI300A unified

module load cce/21.0.3 craype-accel-amd-gfx942 rocm/7.2.0
module unload cray-mpich
ftn -fopenmp -O2 repro.f90 -o repro
HSA_XNACK=1 OMP_TARGET_OFFLOAD=mandatory ./repro

CCE 21.0.4, MI300A unified

module load cce/21.0.4 craype-accel-amd-gfx942 rocm/7.2.0
module unload cray-mpich
ftn -fopenmp -O2 repro.f90 -o repro
HSA_XNACK=1 OMP_TARGET_OFFLOAD=mandatory ./repro

NVHPC 25.11, A100 separate

export LD_LIBRARY_PATH=$NVHPC_25_11/compilers/lib
nvfortran -mp=gpu -gpu=cc80 -gpu=mem:separate -O2 repro.f90 -o repro
OMP_TARGET_OFFLOAD=mandatory ./repro

NVHPC 26.9, A100 separate

export LD_LIBRARY_PATH=$NVHPC_26_9/compilers/lib
nvfortran -mp=gpu -gpu=cc80 -gpu=mem:separate -O2 repro.f90 -o repro
OMP_TARGET_OFFLOAD=mandatory ./repro

GCC 16.2.0, MI300A unified (runs correctly)

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
Program (40 lines)
! NVHPC 25.11, NVIDIA A100 80GB PCIe (wingtip, sm_80), both memory modes:
! with defaultmap(firstprivate) on a target construct, the arrays and
! scalars the construct maps EXPLICITLY (map(from: b), map(tofrom:
! host_flag)) are not copied back: the host sees b and host_flag unchanged.
! Spec: "The defaultmap clause determines the implicit data-mapping or
! data-sharing attribute of certain variables" (5.2 §5.8.7 p.161); "When
! specified, explicit data-environment attribute clauses on target
! directives determine the attributes" of the variables they name (5.2
! §5.8.1 p.148).
! Vendor: "The defaultmap clause is supported using OpenMP 5.0 semantics"
! (HPC Compilers User's Guide 25.11 §7.4, 2.12.5).
! Expected: "sum 2144 host_flag 0".
! Observed (2026-10-24, nvfortran 25.11-0, -O2, OMP_TARGET_OFFLOAD=
! mandatory, two runs, the same): "sum 0 host_flag 1".
! Found by the catalog (omp50/52/60-clause-defaultmap-firstprivate: their
! cells read ran_on_host=1 check=fail; confirmer R20-runtime-bug); reduced
! by hand.
! NVHPC 26.9 (26.9-0, the latest release; rerun 2026-10-24 on wingtip with
! the same flags): still present -- the same: "sum 0 host_flag 1", both modes.
! Fix (2026-10-24): rerun on 25.11 and 26.9 in both memory modes,
! each with its own runtime libraries (LD_LIBRARY_PATH = the release's
! compilers/lib; the first 26.9 runs had loaded 25.11's): still present
! on both releases, the same output.
! NVHPC: nvfortran -mp=gpu -gpu=cc80 -gpu=mem:separate -O2
! Run:   OMP_TARGET_OFFLOAD=mandatory ./a.out
program p
  use omp_lib, only: omp_is_initial_device
  implicit none
  integer :: b(64), host_flag, i, c
  b = 0
  host_flag = 1
  c = 1
  !$omp target map(from: b) map(tofrom: host_flag) defaultmap(firstprivate)
    host_flag = merge(1, 0, omp_is_initial_device())
    do i = 1, 64
      b(i) = i + c
    end do
  !$omp end target
  print *, 'sum', sum(b), 'host_flag', host_flag
end program p

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

Expected

sum 2144 host_flag 0

Observed where it behaves incorrectly

 sum 0 host_flag 0

What the specification requires

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

OpenMP 5.2 §5.8.7 p.161

The defaultmap clause determines the implicit data-mapping or data-sharing attribute of certain variables

OpenMP 5.2 §5.8.1 p.148

Evidence

Same compiler, one change

  • defaultmap(firstprivate) removed: 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; NVHPC 25.11: correct; NVHPC 26.9: correct
    Control program
    program p
      use omp_lib, only: omp_is_initial_device
      implicit none
      integer :: b(64), host_flag, i, c
      b = 0
      host_flag = 1
      c = 1
      !$omp target map(from: b) map(tofrom: host_flag)
        host_flag = merge(1, 0, omp_is_initial_device())
        do i = 1, 64
          b(i) = i + c
        end do
      !$omp end target
      print *, 'sum', sum(b), 'host_flag', host_flag
    end program p
    

Other compilers run it correctly

GCC 16.2.0