Observed issues › harvest/cce-use-device-ptr-c-ptr-not-converted
Appears to behave incorrectlyWrong answer · Fortran · OpenMP · Open
use_device_ptr does not convert a C_PTR list item: the region sees the host address
Legality: independently confirmed. 2 independent readings find the program legal and the result required. How this is checked
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 | behaves incorrectly | correct | unknown not run | correct | correct | n/a | n/a |
| CCE 19.0.0 | correct | behaves incorrectly | unknown not run | unknown not run | unknown not run | n/a | n/a |
| CCE 20.0.2 | correct | behaves incorrectly | unknown not run | unknown not run | unknown not run | n/a | n/a |
| CCE 21.0.3 | correct | behaves incorrectly | unknown not run | unknown not run | unknown not run | n/a | n/a |
| CCE 21.0.4 | correct | behaves incorrectly | 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 | correct | correct | correct | correct | correct | correct | 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 |
|---|---|---|
| behaves incorrectly | AFAR 24.3.0, MI300A unified | showhost 555555B61EC0 mapped 0 seen 555555B61EC0 loc(cp) 5555556200C0 RESULT ran_on_host=0 check=fail |
| behaves incorrectly | CCE 19.0.0, MI300A copy | showhost 48C040 mapped 155544D00000 seen 48C040 loc(cp) 408740 RESULT ran_on_host=0 check=fail |
| behaves incorrectly | CCE 20.0.2, MI300A copy | showhost 48C2C0 mapped 155544D00000 seen 48C2C0 loc(cp) 408780 RESULT ran_on_host=0 check=fail |
| behaves incorrectly | CCE 21.0.3, MI300A copy CCE 21.0.4, MI300A copy | showhost 494480 mapped 155544200000 seen 494480 loc(cp) 4087C0 RESULT ran_on_host=0 check=fail |
| fails another way | NVHPC 25.11, A100 separate | showPresent 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:0x308d1120 device:0x792a792fa000 size:4096 presentcount:0+1 line:44 name:tab(:) allocated block device:0x792a792fa000 size:4096 thread:1 FATAL ERROR: data in use_device clause was not found on device 1: host:0x413e88 |
| fails another way | NVHPC 25.11, A100 managed | showFATAL ERROR: data in use_device clause was not found on device 1: host:0x413e88 |
| fails another way | NVHPC 26.9, A100 separate | showPresent 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:0xf262130 device:0x71e5ab2fa000 size:4096 presentcount:0+1 line:44 name:tab(:) allocated block device:0x71e5ab2fa000 size:4096 thread:1 FATAL ERROR: data in use_device clause was not found on device 1: host:0x41a888 |
| fails another way | NVHPC 26.9, A100 managed | showFATAL ERROR: data in use_device clause was not found on device 1: host:0x41a888 |
Reproduce
AFAR 24.3.0, MI300A unified
$AFAR/bin/amdflang -fopenmp --offload-arch=gfx942 -O2 repro.f90 -o repro HSA_XNACK=1 OMP_TARGET_OFFLOAD=mandatory ./repro
CCE 19.0.0, MI300A copy
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=0 OMP_TARGET_OFFLOAD=mandatory ./repro
CCE 20.0.2, MI300A copy
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=0 OMP_TARGET_OFFLOAD=mandatory ./repro
CCE 21.0.3, MI300A copy
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=0 OMP_TARGET_OFFLOAD=mandatory ./repro
CCE 21.0.4, MI300A copy
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=0 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 (61 lines)
! # Finding (known-issues harvest): CCE does not convert a C_PTR list item of
! use_device_ptr: the region sees the host address
!
! - source: the NVIDIA forum topic 290317 (nvfortran dropping use_device_addr on an allocatable,
! TPR 36867) gave data/bench/harvest-known hk-040, which compares the use_device_addr address of an
! allocatable with the use_device_ptr address of a C_PTR to it; this file is the use_device_ptr
! half (data/reports/harvest-known/v040-ptr-print.f90)
! - compilers: CCE 19.0.0, 20.0.2, 21.0.3 (ftn -fopenmp), copy mode: gfx90a (Tioga, HSA_XNACK=0)
! and gfx942 at HSA_XNACK=0 (MI300A); at HSA_XNACK=1 on MI300A the mapped address is the host
! address, so the missing conversion is not visible (check=pass)
! - expected: seen equals mapped (the device address of tab), RESULT ... check=pass
! - actual: seen equals host: e.g. CCE 19 "host 48BEC0 mapped 155544200000 seen 48BEC0", the same
! on 20 and 21; RESULT ... check=fail. A device kernel given this pointer would read host memory.
! The observation does not rest on omp_get_mapped_ptr (a routine of the compiler under test):
! in copy mode device memory is separate, so seen = the host address is wrong whatever it returns
! - control (same compiler): use_device_addr(tab) on the allocatable itself gives the mapped
! address (data/reports/harvest-known/v040-addr.f90, check=pass on CCE 19/20/21)
! - other families: AFAR converts it (seen = mapped); NVHPC 25.11 and 26.9 abort at the construct
! (harvest/nvhpc-use-device-ptr-c-ptr-not-found.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.tioga (hk-040, gate: confirmed); the MI250X probe runs' output
! (results/harvest-known/logs/tioga/probe.f656gDkdAd9R.log and probe.f656k2mjQdoD.log; their rows file
! probes.tioga.jsonl was not kept); results/harvest-known/probes.tuolumne.jsonl (MI300A, v040-ptr.f90:
! fail at HSA_XNACK=0, pass at 1)
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
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
host 555555B61EC0 mapped 0 seen 555555B61EC0 loc(cp) 5555556200C0 RESULT ran_on_host=0 check=fail
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
GCC 16.2.0