OffTarget

Observed issues › fuzz/b3-94-afar

Appears to behave incorrectlyWrong answer · Fortran · OpenMP · Open

amdflang: a parallel region with firstprivate nested in a distribute loop loses the writes of its worksharing loop

Legality: not independently confirmed. no independent review yet How this is checked

Same issue as fuzz/650-afar; this program is another reproducer of it.

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
unknown
varies between runs
behaves 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/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 incorrectlyAFAR 24.3.0, MI300A unified
AFAR 24.3.0, MI300A copy
AFAR 24.3.0, MI350X
show
RESULT checksum=0

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 (76 lines)
! Minimized by compliance.fuzz_min from fuzz seed 94 (fuzz-3).
! toolchain: afar (-O2, HSA_XNACK=1, OMP_TARGET_OFFLOAD=mandatory)
! failure: wrong_code
! expected: the host reference checksum (host reference (elision) checksum=2012829416)
! observed: device checksum=0 ran_on_host=0
! Legal OpenMP 5.2: offload.engine.rules accepts it (offload.engine.prerun.check, rerun: with the
!   race rule and the restriction checks); nvfortran/nvc 26.9 and 25.11 (NVHPC, not under test
!   here) compile it; 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.
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 = 32, m = 2
  type :: rec_t
    integer :: a(n)
    integer, allocatable :: q(:)
  end type rec_t
  type(rec_t) :: dr
  integer, allocatable :: ib(:)
  integer, allocatable :: o1(:, :)
  integer, pointer :: o2(:, :)
  integer :: s3(n)
  integer, allocatable :: s4(:)
  integer, target :: o2t(n, m)
  integer, target :: tgc(n)
  integer :: i, j
  integer(8) :: cs
  allocate(ib(n))
  allocate(o1(n, m))
  allocate(s4(n))
  allocate(dr%q(n))
  o2 => o2t
  do i = 1, n
    ib(i) = mod(i * 16 + 35, 30011) - 1727
  end do
  do i = 1, n
    dr%a(i) = mod(i * 5 + 17, 211) - 48
    dr%q(i) = mod(i * 50 + 39, 1009) - 500
    tgc(i) = mod(i * 55 + 22, 97) - 32
  end do
  o1 = 0
  o2 = 0
  s3 = 0
  s4 = 0
  ! fuzz: kernels
  !$omp target map(to: dr%a, ib)
    !$omp teams
      !$omp distribute
      do i = n, 1, -1
        !$omp parallel firstprivate(i)
          !$omp do
          do j = 1, m
            o1(i, j) = mod(mod(i, 13), 1009)
          end do
        !$omp end parallel
      end do
    !$omp end teams
  !$omp end target
  ! fuzz: checksum
  cs = 0
  do j = 1, m
    do i = 1, n
      cs = modulo(cs * 31_8 + int(o1(i, j), 8), 2147483629_8)
    end do
  end do
  do j = 1, m
    do i = 1, n
      cs = modulo(cs * 31_8 + int(o2t(i, j), 8), 2147483629_8)
    end do
  end do
  print '(a,i0,a,i0)', 'RESULT checksum=', cs, ' ran_on_host=', 0
end program fuzz_prog

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

RESULT checksum=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/650-afar.

OpenMP 5.2 §5.4.4 p.112 l.11-14

In addition, the new list item is initialized from the original list item that exists before the construct. The initialization of the new list item is done once for each task that references the list item in any statement in the construct. The initialization is done prior to the execution of the construct.

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.

Evidence

Other compilers run it correctly

CCE 19.0.0, CCE 20.0.2, CCE 21.0.3, CCE 21.0.4, NVHPC 25.11, NVHPC 26.9, GCC 16.2.0