OffTarget

Observed issues › gcc/gcc-acc-gang-dim-collapse-force-rejected

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

OpenACC 3.3 gang(dim:) and collapse(force:) are rejected (newer than GCC's OpenACC 2.6)

Legality: independently confirmed. 2 independent readings find the program legal and the result required. How this is checked

GCC 16.2 rejects two OpenACC 3.3 loop forms: the dim argument of the gang clause and the force modifier of collapse. GCC documents OpenACC 2.6, so both are newer than its claim.

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.0n/an/an/an/an/an/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.3correctcorrectunknown
not run
unknown
not run
unknown
not run
n/an/a
CCE 21.0.4correctcorrectunknown
not run
unknown
not run
unknown
not run
n/an/a
NVHPC 25.11n/an/an/an/an/acorrectcorrect
NVHPC 26.9n/an/an/an/an/acorrectcorrect
GCC 16.2.0not supportednot supportednot supportednot supportednot supportednot supportedn/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 supportedGCC 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
show
site-gcc--gcc-acc-gang-dim-collapse-force-rejected.f90:54:69:
   54 |   !$acc parallel loop copyin(a) copyout(b) copy(host_flag) collapse(force: 2)
      |                                                                     1
Error: Invalid expression after ‘collapse(’ at (1)
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..
  !$acc parallel loop copyin(a) copyout(b) copy(host_flag) collapse(force: 2)
                                                                    ^         
ftn-113 ftn: ERROR GEN_PROG, File = site-gcc--gcc-acc-gang-dim-collapse-force-rejected.f90, Line = 54, Column = 69 
  IMPLICIT NONE is specified in the local scope, therefore an explicit type must be specified for data object "FORCE".
                                                                    ^         
ftn-868 ftn: ERROR GEN_PROG, File = site-gcc--gcc-acc-gang-dim-collapse-force-rejected.f90, Line = 54, Column = 69 
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..
  !$acc parallel loop copyin(a) copyout(b) copy(host_flag) collapse(force: 2)
                                                                    ^         
ftn-113 ftn: ERROR GEN_PROG, File = site-gcc--gcc-acc-gang-dim-collapse-force-rejected.f90, Line = 54, Column = 69 
  IMPLICIT NONE is specified in the local scope, therefore an explicit type must be specified for data object "FORCE".
                                                                    ^         
ftn-868 ftn: ERROR GEN_PROG, File = site-gcc--gcc-acc-gang-dim-collapse-force-rejected.f90, Line = 54, Column = 69 

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 21.0.3, MI300A unified (runs correctly)

module load cce/21.0.3 craype-accel-amd-gfx942 rocm/7.2.0
module unload cray-mpich
ftn -h acc -O2 repro.f90 -o repro
HSA_XNACK=1 ./repro
Program (64 lines)
! # Finding (GCC 16.2): OpenACC 3.3 gang(dim:) and collapse(force:) are rejected (Fortran); the reproducer is the catalog program
!   acc34-clause-collapse-force
!
! - 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
! - observed: `Error: Invalid expression after 'collapse(' at (1)` (gang(dim:): `Failed to match clause`), on both GPUs.
! - expected: compiles; `RESULT ran_on_host=0 check=pass`
! - spec: the force modifier (OpenACC 3.4 §2.9.1 l.2340-2341: "If the force modifier does not appear, then the associated loops must
!   be tightly nested"; added in 3.3: OpenACC 3.4's "Changes from Version 3.2 to 3.3", margin line 807, and OpenACC 3.3's own,
!   margin line 787) and the dim argument of gang (§2.9.2 l.2371; added in 3.3, "Changes from Version 3.2 to 3.3", margin line 800).
! - 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 21 and NVHPC 25.11/26.9 compile and run the collapse(force:) program (CCE 19/20 reject it); every compiler
!   under test fails the Fortran gang(dim:) program.
! - gate and confirmer: 4 cells (2 gcc_g90, 2 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) 2, needs_human (R12b-compile-undecided) 2
! - catalog programs (2): acc34-clause-collapse-force, acc34-clause-gang-dim
! - 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-collapse-force
! primary atom: acc.clause.collapse.force
! legal: yes
! observable: yes
! ran_on_host: inside the compute region of interest (acc_on_device)
! evidence: unverified
! needs: none
! std: f2008
! unverified (needs_other_infrastructure): collapse(force: 2) decides which gang, worker or vector lane runs an iteration; no
! OpenACC routine reports it (the result of a correct loop is the same under every schedule)
program gen_prog
  use openacc, only: acc_device_host, acc_on_device
  implicit none
  integer, parameter :: n = 64
  integer, allocatable, target :: a(:), b(:)
  integer :: ref(n)
  integer :: i, host_flag
  logical :: ok
  integer :: j, k
  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
  !$acc parallel loop copyin(a) copyout(b) copy(host_flag) collapse(force: 2)
  do j = 1, 8
    do k = 1, 8
      if (j == 1 .and. k == 1) host_flag = merge(1, 0, acc_on_device(acc_device_host))
      b((j - 1)*8 + k) = 2*a((j - 1)*8 + k) + 1
    end do
  end do
  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

Expected

check=pass

Observed where it behaves incorrectly

site-gcc--gcc-acc-gang-dim-collapse-force-rejected.f90:54:69:
   54 |   !$acc parallel loop copyin(a) copyout(b) copy(host_flag) collapse(force: 2)
      |                                                                     1
Error: Invalid expression after ‘collapse(’ at (1)

What the specification requires

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

OpenACC 3.4 §2.9.1

If the force modifier does not appear, then the associated loops must be tightly nested

OpenACC 3.4 §2.9.2

Evidence

Other compilers run it correctly

CCE 21.0.3, CCE 21.0.4, NVHPC 25.11, NVHPC 26.9

Reproducers of this issue