OffTarget

Observed issues › harvest/nvhpc-use-device-ptr-c-ptr-not-found

Appears to behave incorrectlyRun-time error · Fortran · OpenMP · Open

nvfortran aborts on use_device_ptr of a C_PTR to mapped data ("data in use_device clause was not found")

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 waycorrectunknown
not run
correctcorrectn/an/a
CCE 19.0.0correctfails another wayunknown
not run
unknown
not run
unknown
not run
n/an/a
CCE 20.0.2correctfails another wayunknown
not run
unknown
not run
unknown
not run
n/an/a
CCE 21.0.3correctfails another wayunknown
not run
unknown
not run
unknown
not run
n/an/a
CCE 21.0.4correctfails another wayunknown
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 incorrectlyNVHPC 25.11, A100 separate
show
Present table dump for device[1]: NVIDIA Tesla GPU 0, compute capability 8.0, threadid=1
Hint: specify 0x800 bit in NV_ACC_DEBUG for verbose info.
host:0x3a7dc120 device:0x78f87d2fa000 size:4096 presentcount:0+1 line:42 name:tab(:)
allocated block device:0x78f87d2fa000 size:4096 thread:1
FATAL ERROR: data in use_device clause was not found on device 1: host:0x413e88
behaves incorrectlyNVHPC 25.11, A100 managed
show
FATAL ERROR: data in use_device clause was not found on device 1: host:0x413e88
behaves incorrectlyNVHPC 26.9, A100 separate
show
Present table dump for device[1]: NVIDIA Tesla GPU 0, compute capability 8.0, threadid=1
Hint: specify 0x800 bit in NV_ACC_DEBUG for verbose info.
host:0x2066c130 device:0x7f239b2fa000 size:4096 presentcount:0+1 line:42 name:tab(:)
allocated block device:0x7f239b2fa000 size:4096 thread:1
FATAL ERROR: data in use_device clause was not found on device 1: host:0x41a888
behaves incorrectlyNVHPC 26.9, A100 managed
show
FATAL ERROR: data in use_device clause was not found on device 1: host:0x41a888
fails another wayAFAR 24.3.0, MI300A unified
show
host   555555B61EC0
mapped 0
seen   555555B61EC0
loc(cp) 5555556200C0
RESULT ran_on_host=0 check=fail
fails another wayCCE 19.0.0, MI300A copy
show
host   48C040
mapped 155544D00000
seen   48C040
loc(cp) 408740
RESULT ran_on_host=0 check=fail
fails another wayCCE 20.0.2, MI300A copy
show
host   48C2C0
mapped 155544D00000
seen   48C2C0
loc(cp) 408780
RESULT ran_on_host=0 check=fail
fails another wayCCE 21.0.3, MI300A copy
CCE 21.0.4, MI300A copy
show
host   494480
mapped 155544200000
seen   494480
loc(cp) 4087C0
RESULT ran_on_host=0 check=fail

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 copy (runs correctly)

