OffTarget

Observed issues › fuzz/2334-cce19

Appears to behave incorrectlyCompiler crash · Fortran · OpenMP · Open

ftn: internal compiler error "Couldn't find an atomic update statement" for an atomic update whose factor folds to a constant

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.0correctcorrectunknown
not run
correctcorrectn/an/a
CCE 19.0.0behaves incorrectlybehaves incorrectlyunknown
not run
unknown
not run
unknown
not run
n/an/a
CCE 20.0.2behaves incorrectlybehaves incorrectlyunknown
not run
unknown
not run
unknown
not run
n/an/a
CCE 21.0.3behaves incorrectlybehaves incorrectlyunknown
not run
unknown
not run
unknown
not run
n/an/a
CCE 21.0.4behaves incorrectlybehaves incorrectlyunknown
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.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 incorrectlyCCE 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..
   Error message      ::  Couldn't find an atomic update statement
   Error detected     ::  File '/workspace/crayftn/pdgcs/v_mt_translate_atomic.c', line 1703
   Initiated from     ::  Line 660 (v_main.c)
   Optimizer built    ::  2025-02-07 (production)
   File               ::  fuzz-2334-cce19.f90
   Function           ::  fuzz_prog
behaves incorrectlyCCE 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..
   Error message      ::  Couldn't find an atomic update statement
   Error detected     ::  File '/workspace/crayftn/pdgcs/v_mt_translate_atomic.c', line 1703
   Initiated from     ::  Line 660 (v_main.c)
   Optimizer built    ::  2025-11-17 (production)
   File               ::  fuzz-2334-cce19.f90
   Function           ::  fuzz_prog
behaves incorrectlyCCE 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..
   Error message      ::  Couldn't find an atomic update statement
   Error detected     ::  File '/workspace/crayftn/pdgcs/v_mt_translate_atomic.c', line 1702
   Initiated from     ::  Line 732 (v_main.c)
   Optimizer built    ::  2026-07-14 (production)
   File               ::  fuzz-2334-cce19.f90
   Function           ::  fuzz_prog
behaves incorrectlyCCE 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..
   Error message      ::  Couldn't find an atomic update statement
   Error detected     ::  File '/workspace/crayftn/pdgcs/v_mt_translate_atomic.c', line 1702
   Initiated from     ::  Line 732 (v_main.c)
   Optimizer built    ::  2026-09-24 (production)
   File               ::  fuzz-2334-cce19.f90
   Function           ::  fuzz_prog

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 (50 lines)
! Minimized by compliance.fuzz_min from fuzz seed 2334 (fuzz-1).
! toolchain: cce19 (-O2, HSA_XNACK=1, OMP_TARGET_OFFLOAD=mandatory)
! failure: ice (ice: INTERNAL COMPILER ERROR: "Couldn't find an atomic update statement" (v_mt_translate_atomic.c, line 1703,
!   version <v>))
! expected: compiles
! observed: internal compiler error: ice: INTERNAL COMPILER ERROR:  "Couldn't find an atomic update statement"
!   (/workspace/crayftn/pdgcs/v_mt_translate_atomic.c, line 1703, version cc4d36e4ff3377d4
! Legal OpenMP 5.2: offload.engine.prerun.check accepts it (rerun: offload.engine.rules with the
!   race rule and the restriction checks, and the AFAR flang front end, not under test here); no
!   compiler under test, gfortran or gcc is a legality witness.
! also fails on: cce20, cce21
module fuzz_mod
  implicit none
contains
  integer function g1(x)
    !$omp declare target
    integer, intent(in) :: x
    g1 = mod(mod(merge(1, x, 1 > x), 13), 97)
  end function g1
end module fuzz_mod
program fuzz_prog
  use omp_lib, only: omp_get_thread_num, omp_is_initial_device
  use fuzz_mod, only: g1
  implicit none
  integer, parameter :: n = 100, m = 5
  integer :: i, j, r1b
  integer(8) :: cs
  r1b = -1
  ! fuzz: kernels
  !$omp target
    !$omp do
    do i = 1, n
      !$omp atomic
      r1b = r1b * merge((-1), 1, mod(11, 13) == 0)
    end do
    !$omp end do
  !$omp end target
  ! fuzz: checksum
  cs = 0
  cs = modulo(cs * 31_8 + int(r1b, 8), 2147483629_8)
  print '(a,i0,a,i0)', 'RESULT checksum=', cs, ' ran_on_host=', 0
end program fuzz_prog
! spec (requirement): an atomic update statement of the form x = x operator expr, where operator is one of the listed operators
!   (including *) and expr is any scalar expression, is a legal update-atomic structured block; a constant-valued expr is no
!   exception.
! "x   =   x operator expr" (5.2 §4.3.1.3 p.81 l.12)
! "expr is a scalar expression." (5.2 §4.3.1.3 p.79 l.23)
! spec (this program): !$omp atomic with r1b = r1b * merge((-1), 1, mod(11, 13) == 0) is an x = x operator expr update whose
!   scalar factor folds to the constant 1; CCE 19, 20 and 21 stop with an internal compiler error (Couldn't find an atomic update
!   statement), while the same statement with a factor that depends on i 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

Warning:
 Headers and libraries from cray-libsci/25.03.0 will be ignored because depends on PE_MPICH which is unavailable..
   Error message      ::  Couldn't find an atomic update statement
   Error detected     ::  File '/workspace/crayftn/pdgcs/v_mt_translate_atomic.c', line 1703
   Initiated from     ::  Line 660 (v_main.c)
   Optimizer built    ::  2025-02-07 (production)
   File               ::  fuzz-2334-cce19.f90
   Function           ::  fuzz_prog

What the specification requires

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

OpenMP 5.2 §4.3.1.3 p.81 l.12

x = x operator expr

OpenMP 5.2 §4.3.1.3 p.79 l.23

expr is a scalar expression.

Evidence

Same compiler, one change

  • the factor depends on i: merge(-1, 1, mod(i, 13) == 0) (seven sign changes, r1b = 1): 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 = 100
      integer :: i, r1b
      integer(8) :: cs
      r1b = -1
      !$omp target
        !$omp do
        do i = 1, n
          !$omp atomic
          r1b = r1b * merge((-1), 1, mod(i, 13) == 0)
        end do
        !$omp end do
      !$omp end target
      cs = 0
      cs = modulo(cs * 31_8 + int(r1b, 8), 2147483629_8)
      print '(a,i0)', 'RESULT checksum=', cs
    end program fuzz_prog
    

Other compilers run it correctly

AFAR 24.3.0, NVHPC 25.11, NVHPC 26.9, GCC 16.2.0