OffTarget

Observed issues › fuzz/1540-afar

Appears to behave incorrectlyCompiler crash · Fortran · OpenMP · Open

"'omp.target' op SPMD kernel must capture an 'omp.loop_nest' operation" for lastprivate(conditional:) on target parallel do

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.0behaves incorrectlybehaves incorrectlyunknown
not run
behaves incorrectlybehaves incorrectlyn/an/a
CCE 19.0.0correctcorrectunknown
not run
unknown
not run
unknown
not run
n/an/a
CCE 20.0.2correctcorrectunknown
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/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
behaves incorrectlyAFAR 24.3.0, MI300A unified
AFAR 24.3.0, MI300A copy
AFAR 24.3.0, MI300X
AFAR 24.3.0, MI350X
show
error: loc("fuzz-1540-afar.f90":7:9): 'omp.target' op SPMD kernel must capture an 'omp.loop_nest' operation
error: verification of lowering to FIR failed
fails another wayNVHPC 25.11, A100 separate
NVHPC 25.11, A100 managed
NVHPC 26.9, A100 separate
NVHPC 26.9, A100 managed
show
NVFORTRAN-S-0034-Syntax error at or near : (fuzz-1540-afar.f90: 7)
  0 inform,   0 warnings,   1 severes, 0 fatal for fuzz_prog

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

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
Program (39 lines)
! Minimized by compliance.fuzz_min from fuzz seed 1540 (fuzz-1).
! toolchain: afar (-O2, HSA_XNACK=1, OMP_TARGET_OFFLOAD=mandatory)
! failure: ice (afar FIR verification: 'omp.target' op SPMD kernel must capture an 'omp.loop_nest' operation)
! expected: compiles
! observed: internal compiler error: ice: error: verification of lowering to FIR failed
! Legal OpenMP 5.2: offload.engine.rules accepts it (offload.engine.prerun.check, rerun: with the
!   race rule and the restriction checks); NVHPC is no witness: it rejects it
!   (NVFORTRAN-S-0034-Syntax error at or near :); the check's other
!   witness, the AFAR flang front end, is the compiler under test and is not counted; no gfortran
!   or gcc is a legality witness.
program fuzz_prog
  use omp_lib, only: omp_is_initial_device
  implicit none
  integer, parameter :: n = 16, m = 4
  integer :: i, j, lp1
  integer(8) :: cs
  lp1 = 0
  ! fuzz: kernels
  !$omp target parallel do lastprivate(conditional: lp1)
  do i = 1, n
  end do
  !$omp end target parallel do
  ! fuzz: checksum
  cs = 0
  cs = modulo(cs * 31_8 + int(lp1, 8), 2147483629_8)
  print '(a,i0,a,i0)', 'RESULT checksum=', cs, ' ran_on_host=', 0
end program fuzz_prog
! spec (requirement): the lastprivate clause accepts the conditional modifier on a worksharing loop (the original list item
!   receives the value the last assigning iteration of sequential execution would leave), and on a combined construct with target
!   the list item is mapped tofrom.
! "When the conditional modifier appears on the clause or the list item is an iteration variable of one of the associated loops,
!   if sequential execution of the loop nest would assign a value to the list item then the original list item is assigned the
!   value that the list item would have after sequential execution of the loop nest." (5.2 §5.4.5 p.115 l.16-19)
! "If the target construct is among the constituent constructs and the list item is not the base variable or base pointer of a
!   list item that appears in a map clause, the effect of the lastprivate clause is as if the same list item appears in a map
!   clause with a map-type of tofrom." (5.2 §17.2 p.340 l.27-30)
! spec (this program): target parallel do lastprivate(conditional: lp1) with a loop body that assigns nothing is a legal
!   combined construct that leaves lp1 unchanged; AFAR stops with an internal compiler error in FIR verification (SPMD kernel must
!   capture an omp.loop_nest) instead of compiling it, while lastprivate(lp1) without the modifier compiles.

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

error: loc("fuzz-1540-afar.f90":7:9): 'omp.target' op SPMD kernel must capture an 'omp.loop_nest' operation
error: verification of lowering to FIR failed

What the specification requires

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

OpenMP 5.2 §5.4.5 p.115 l.16-19

When the conditional modifier appears on the clause or the list item is an iteration variable of one of the associated loops, if sequential execution of the loop nest would assign a value to the list item then the original list item is assigned the value that the list item would have after sequential execution of the loop nest.

OpenMP 5.2 §17.2 p.340 l.27-30

If the target construct is among the constituent constructs and the list item is not the base variable or base pointer of a list item that appears in a map clause, the effect of the lastprivate clause is as if the same list item appears in a map clause with a map-type of tofrom.

Evidence

Same compiler, one change

  • lastprivate(lp1) without the conditional modifier: 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 fuzz_prog
      implicit none
      integer, parameter :: n = 16
      integer :: i, lp1
      integer(8) :: cs
      lp1 = 0
      !$omp target parallel do lastprivate(lp1)
      do i = 1, n
      end do
      !$omp end target parallel do
      cs = 0
      cs = modulo(cs * 31_8 + int(lp1, 8), 2147483629_8)
      print '(a,i0)', 'RESULT checksum=', cs
    end program fuzz_prog
    

Other compilers run it correctly

CCE 19.0.0, CCE 20.0.2, CCE 21.0.3, CCE 21.0.4, GCC 16.2.0

Reproducers of this issue