Observed issues › fuzz/b3-250-cce20
ftn: a target construct with in_reduction in an internal subroutine loses the writes to an implicitly mapped dummy array
Legality: not independently confirmed. no independent review yet How this is checked
Same issue as fuzz/b3-61-cce20; this program is another reproducer of it.
Affected variants
| Compiler | MI300A 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.0 | correct | correct | unknown not run | correct | correct | n/a | n/a |
| CCE 19.0.0 | behaves incorrectly | behaves incorrectly | unknown not run | unknown not run | unknown not run | n/a | n/a |
| CCE 20.0.2 | behaves incorrectly | behaves incorrectly | unknown not run | unknown not run | unknown not run | n/a | n/a |
| CCE 21.0.3 | behaves incorrectly | behaves incorrectly | unknown not run | unknown not run | unknown not run | n/a | n/a |
| CCE 21.0.4 | behaves incorrectly | behaves incorrectly | unknown not run | unknown not run | unknown not run | n/a | n/a |
| NVHPC 25.11 | n/a | n/a | n/a | n/a | n/a | fails another way | fails another way |
| NVHPC 26.9 | n/a | n/a | n/a | n/a | n/a | fails another way | fails another way |
| GCC 16.2.0 | fails another way | fails another way | fails another way | fails another way | fails another way | fails another way | n/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
| Result | Compiler and GPU | Message |
|---|---|---|
| behaves incorrectly | CCE 19.0.0, MI300A unified CCE 19.0.0, MI300A copy CCE 20.0.2, MI300A unified CCE 20.0.2, MI300A copy CCE 21.0.3, MI300A unified CCE 21.0.3, MI300A copy CCE 21.0.4, MI300A unified CCE 21.0.4, MI300A copy | showRESULT checksum=1312631914 ran_on_host=0 |
| fails another way | NVHPC 25.11, A100 separate NVHPC 25.11, A100 managed | showNVFORTRAN-S-0034-Syntax error at or near identifier task_reduction (fuzz-b3-250-cce20.f90: 58) NVFORTRAN-S-0034-Syntax error at or near identifier in_reduction (fuzz-b3-250-cce20.f90: 59) NVFORTRAN/x86-64 Linux 25.11-0: compilation completed with severe errors |
| fails another way | NVHPC 26.9, A100 separate NVHPC 26.9, A100 managed | showNVFORTRAN-S-0034-Syntax error at or near identifier task_reduction (fuzz-b3-250-cce20.f90: 58) NVFORTRAN-S-0034-Syntax error at or near identifier in_reduction (fuzz-b3-250-cce20.f90: 59) NVFORTRAN/x86-64 Linux 26.9-0: compilation completed with severe errors |
| fails another way | GCC 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 | showlibgomp: OMP_TARGET_OFFLOAD is set to MANDATORY, but device not found |
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 (85 lines)
! Minimized by compliance.fuzz_min from fuzz seed 250 (fuzz-3).
! toolchain: cce20 (-O2, HSA_XNACK=1, OMP_TARGET_OFFLOAD=mandatory)
! failure: wrong_code
! expected: the host reference checksum (host reference (elision) checksum=1218074569)
! observed: device checksum=1312631914 ran_on_host=0
! 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: cce19, cce21
module fuzz_mod
implicit none
contains
end module fuzz_mod
program fuzz_prog
use omp_lib, only: omp_is_initial_device
implicit none
integer, parameter :: n = 128, m = 5
type :: rec_t
end type rec_t
type(rec_t) :: dr
integer :: ia(n)
integer, allocatable :: ib(:)
integer, allocatable :: ic(:, :)
integer, allocatable :: o1(:)
integer, pointer :: o2(:)
integer, target :: o2t(n)
integer :: i, j, p1, r1a, hf1
integer(8) :: cs
allocate(ib(n))
allocate(ic(n, m))
allocate(o1(n))
o2 => o2t
do i = 1, n
ia(i) = mod(i * 35 + 30, 1009) - 462
end do
do i = 1, n
ib(i) = mod(i * 22 + 36, 30011) - 8252
end do
do j = 1, m
do i = 1, n
ic(i, j) = mod((i + 6 * j) * 36 + 12, 30011) - 539
end do
end do
o1 = 0
o2 = 0
p1 = -6
r1a = -5
hf1 = 0
! fuzz: kernels
call kp1(ia, ib, ic, o1, dr, p1)
! fuzz: checksum
cs = 0
cs = modulo(cs * 31_8 + int(r1a, 8), 2147483629_8)
do i = 1, n
cs = modulo(cs * 31_8 + int(o1(i), 8), 2147483629_8)
end do
do i = 1, n
cs = modulo(cs * 31_8 + int(o2t(i), 8), 2147483629_8)
end do
print '(a,i0,a,i0)', 'RESULT checksum=', cs, ' ran_on_host=', max(hf1, 0)
contains
subroutine kp1(ia, ib, ic, o1, dr, p1)
integer, intent(in) :: ia(:)
integer, intent(inout) :: ib(:)
integer, intent(inout) :: ic(:, :)
integer, intent(inout) :: o1(:)
type(rec_t), intent(inout) :: dr
integer, intent(in) :: p1
!$omp taskgroup task_reduction(+: r1a)
!$omp target map(tofrom: hf1) in_reduction(+: r1a)
hf1 = merge(1, 0, omp_is_initial_device())
do i = 1, n
o1(i) = 1009
end do
!$omp end target
!$omp end taskgroup
end subroutine kp1
subroutine kp2(ib, ic, o2, dr, zopt)
integer, allocatable, intent(inout) :: ib(:)
integer, intent(in) :: ic(:, :)
integer, pointer, intent(in) :: o2(:)
type(rec_t), intent(inout) :: dr
integer, intent(in), optional :: zopt(:)
end subroutine kp2
end program fuzz_prog
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
RESULT checksum=1312631914 ran_on_host=0
What the specification requires
The specification text this program relies on and the compiler is expected to support.
The same requirement as the issue fuzz/b3-61-cce20.
OpenMP 5.2 §5.8.1 p.149 l.4-5
If a variable is not a scalar then it is treated as if it had appeared in a map clause with a map-type of tofrom.
OpenMP 5.2 §5.8.1 p.148 l.15-17
If a variable is the base variable of a list item in an in_reduction clause on a target construct then it is treated as if the list item had appeared in a map clause with a map-type of tofrom and a map-type-modifier of always.
Evidence
Other compilers run it correctly
AFAR 24.3.0