$AFAR/bin/amdflang -fopenmp --offload-arch=gfx942 -O2 repro.f90 -o repro
HSA_XNACK=0 OMP_TARGET_OFFLOAD=mandatory ./repro
Program (57 lines)
! # Finding (known-issues harvest): NVHPC aborts on use_device_ptr of a C_PTR
!   that points to mapped data ("data in use_device clause was not found")
!
! - source: the NVIDIA forum topic 290317 (nvfortran dropping use_device_addr on an allocatable,
!   TPR 36867; that defect is gone in 25.11 and 26.9) gave data/bench/harvest-known hk-040; this file is
!   its use_device_ptr half (data/reports/harvest-known/v040-ptr-print.f90)
! - compilers: NVHPC nvfortran 25.11 and 26.9, -mp=gpu -gpu=cc80 (separate and managed memory)
! - expected: seen equals mapped (the device address of tab), RESULT ... check=pass
! - actual: the run stops at the target data construct, exit status 1: "FATAL ERROR: data in
!   use_device clause was not found on device 1: host:0x4197a8", a static address (cp's own
!   storage; tab is on the heap, the present table lists it at host:0x1f173160), both releases,
!   both memory modes, with and without OMP_TARGET_OFFLOAD=mandatory. The compiler also warns
!   "Use of the USE_DEVICE_PTR clause is deprecated" for this C_PTR list item
! - control (same compiler): use_device_addr(tab) on the allocatable gives the mapped address
!   (data/reports/harvest-known/v040-addr.f90, check=pass); the C form, use_device_ptr of a C
!   pointer, converts correctly (data/reports/harvest-known/c018-data-if-true.c)
! - other families: AFAR converts it (seen = mapped); CCE 19/20/21 leave the host address
!   (harvest/cce-use-device-ptr-c-ptr-not-converted.f90)
!   This file uses omp_get_mapped_ptr as the reference: AFAR at HSA_XNACK=1 (MI300A) returns a
!   null pointer for it, the known defect of afar-xnack1-target-is-present.f90 (nothing is
!   recorded present in unified memory), so that cell fails for another reason
! - legality: "If a list item that appears in a use_device_ptr clause is of type C_PTR and
!   points to a data entity that is mapped to the device data environment, references to the list
!   item in the structured block ... are converted into references to a device pointer that is
!   local to the structured block and that refers to the device address of the corresponding
!   entity" (OpenMP 5.2 §5.4.8 p.122 l.1-5); tab is mapped by target enter data and cp =
!   c_loc(tab); the C_PTR form is the one 5.2 keeps (the non-C_PTR form is deprecated, l.8-10).
!   omp_get_mapped_ptr is OpenMP 5.1 (§3.8.11); the pre-run check accepts the program
! - evidence: results/harvest-known/main.wingtip (hk-040, gate: confirmed), results/harvest-known/probes.wingtip.jsonl
program v040pp
  use iso_c_binding
  use omp_lib
  implicit none
  integer, parameter :: n = 1024
  integer, allocatable, target :: tab(:)
  type(c_ptr), target :: cp
  type(c_ptr) :: p_ptr, p_map
  integer :: hk_host
  allocate(tab(n))
  tab = 7
  !$omp target enter data map(to: tab)
  p_map = omp_get_mapped_ptr(c_loc(tab), omp_get_default_device())
  cp = c_loc(tab)
  !$omp target data use_device_ptr(cp)
  p_ptr = cp
  !$omp end target data
  !$omp target exit data map(delete: tab)
  print '(a,z0)', 'host   ', transfer(c_loc(tab), 0_c_intptr_t)
  print '(a,z0)', 'mapped ', transfer(p_map, 0_c_intptr_t)
  print '(a,z0)', 'seen   ', transfer(p_ptr, 0_c_intptr_t)
  print '(a,z0)', 'loc(cp) ', transfer(c_loc(cp), 0_c_intptr_t)
  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', c_associated(p_ptr, p_map))
end program v040pp

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

Present table dump for device[1]: NVIDIA Tesla GPU 0, compute capability 8.0, threadid=1
Hint: specify 0x800 bit in NV_ACC_DEBUG for verbose info.
host:0x3a7dc120 device:0x78f87d2fa000 size:4096 presentcount:0+1 line:42 name:tab(:)
allocated block device:0x78f87d2fa000 size:4096 thread:1
FATAL ERROR: data in use_device clause was not found on device 1: host:0x413e88

What the specification requires

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

OpenMP 5.2 §5.4.8 p.122 l.1-5

If a list item that appears in a use_device_ptr clause is of type C_PTR and points to a data entity that is mapped to the device data environment, references to the list item in the structured block ... are converted into references to a device pointer that is local to the structured block and that refers to the device address of the corresponding entity

OpenMP 5.1 §3.8.11

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, GCC 16.2.0