OffTarget

Observed issues › fuzz/s1-2370-cce21

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

ftn: firstprivate(i) on a parallel do nested in a teams distribute loop over i rejected under default(none) (ftn-1510)

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/acorrectcorrect
NVHPC 26.9n/an/an/an/an/acorrectcorrect
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
CCE 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..
    !$omp parallel do default(none) shared(a) firstprivate(i)
                                                           ^  
ftn-1510 ftn: ERROR P, File = s1-2370-cce21.f90, Line = 10, Column = 60 
  Variable "I" must have its data scope explicitly declared because DEFAULT(NONE) was specified.
Cray Fortran : 28 source lines
Cray Fortran : 1 errors, 0 warnings, 0 other messages, 0 ansi
not supportedCCE 20.0.2, MI300A unified
CCE 20.0.2, MI300A copy
CCE 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..
    !$omp parallel do default(none) shared(a) firstprivate(i)
                                                           ^  
ftn-1510 ftn: ERROR P, File = s1-2370-cce21.f90, Line = 10, Column = 60 
  Variable "I" must have its data scope explicitly declared because DEFAULT(NONE) was specified.
Cray Fortran : 28 source lines
Cray Fortran : 1 errors, 0 warnings, 0 other messages, 0 ansi
not supportedCCE 21.0.3, MI300A unified
CCE 21.0.3, MI300A copy
CCE 21.0.3, MI250X
CCE 21.0.4, MI300A unified
CCE 21.0.4, MI300A copy
CCE 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..
    !$omp parallel do default(none) shared(a) firstprivate(i)
                                                           ^  
ftn-1510 ftn: ERROR P, File = s1-2370-cce21.f90, Line = 10, Column = 60 
  Variable "I" must have its data scope explicitly declared because DEFAULT(NONE) was specified.
Cray Fortran : 28 source lines
Cray Fortran : 1 errors, 0 warnings, 0 other messages, 0 ansi

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 (63 lines)
! Finding: CCE 19, 20, 21 reject firstprivate(i) on a combined
! parallel do nested in a teams distribute loop over i, under default(none)
! (ftn-1510 "Variable "I" must have its data scope explicitly declared
! because DEFAULT(NONE) was specified"; in other programs ftn-1310 "Object
! "I" is specified on the FIRSTPRIVATE clause. It must have a shared scope
! in the enclosing region").
!
! Legal OpenMP 5.2: firstprivate on a combined construct applies to the
! worksharing leaf, and "If the parallel construct is among the constituent
! constructs and the effect is not as if the firstprivate clause is applied
! to it by the above rules, then the effect is as if the shared clause with
! the same list item is applied to the parallel construct" (5.2 §17.2
! p.340), so i is shared in the parallel region (default(none) is
! satisfied, 5.2 §5.4.1 p.109) and the restriction on worksharing
! firstprivate items that are private in the binding parallel region (5.2
! §5.4.4) does not apply; in the teams region i is the iteration variable of
! the distribute loop, predetermined private ("The loop iteration variable
! in any associated loop of a loop-associated construct is otherwise
! private", 5.2 §5.1.1 p.97). (A gfortran -fopenmp accept is withdrawn as evidence, 2026-10-23.)
! Expected: "RESULT check=pass" (a(i, j) = 10 * i + j).
!
! Observed (tuolumne, MI300A, -O2, HSA_XNACK=1, 2026-10-23,
! results/t28_probe/dn_teams_loopvar*.json):
! - CCE 19.0.0, 20.0.2, 21.0.3: ftn-1510 for I at the firstprivate(i) of
!   the parallel do; without firstprivate(i) (data/evidence/dataenv_probe/
!   dn_teams_loopvar_nofp.f90) all three compile and run correctly;
! - AFAR amdflang 24.0.0git: "RESULT check=pass".
! - Tioga MI250X (gfx90a, HSA_XNACK=0): the same; CCE 19/20/21 reject,
!   AFAR passes (results/t28_probe/g90/dn_teams_loopvar.cce21_g90.json).
! Fuzz campaign s1: the ftn-1510 "I" and ftn-1310 "I" cells of CCE (rule
! R11, decisions D2 and D5), verdict compiler_bug. Representatives: s1
! seeds 2370 (cce21, copy) and 6443 (cce21); reproducer written by hand
! (data/evidence/dataenv_probe/dn_teams_loopvar.f90).
!
! ftn -fopenmp -O2
program p
  implicit none
  integer, parameter :: n = 8, m = 4
  integer :: a(n, m), i, j
  logical :: ok
  a = 0
  !$omp target map(tofrom: a)
  !$omp teams distribute default(none) shared(a) private(j)
  do i = 1, n
    !$omp parallel do default(none) shared(a) firstprivate(i)
    do j = 1, m
      a(i, j) = 10 * i + j
    end do
  end do
  !$omp end teams distribute
  !$omp end target
  ok = .true.
  do i = 1, n
    do j = 1, m
      ok = ok .and. a(i, j) == 10 * i + j
    end do
  end do
  if (ok) then
    print '(a)', 'RESULT check=pass'
  else
    print '(a)', 'RESULT check=fail'
  end if
end program p

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

RESULT check=pass

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..
    !$omp parallel do default(none) shared(a) firstprivate(i)
                                                           ^  
ftn-1510 ftn: ERROR P, File = s1-2370-cce21.f90, Line = 10, Column = 60 
  Variable "I" must have its data scope explicitly declared because DEFAULT(NONE) was specified.
Cray Fortran : 28 source lines
Cray Fortran : 1 errors, 0 warnings, 0 other messages, 0 ansi

What the specification requires

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

OpenMP 5.2 §17.2 p.340

If the parallel construct is among the constituent constructs and the effect is not as if the firstprivate clause is applied to it by the above rules, then the effect is as if the shared clause with the same list item is applied to the parallel construct

OpenMP 5.2 §5.4.1 p.109

OpenMP 5.2 §5.4.4

OpenMP 5.2 §5.1.1 p.97

The loop iteration variable in any associated loop of a loop-associated construct is otherwise private

Evidence

Same compiler, one change

  • firstprivate(i) removed from the parallel do: AFAR 24.3.0: fails another way; CCE 19.0.0: correct; CCE 20.0.2: correct; CCE 21.0.3: correct; CCE 21.0.4: correct
    Control program
    program p
      implicit none
      integer, parameter :: n = 8, m = 4
      integer :: a(n, m), i, j
      logical :: ok
      a = 0
      !$omp target map(tofrom: a)
      !$omp teams distribute default(none) shared(a) private(j)
      do i = 1, n
        !$omp parallel do default(none) shared(a)
        do j = 1, m
          a(i, j) = 10 * i + j
        end do
      end do
      !$omp end teams distribute
      !$omp end target
      ok = .true.
      do i = 1, n
        do j = 1, m
          ok = ok .and. a(i, j) == 10 * i + j
        end do
      end do
      if (ok) then
        print '(a)', 'RESULT check=pass'
      else
        print '(a)', 'RESULT check=fail'
      end if
    end program p
    

Other compilers run it correctly

AFAR 24.3.0, NVHPC 25.11, NVHPC 26.9, GCC 16.2.0