OffTarget

Observed issues › catalog/cce-c-f-pointer-device-link

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

ftn: C_F_POINTER called in a target region fails at the device link (_C_F_POINTER undefined)

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.0correctcorrectcorrectcorrectcorrectn/an/a
CCE 19.0.0not supportednot supportednot supportedunknown
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.3not supportednot supportednot supportedunknown
not run
unknown
not run
n/an/a
CCE 21.0.4not supportednot supportednot supportedunknown
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.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
not supportedCCE 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..
lld: error: undefined symbol: _C_F_POINTER
>>> referenced by <dir>/cooltmpdir-5HO6vp/repro-cce-openmp__llc.amdgpu:(gen_prog_$ck_L22_1)
>>> referenced by <dir>/cooltmpdir-5HO6vp/repro-cce-openmp__llc.amdgpu:(gen_prog_$ck_L22_1)
not supportedCCE 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..
lld: error: undefined symbol: _C_F_POINTER
>>> referenced by <dir>/cooltmpdir-5C8SRY/repro-cce-openmp__llc.amdgpu:(gen_prog_$ck_L22_1)
>>> referenced by <dir>/cooltmpdir-5C8SRY/repro-cce-openmp__llc.amdgpu:(gen_prog_$ck_L22_1)
not supportedCCE 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..
lld: error: undefined symbol: _C_F_POINTER
>>> referenced by <dir>/cooltmpdir-6lfXrk/repro-cce-openmppost_lld.amdgpu.lto.o:(gen_prog_$ck_L22_1)
>>> referenced by <dir>/cooltmpdir-6lfXrk/repro-cce-openmppost_lld.amdgpu.lto.o:(gen_prog_$ck_L22_1)
not supportedCCE 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..
lld: error: undefined symbol: _C_F_POINTER
>>> referenced by <dir>/cooltmpdir-Xe9w0T/repro-cce-openmppost_lld.amdgpu.lto.o:(gen_prog_$ck_L22_1)
>>> referenced by <dir>/cooltmpdir-Xe9w0T/repro-cce-openmppost_lld.amdgpu.lto.o:(gen_prog_$ck_L22_1)
not supportedCCE 21.0.3, MI300A unified
CCE 21.0.3, MI300A copy
show
Warning:
 Headers and libraries from cray-libsci/26.03.0 will be ignored because depends on PE_MPICH which is unavailable..
lld: error: undefined symbol: _C_F_POINTER
>>> referenced by <dir>/pe_2677814//cooltmpdir-tqPBJ2/repro-cce-openmppost_lld.amdgpu.lto.o:(gen_prog_$ck_L22_1)
>>> referenced by <dir>/pe_2677814//cooltmpdir-tqPBJ2/repro-cce-openmppost_lld.amdgpu.lto.o:(gen_prog_$ck_L22_1)
not supportedCCE 21.0.3, MI250X
show
Warning:
 Headers and libraries from cray-libsci/26.03.0 will be ignored because depends on PE_MPICH which is unavailable..
lld: error: undefined symbol: _C_F_POINTER
>>> referenced by <dir>/pe_3597796//cooltmpdir-ehcLJG/repro-cce-openmppost_lld.amdgpu.lto.o:(gen_prog_$ck_L22_1)
>>> referenced by <dir>/pe_3597796//cooltmpdir-ehcLJG/repro-cce-openmppost_lld.amdgpu.lto.o:(gen_prog_$ck_L22_1)
not supportedCCE 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..
lld: error: undefined symbol: _C_F_POINTER
>>> referenced by <dir>/pe_3400038//cooltmpdir-XpJt4J/repro-cce-openmppost_lld.amdgpu.lto.o:(gen_prog_$ck_L22_1)
>>> referenced by <dir>/pe_3400038//cooltmpdir-XpJt4J/repro-cce-openmppost_lld.amdgpu.lto.o:(gen_prog_$ck_L22_1)
not supportedCCE 21.0.4, MI250X
show
Warning:
 Headers and libraries from cray-libsci/26.03.0 will be ignored because depends on PE_MPICH which is unavailable..
