Observed issues › gcc/gcc-acc-use-device-allocatable-rejected
gfortran: an allocatable array in host_data use_device is rejected ("ALLOCATABLE object ... in USE_DEVICE clause")
Legality: independently confirmed. 2 independent readings find the program legal and the result required. How this is checked
GCC 16.2's Fortran front end rejects an allocatable array in the use_device clause of host_data ("ALLOCATABLE object 'a' in USE_DEVICE clause"). OpenACC asks only that the item be a variable or an array. CCE and NVHPC compile and run the programs.
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 | n/a | n/a | n/a | n/a | n/a | n/a | n/a |
| CCE 19.0.0 | correct | correct | unknown not run | unknown not run | unknown not run | n/a | n/a |
| CCE 20.0.2 | correct | correct | unknown not run | unknown not run | unknown not run | n/a | n/a |
| CCE 21.0.3 | correct | correct | unknown not run | unknown not run | unknown not run | n/a | n/a |
| CCE 21.0.4 | correct | correct | 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 | correct | correct |
| NVHPC 26.9 | n/a | n/a | n/a | n/a | n/a | correct | correct |
| GCC 16.2.0 | not supported | not supported | not supported | not supported | not supported | not supported | 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 |
|---|---|---|
| not supported | GCC 16.2.0, MI300A unified GCC 16.2.0, MI300A copy GCC 16.2.0, MI250X GCC 16.2.0, MI300X GCC 16.2.0, MI350X GCC 16.2.0, A100 separate | showsite-gcc--gcc-acc-use-device-allocatable-rejected.f90:76:32:
76 | !$acc host_data use_device(a, b)
| 1
Error: ALLOCATABLE object ‘a’ in USE_DEVICE clause at (1)
site-gcc--gcc-acc-use-device-allocatable-rejected.f90:76:35:
76 | !$acc host_data use_device(a, b)
| 1
Error: ALLOCATABLE object ‘b’ in USE_DEVICE clause at (1) |
Reproduce
GCC 16.2.0, MI300A unified
export LD_LIBRARY_PATH=$GCC_16_2/lib64:/opt/rocm-7.2.1/lib $GCC_16_2/bin/gfortran -fopenacc -foffload=amdgcn-amdhsa -foffload-options=amdgcn-amdhsa=-march=gfx942 -O2 repro.f90 -o repro HSA_XNACK=1 ./repro
GCC 16.2.0, A100 separate
export PATH=/usr/local/cuda/bin:$PATH export LD_LIBRARY_PATH=$GCC_16_2/lib64 $GCC_16_2/bin/gfortran -fopenacc -foffload=nvptx-none -foffload-options=nvptx-none=-march=sm_80 -foffload-options=nvptx-none=-latomic -O2 repro.f90 -o repro ./repro
CCE 19.0.0, MI300A unified (runs correctly)
module load cce/19.0.0 craype-accel-amd-gfx942 rocm/6.4.3 module unload cray-mpich ftn -h acc -O2 repro.f90 -o repro HSA_XNACK=1 ./repro
Program (83 lines)
! # Finding (GCC 16.2): an allocatable array in use_device is rejected (Fortran); the reproducer is the catalog program
! acc34-clause-use_device
!
! - toolchains: gcc_g90 (GCC 16.2.0, AMD Instinct MI250X gfx90a, Tioga) and gcc_sm80 (GCC 16.2.0,
! NVIDIA A100 sm_80, wingtip); separate memory only; -O2; OMP_TARGET_OFFLOAD=mandatory
! - build: gfortran -fopenacc -foffload=amdgcn-amdhsa -foffload-options=amdgcn-amdhsa=-march=gfx90a -O2 (gcc_g90);
! -foffload=nvptx-none -foffload-options=nvptx-none=-march=sm_80 -foffload-options=nvptx-none=-latomic -O2 (gcc_sm80)
! - failure: rejected: ALLOCATABLE object .* in USE_DEVICE clause
! - observed: `Error: ALLOCATABLE object 'a' in USE_DEVICE clause at (1)` on both GPUs (the host_data and deviceptr programs pass
! their allocatable arrays the same way).
! - expected: compiles; `RESULT ran_on_host=0 check=pass`
! - spec: "A var in a use_device clause must be the name of a variable or array" (OpenACC 3.4 §2.8 l.2230); the restriction names no
! attribute, and an allocatable array is an array.
! - GCC 16.2 documentation (libgomp.texi "Enabling OpenACC"): "A complete description of all OpenACC directives accepted may be
! found in the OpenACC Application Programming Interface manual, version 2.6"; _OPENACC is 201711 (2.6). No list of OpenACC gaps
! is documented.
! - other families: CCE 19/20/21 (MI300A, MI250X) and NVHPC 25.11/26.9 compile and run all three programs correctly.
! - gate and confirmer: 6 cells (3 gcc_g90, 3 gcc_sm80), each confirmed in the gate's four environments (a-d;
! results/gcc/gate-tioga/ and gate-wingtip/ verdicts.jsonl); confirmer verdicts (results/gcc/confirm/batch.gcc_*.jsonl):
! compiler_bug (R11-compile-rejection) 6
! - catalog programs (3): acc34-clause-deviceptr, acc34-clause-use_device, acc34-directive-host_data
! - legality: the catalog programs are legal by construction (offload.engine.gen, c_gen and acc_gen
! check every program against the catalog rules and the offload scope as it is built; no
! compiler). GCC is a compiler under test only: never a legality witness, here or for another
! family's case (catalog/machines.yaml under_test_only).
! Generated by compliance.gen (OpenACC 3.4, free-form Fortran). Do not edit.
! id: acc34-clause-use_device
! primary atom: acc.clause.use_device
! legal: yes
! observable: yes
! ran_on_host: inside the compute region of interest (acc_on_device)
! evidence: copy_mode_only
! needs: none
! std: f2008
module gen_mod
use openacc
implicit none
contains
subroutine dev_twice(x, y, m, hf)
integer, intent(in) :: m
integer :: x(m), y(m), hf
integer :: k
!$acc parallel loop deviceptr(x, y) copy(hf)
do k = 1, m
if (k == 1) hf = merge(1, 0, acc_on_device(acc_device_host))
y(k) = 2*x(k) + 1
end do
end subroutine dev_twice
end module gen_mod
program gen_prog
use openacc, only: acc_device_host, acc_on_device
use gen_mod
implicit none
integer, parameter :: n = 64
integer, allocatable, target :: a(:), b(:)
integer :: ref(n)
integer :: i, host_flag
logical :: ok
logical :: pres, shared_mem
integer :: zc(1)
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
pres = .true.
zc = 0
!$acc serial copyin(zc)
zc(1) = 1
!$acc end serial
shared_mem = zc(1) == 1
!$acc data copyin(a) copyout(b)
!$acc host_data use_device(a, b)
call dev_twice(a, b, n, host_flag)
!$acc end host_data
!$acc end data
ok = all(b == ref) .and. pres
print '(a,i0,a,a)', 'RESULT ran_on_host=', host_flag, ' check=', merge('pass', 'fail', ok)
deallocate(a, b)
end program gen_prog
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
site-gcc--gcc-acc-use-device-allocatable-rejected.f90:76:32:
76 | !$acc host_data use_device(a, b)
| 1
Error: ALLOCATABLE object ‘a’ in USE_DEVICE clause at (1)
site-gcc--gcc-acc-use-device-allocatable-rejected.f90:76:35:
76 | !$acc host_data use_device(a, b)
| 1
Error: ALLOCATABLE object ‘b’ in USE_DEVICE clause at (1)What the specification requires
The specification text this program relies on and the compiler is expected to support.
OpenACC 3.4 §2.8
A var in a use_device clause must be the name of a variable or array
Evidence
Other compilers run it correctly
CCE 19.0.0, CCE 20.0.2, CCE 21.0.3, CCE 21.0.4, NVHPC 25.11, NVHPC 26.9