OffTarget

Observed issues › cce21-in-reduction-assumed-shape-write-lost

Appears to behave incorrectlyWrong answer · Fortran · OpenMP · Open · regression

ftn 21: writes to an assumed-shape dummy in a target region with in_reduction are lost

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.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.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/afails another wayfails another way
NVHPC 26.9n/an/an/an/an/afails another wayfails another way
GCC 16.2.0fails another wayfails another wayfails another wayfails another wayfails another wayfails another wayn/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 21.0.3, MI300A unified
CCE 21.0.3, MI300A copy
CCE 21.0.4, MI300A unified
CCE 21.0.4, MI300A copy
show
r= 3 y(16)= 0
fails another wayNVHPC 25.11, A100 separate
NVHPC 25.11, A100 managed
show
NVFORTRAN-S-0034-Syntax error at or near identifier task_reduction (site-cce21-in-reduction-assumed-shape-write-lost.f90: 50)
NVFORTRAN-S-0034-Syntax error at or near identifier in_reduction (site-cce21-in-reduction-assumed-shape-write-lost.f90: 51)
NVFORTRAN/x86-64 Linux 25.11-0: compilation completed with severe errors
fails another wayNVHPC 26.9, A100 separate
NVHPC 26.9, A100 managed
show
NVFORTRAN-S-0034-Syntax error at or near identifier task_reduction (site-cce21-in-reduction-assumed-shape-write-lost.f90: 50)
NVFORTRAN-S-0034-Syntax error at or near identifier in_reduction (site-cce21-in-reduction-assumed-shape-write-lost.f90: 51)
NVFORTRAN/x86-64 Linux 26.9-0: compilation completed with severe errors
fails another wayGCC 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
libgomp: OMP_TARGET_OFFLOAD is set to MANDATORY, but device not found

Reproduce

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 (58 lines)
! (reducing the reproduction gate's flagged case entry
! 48, fuzz x0-alloc:197, whose kernel 4 is this pattern): CCE 21 loses the
! writes to an assumed-shape dummy array in a target region that has
! in_reduction (in a taskgroup with task_reduction), inside the procedure
! whose dummy it is. With explicit-shape dummies, or without the
! task_reduction/in_reduction pair, the writes come back.
! Spec: y is a mappable list item mapped tofrom (5.2 §5.8.3 p.150; the only
! Fortran list-item restriction, p.156, is on assumed-size arrays), so its
! values at the end of the region are assigned back to the original; the
! in_reduction clause on target (§5.5.10 p.138) and task_reduction on
! taskgroup (§5.5.9 p.137) do not change the mapping of other list items. r
! is not updated in the region. Expected: "r= 3 y(16)= 32".
! Observed (Tuolumne MI300A, -O2, OMP_TARGET_OFFLOAD=mandatory, 3 runs per
! cell, 2026-10-26; data/evidence/gate_probe/logs/reduce.txt, ids r2/inred_noh*):
! CCE 21.0.3 at HSA_XNACK 0 and 1: "r= 3 y(16)= 0" in every run.
! One-change controls of this program (after the later
! runs; data/evidence/gate_probe/reduce/): x(n), y(n) explicit-shape
! (inred_noh_explicit.f90) and the taskgroup and in_reduction removed
! (inred_noh_noinred.f90) each give "r= 3 y(16)= 32" in 6 of 6 runs on
! CCE 21, XNACK 0 and 1. CCE 19.0.0 and 20.0.2: right (both crash on the
! fuller fuzz kernel instead: data/reports/gate-queue.md, entry 48). The
! fix-round-1 form, which also printed an unwritten scalar h, gave the same
! (inred_host_noh.f90), and so did a form that writes and maps h
! (inred_host.f90).
! With r updated in the region (r = r + x(i)) CCE 21 does not link it
! ("undefined symbol: _cray$mt_taskwait": cce21-in-reduction-taskwait-link.f90),
! so this program leaves r alone.
! Another family: AFAR amdflang: "r= 3 y(16)= 32" (XNACK 0 and 1). NVHPC
! nvfortran 25.11 and 26.9 reject task_reduction ("Syntax error at or near
! identifier task_reduction" on data/evidence/gate_probe/reduce/unh_k2.f90 and
! unh_k4.f90, data/evidence/gate_probe/logs/wingtip5.log), so it is no witness.
! CCE: ftn -fopenmp -O2 (module load cce/21.0.3 craype-accel-amd-gfx942 rocm)
! Run: OMP_TARGET_OFFLOAD=mandatory HSA_XNACK=0 ./a.out
program p
  implicit none
  integer, parameter :: n = 16
  integer :: a(n), b(n), r, i
  do i = 1, n
    a(i) = i
    b(i) = 0
  end do
  r = 3
  call k(a, b)
  print '(a,i0,a,i0)', 'r= ', r, ' y(16)= ', b(n)
contains
  subroutine k(x, y)
    integer, intent(in) :: x(:)
    integer, intent(inout) :: y(:)
    integer :: i
    !$omp taskgroup task_reduction(+: r)
      !$omp target map(to: x) map(tofrom: y) in_reduction(+: r)
        do i = 1, n
          y(i) = 2 * x(i)
        end do
      !$omp end target
    !$omp end taskgroup
  end subroutine k
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

r= 3 y(16)= 32

Observed where it behaves incorrectly

r= 3 y(16)= 0

What the specification requires

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

OpenMP 5.2 §5.8.3 p.150

OpenMP 5.2 §5.5.10 p.138

OpenMP 5.2 §5.5.9 p.137

Evidence

Other compilers run it correctly

AFAR 24.3.0