OffTarget

Observed issues › harvest/nvhpc-named-constant-array-declare-target-routine-rejected

Appears not to supportRefused at compile time · Fortran · OpenMP · Open

nvfortran rejects a module's named-constant array referenced in a declare target routine

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.0correctcorrectunknown
not run
correctcorrectn/an/a
CCE 19.0.0fails another wayfails another wayunknown
not run
unknown
not run
unknown
not run
n/an/a
CCE 20.0.2fails another wayfails another wayunknown
not run
unknown
not run
unknown
not run
n/an/a
CCE 21.0.3fails another wayfails another wayunknown
not run
unknown
not run
unknown
not run
n/an/a
CCE 21.0.4fails another wayfails another wayunknown
not run
unknown
not run
unknown
not run
n/an/a
NVHPC 25.11n/an/an/an/an/anot supportednot supported
NVHPC 26.9n/an/an/an/an/anot supportednot supported
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 supportedNVHPC 25.11, A100 separate
NVHPC 25.11, A100 managed
NVHPC 26.9, A100 separate
NVHPC 26.9, A100 managed
show
NVFORTRAN-W-0016-Identifier, struct_STATICS2_261a11241b5c231b0235041019665d0f3d03066c58552f0c107d140b5a3847183b0748204446231059341207582a411c7807043351513644063f02105d25565427160f24554027..., truncate
NVFORTRAN-W-0016-Identifier, struct_BSS2_261a11241b5c231b0235041019665d0f3d03066c58552f0c107d140b5a3847183b0748204446231059341207582a411c7807043351513644063f02105d25565427160f245540270d5a..., truncate
NVFORTRAN-W-0016-Identifier, struct_STATICS3_261a11241b5c231b0235041019665d0f3d03066c58552f0c107d140b5a3847183b0748204446231059341207582a411c7807043351513644063f02105d25565427160f24554027..., truncate
NVFORTRAN-W-0016-Identifier, struct_BSS3_261a11241b5c231b0235041019665d0f3d03066c58552f0c107d140b5a3847183b0748204446231059341207582a411c7807043351513644063f02105d25565427160f245540270d5a..., truncate
NVFORTRAN-W-0016-Identifier, struct_STATICS1_261a11241b5c231b0235041019665d0f3d03066c58552f0c107d140b5a3847183b0748204446231059341207582a411c7807043351513644063f02105d25565427160f24554027..., truncate
NVFORTRAN-W-0016-Identifier, struct_BSS1_261a11241b5c231b0235041019665d0f3d03066c58552f0c107d140b5a3847183b0748204446231059341207582a411c7807043351513644063f02105d25565427160f245540270d5a..., truncate
  0 inform,   2 warnings,   0 severes, 0 fatal for vpa_m
NVFORTRAN-W-0016-Identifier, struct_STATICS2_261a11241b5c231b0235041019665d0f3d03066c58552f0c107d140b5a3847183b0748204446231059341207582a411c7807043351513644063f02105d25565427160f24554027..., truncate
fails another wayCCE 19.0.0, MI300A unified
CCE 19.0.0, MI300A copy
show
Warning:
 Headers and libraries from cray-libsci/25.03.0 will be ignored because depends on PE_MPICH which is unavailable..
    x = c(i)
ftn-7066 ftn: ERROR PICK, File = site-harvest--nvhpc-named-constant-array-declare-target-routine-rejected.f90, Line = 39 
  Unsupported accelerator code error: Global in accelerator routine without declare -- c
ftn-7066 ftn: ERROR PICK$VPA_M__CCE$OMP_REDUN_CLONE, File = site-harvest--nvhpc-named-constant-array-declare-target-routine-rejected.f90, Line = 39 
  Unsupported accelerator code error: Global in accelerator routine without declare -- c
Cray Fortran : 63 source lines
fails another wayCCE 20.0.2, MI300A unified
CCE 20.0.2, MI300A copy
show
Warning:
 Headers and libraries from cray-libsci/25.09.0 will be ignored because depends on PE_MPICH which is unavailable..
    x = c(i)
ftn-7066 ftn: ERROR PICK, File = site-harvest--nvhpc-named-constant-array-declare-target-routine-rejected.f90, Line = 39 
  Unsupported accelerator code error: Global in accelerator routine without declare -- c
ftn-7066 ftn: ERROR PICK$VPA_M__CCE$OMP_REDUN_CLONE, File = site-harvest--nvhpc-named-constant-array-declare-target-routine-rejected.f90, Line = 39 
  Unsupported accelerator code error: Global in accelerator routine without declare -- c
Cray Fortran : 63 source lines
fails another wayCCE 21.0.3, MI300A unified
CCE 21.0.3, MI300A copy
CCE 21.0.4, MI300A unified
CCE 21.0.4, MI300A copy
show
Warning:
 Headers and libraries from cray-libsci/26.03.0 will be ignored because depends on PE_MPICH which is unavailable..
    x = c(i)