lld: error: undefined symbol: _C_F_POINTER
>>> referenced by <dir>/pe_3556018//cooltmpdir-G40wCC/repro-cce-openmppost_lld.amdgpu.lto.o:(gen_prog_$ck_L22_1)
>>> referenced by <dir>/pe_3556018//cooltmpdir-G40wCC/repro-cce-openmppost_lld.amdgpu.lto.o:(gen_prog_$ck_L22_1)
fails another wayNVHPC 25.11, A100 separate
NVHPC 25.11, A100 managed
NVHPC 26.9, A100 separate
NVHPC 26.9, A100 managed
show
NVFORTRAN-W-1288-Use of the USE_DEVICE_PTR clause is deprecated, use USE_DEVICE_ADDR clause instead (cce-c-f-pointer-device-link.f90: 21)
  0 inform,   1 warnings,   0 severes, 0 fatal for gen_prog
NVFORTRAN-S-1058-Call to NVHPC runtime function not supported - pgf90_c_f_ptr_i8 (cce-c-f-pointer-device-link.f90: 24)

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 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

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

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 (64 lines)
! # Draft finding: omp52-clause-is_device_ptr on cce19
!
! - compiler: cce19
! - toolchain: cce19; arch: gfx942; machine: tuolumne; memory mode: unified; opt: -O2
! - program: catalog omp52-clause-is_device_ptr (f90, version 52, sha256 234487aa9ebe80a4)
! - expected: None (None; )
! - actual: rejected  (link_undefined_symbol: lld: error: undefined symbol: _C_F_POINTER)
! - verdict: compiler_bug by rule R10b-own-link-or-hang: a link failure on symbols the compiler's own generated code needs, or a
!   compile that does not finish, on a legal program: the compiler's defect (never a rejection)
! - 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 5.2, free-form Fortran). Do not edit.
! id: omp52-clause-is_device_ptr
! primary atom: omp.clause.is_device_ptr
! legal: yes
! observable: yes
! ran_on_host: inside the target region of interest
! evidence: copy_mode_only
! needs: device_c_f_pointer
! std: f2008
! derivation (check=pass): target data maps a (to) and b (from); use_device_ptr(pa, pb) makes pa and pb the device addresses of a
! derivation: and b (5.2 §5.4.8 p.121); the nested target has is_device_ptr(pa, pb), so they are used as device pointers there (5.2
! derivation: §5.4.7 p.120) and qq(i) = 2*pp(i) + 1 writes the device's b; the end of target data copies b back: b = ref; the check
! derivation: accepts
program gen_prog
  use omp_lib, only: omp_is_initial_device
  use, intrinsic :: iso_c_binding, only: c_ptr, c_loc, c_f_pointer
  implicit none
  integer, parameter :: n = 64
  integer, allocatable, target :: a(:), b(:)
  integer :: ref(n)
  integer :: i, host_flag
  logical :: ok
  type(c_ptr) :: pa, pb
  integer, pointer :: pp(:), qq(:)
  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
  pa = c_loc(a)
  pb = c_loc(b)
  !$omp target data map(to: a) map(from: b) use_device_ptr(pa, pb)
    !$omp target is_device_ptr(pa, pb) private(pp, qq) map(tofrom: host_flag)
      host_flag = merge(1, 0, omp_is_initial_device())
      call c_f_pointer(pa, pp, [n])
      call c_f_pointer(pb, qq, [n])
      do i = 1, n
        qq(i) = 2*pp(i) + 1
      end do
    !$omp end target
  !$omp end target data
  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.03.0 will be ignored because depends on PE_MPICH which is unavailable..
lld: error: undefined symbol: _C_F_POINTER
>>> referenced by <dir>/cooltmpdir-5HO6vp/repro-cce-openmp__llc.amdgpu:(gen_prog_$ck_L22_1)
>>> referenced by <dir>/cooltmpdir-5HO6vp/repro-cce-openmp__llc.amdgpu:(gen_prog_$ck_L22_1)

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.121

OpenMP 5.2 §5.4.7 p.120

Evidence

Same compiler, one change

  • the device loop reads a and writes b directly instead of through c_f_pointer: 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
      use, intrinsic :: iso_c_binding, only: c_ptr, c_loc, c_f_pointer
      implicit none
      integer, parameter :: n = 64
      integer, allocatable, target :: a(:), b(:)
      integer :: ref(n)
      integer :: i, host_flag
      logical :: ok
      type(c_ptr) :: pa, pb
      integer, pointer :: pp(:), qq(:)
      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
      pa = c_loc(a)
      pb = c_loc(b)
      !$omp target data map(to: a) map(from: b) use_device_ptr(pa, pb)
        !$omp target is_device_ptr(pa, pb) private(pp, qq) 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
      !$omp end target data
      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, GCC 16.2.0