ftn-7066 ftn: ERROR PICK, File = site-harvest--nvhpc-named-constant-array-declare-target-routine-rejected.f90, Line = 39 
  Unsupported accelerator code error: Global in accelerator routine without declare -- c
ftn-7066 ftn: ERROR PICK$VPA_M__CCE$OMP_REDUN_CLONE, File = site-harvest--nvhpc-named-constant-array-declare-target-routine-rejected.f90, Line = 39 
  Unsupported accelerator code error: Global in accelerator routine without declare -- c
Cray Fortran : 63 source lines
fails another wayGCC 16.2.0, MI300A unified
GCC 16.2.0, MI300A copy
show
site-harvest--nvhpc-named-constant-array-declare-target-routine-rejected.f90:32:25: error: variable ‘c’ has been referenced in offloaded code but hasn’t been marked to be included in the offloaded cod
   32 |   real(8), parameter :: c(2) = [1.5d0, 2.5d0]
      |                         ^
lto1: fatal error: errors during merging of translation units
compilation terminated.
gcn mkoffload: fatal error: <home>/gcc-16.2/bin/x86_64-pc-linux-gnu-accel-amdgcn-amdhsa-gcc returned 1 exit status
compilation terminated.
lto-wrapper: fatal error: <home>/gcc-16.2/libexec/gcc/x86_64-pc-linux-gnu/16.2.0//accel/amdgcn-amdhsa/mkoffload returned 1 exit status
fails another wayGCC 16.2.0, MI250X
show
site-harvest--nvhpc-named-constant-array-declare-target-routine-rejected.f90:33:25: error: variable ‘c’ has been referenced in offloaded code but hasn’t been marked to be included in the offloaded cod
   33 |   real(8), parameter :: c(2) = [1.5d0, 2.5d0]
      |                         ^
lto1: fatal error: errors during merging of translation units
compilation terminated.
gcn mkoffload: fatal error: <home>/gcc-16.2/bin/x86_64-pc-linux-gnu-accel-amdgcn-amdhsa-gcc returned 1 exit status
compilation terminated.
lto-wrapper: fatal error: <home>/gcc-16.2/libexec/gcc/x86_64-pc-linux-gnu/16.2.0//accel/amdgcn-amdhsa/mkoffload returned 1 exit status
fails another wayGCC 16.2.0, MI300X
GCC 16.2.0, MI350X
show
site-harvest--nvhpc-named-constant-array-declare-target-routine-rejected.f90:32:25: error: variable ‘c’ has been referenced in offloaded code but hasn’t been marked to be included in the offloaded cod
   32 |   real(8), parameter :: c(2) = [1.5d0, 2.5d0]
      |                         ^
lto1: fatal error: errors during merging of translation units
compilation terminated.
gcn mkoffload: fatal error: <home>/<user>/gcc-16.2/bin/x86_64-pc-linux-gnu-accel-amdgcn-amdhsa-gcc returned 1 exit status
compilation terminated.
lto-wrapper: fatal error: <home>/<user>/gcc-16.2/libexec/gcc/x86_64-pc-linux-gnu/16.2.0//accel/amdgcn-amdhsa/mkoffload returned 1 exit status
fails another wayGCC 16.2.0, A100 separate
show
site-harvest--nvhpc-named-constant-array-declare-target-routine-rejected.f90:33:25: error: variable ‘c’ has been referenced in offloaded code but hasn’t been marked to be included in the offloaded cod
   33 |   real(8), parameter :: c(2) = [1.5d0, 2.5d0]
      |                         ^
lto1: fatal error: errors during merging of translation units
compilation terminated.
nvptx mkoffload: fatal error: <home>/gcc-16.2/bin/x86_64-pc-linux-gnu-accel-nvptx-none-gcc returned 1 exit status
compilation terminated.
lto-wrapper: fatal error: <home>/gcc-16.2/libexec/gcc/x86_64-pc-linux-gnu/16.2.0//accel/nvptx-none/mkoffload returned 1 exit status

Reproduce

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

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 (62 lines)
! # Finding (known-issues harvest): NVHPC rejects a module's named-constant array
!   referenced in an OpenMP declare target routine
!
! - source: holdout (a case of the known-issues harvest, held out); this file is the
!   minimal form (data/reports/harvest-known/v-param-array-routine.f90)
! - compilers: NVHPC nvfortran 25.11 and 26.9, -mp=gpu -gpu=cc80 (separate and managed memory)
! - expected: the program compiles and prints RESULT ... check=pass: pick returns c(i), a
!   module named constant [1.5, 2.5]
! - actual: "NVFORTRAN-S-1079-Module variables used in omp target routine need to be in omp
!   declare target() - c$ac" (the named constant read as a module variable), both releases,
!   both memory modes
! - control (same compiler): passes with a scalar named constant in the routine
!   (c-param-scalar-routine.f90), with the array a named constant of the routine itself
!   (c-param-array-local.f90), and with the array indexed in the target region itself
!   (c-param-array-region-only.f90); all in data/reports/harvest-known/
! - other families: AFAR compiles and runs it (check=pass); CCE 19/20/21 reject it too
!   (harvest/cce-named-constant-array-declare-target-routine-rejected.f90)
! - legality: Fortran named constants are not variables; OpenMP 5.2's declare target
!   requirement covers variables only: "A variable referenced in a target region but not the
!   target construct that is not declared in the target region must appear in a declare target
!   directive" (§13.8 p.286 l.31-32), and named constants are predetermined shared (§5.1.1 p.98
!   l.11: "Assumed-size arrays and named constants are shared"); a named constant is a list
!   item only "in clauses where it is explicitly allowed" (§3.2.1 p.61 l.10), and declare
!   target's clauses do not name it. The pre-run check (rules and the AFAR front end) accepts the
!   program
! - the OpenACC form (routine seq; hk-015) compiles and runs on NVHPC
! - MFC's documented nvfortran 23.11/24.1 fort2 crash on a parameter array passed into a
!   declare-target routine (hk-005) no longer reproduces: hk-005 compiles and runs on 25.11/26.9
! - evidence: results/harvest-known/main.wingtip (gate: confirmed), results/harvest-known/probes.wingtip.jsonl
module vpa_m
  implicit none
  real(8), parameter :: c(2) = [1.5d0, 2.5d0]
contains
  subroutine pick(i, x)
    !$omp declare target
    integer, intent(in) :: i
    real(8), intent(out) :: x
    x = c(i)
  end subroutine pick
end module vpa_m

program vpa
  use omp_lib
  use vpa_m
  implicit none
  integer :: k, bad, hk_host
  real(8) :: r(100)
  r = 0
  !$omp target teams distribute parallel do map(from: r)
  do k = 1, 100
    call pick(1 + mod(k, 2), r(k))
  end do
  bad = 0
  do k = 1, 100
    if (r(k) /= c(1 + mod(k, 2))) bad = bad + 1
  end do
  hk_host = 1
  !$omp target map(tofrom: hk_host)
  if (.not. omp_is_initial_device()) hk_host = 0
  !$omp end target
  print '(a,i0,a,a)', 'RESULT ran_on_host=', hk_host, ' check=', merge('pass', 'fail', bad == 0)
end program vpa

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

check=pass

Observed where it behaves incorrectly

NVFORTRAN-W-0016-Identifier, struct_STATICS2_261a11241b5c231b0235041019665d0f3d03066c58552f0c107d140b5a3847183b0748204446231059341207582a411c7807043351513644063f02105d25565427160f24554027..., truncate
NVFORTRAN-W-0016-Identifier, struct_BSS2_261a11241b5c231b0235041019665d0f3d03066c58552f0c107d140b5a3847183b0748204446231059341207582a411c7807043351513644063f02105d25565427160f245540270d5a..., truncate
NVFORTRAN-W-0016-Identifier, struct_STATICS3_261a11241b5c231b0235041019665d0f3d03066c58552f0c107d140b5a3847183b0748204446231059341207582a411c7807043351513644063f02105d25565427160f24554027..., truncate
NVFORTRAN-W-0016-Identifier, struct_BSS3_261a11241b5c231b0235041019665d0f3d03066c58552f0c107d140b5a3847183b0748204446231059341207582a411c7807043351513644063f02105d25565427160f245540270d5a..., truncate
NVFORTRAN-W-0016-Identifier, struct_STATICS1_261a11241b5c231b0235041019665d0f3d03066c58552f0c107d140b5a3847183b0748204446231059341207582a411c7807043351513644063f02105d25565427160f24554027..., truncate
NVFORTRAN-W-0016-Identifier, struct_BSS1_261a11241b5c231b0235041019665d0f3d03066c58552f0c107d140b5a3847183b0748204446231059341207582a411c7807043351513644063f02105d25565427160f245540270d5a..., truncate
  0 inform,   2 warnings,   0 severes, 0 fatal for vpa_m
NVFORTRAN-W-0016-Identifier, struct_STATICS2_261a11241b5c231b0235041019665d0f3d03066c58552f0c107d140b5a3847183b0748204446231059341207582a411c7807043351513644063f02105d25565427160f24554027..., truncate

What the specification requires

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

OpenMP 5.2 §13.8 p.286 l.31-32

A variable referenced in a target region but not the target construct that is not declared in the target region must appear in a declare target directive

OpenMP 5.2 §5.1.1 p.98 l.11

Assumed-size arrays and named constants are shared

OpenMP 5.2 §3.2.1 p.61 l.10

in clauses where it is explicitly allowed

Evidence

Other compilers run it correctly

AFAR 24.3.0