OffTarget

Observed issues › fuzz/916-afar

Appears to behave incorrectlyCrashes or aborts at run time · Fortran · OpenMP · Open

amdflang at HSA_XNACK=1: a parallel region with a reduction (or atomic) nested in a distribute loop of a reducing teams region aborts

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 incorrectlycorrectunknown
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.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
show
Display only launched kernel:
Kernel 'omp target in _QQmain @ 10 (__omp_offloading_14_2a422fd5__QQmain_l10)'
OFFLOAD ERROR: memory access fault by GPU 6 (agent 0x5555556d55a0) at virtual address 0x555500000000. Reasons: Write access to a read-only page
Use 'OFFLOAD_TRACK_ALLOCATION_TRACES=true' to track device allocations

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 (59 lines)
! Minimized by compliance.fuzz_min from fuzz seed 916 (fuzz-1).
! toolchain: afar (-O2, HSA_XNACK=1, OMP_TARGET_OFFLOAD=mandatory)
! failure: run_error (crash: SIGABRT)
! expected: runs to completion (the host run does)
! observed: device: fail crash: SIGABRT; host reference (afar/cce19) checksum=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.
program fuzz_prog
  use omp_lib, only: omp_is_initial_device
  implicit none
  integer, parameter :: n = 48, m = 8
  integer, allocatable :: o1(:, :)
  integer :: i, j, r1a
  integer(8) :: cs
  allocate(o1(n, m))
  o1 = 0
  r1a = 65535
  ! fuzz: kernels
  !$omp target map(tofrom: r1a)
    !$omp teams reduction(iand: r1a)
      !$omp distribute
      do i = n, 1, -1
        !$omp parallel
          !$omp do reduction(iand: r1a)
          do j = 1, m
            o1(i, j) = 0
            r1a = iand(r1a, i)
          end do
          !$omp end do
        !$omp end parallel
      end do
      !$omp end distribute
    !$omp end teams
  !$omp end target
  ! fuzz: checksum
  cs = 0
  cs = modulo(cs * 31_8 + int(r1a, 8), 2147483629_8)
  do j = 1, m
    do i = 1, n
      cs = modulo(cs * 31_8 + int(o1(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
! spec (requirement): a reduction clause on a teams construct combines the private copy of every team into the original list
!   item at the end of the region, and a reduction clause on a worksharing loop requires the list item to be shared in the
!   enclosing parallel region and combines the threads' private copies, so nested reductions over the same variable are legal.
! "For the teams construct, one or more private copies of each list item are created for the initial task of each team in the
!   league, as if the private clause had been used. For the loop construct, private copies are created and used in the construct
!   according to the description and restrictions in Section 5.3. At the end of a region that corresponds to a construct for which
!   the reduction clause was specified, the original list item is updated by combining its original value with the final value of
!   each of the private copies, using the combiner of the specified reduction-identifier." (5.2 §5.5.8 p.135 l.4-10)
! "A list item that appears in a reduction clause on a worksharing construct must be shared in the parallel region to which a
!   corresponding worksharing region binds." (5.2 §5.5.8 p.135 l.26-27)
! spec (this program): teams reduction(iand: r1a) containing a distribute loop whose body has a parallel region with a do
!   reduction(iand: r1a) is legal (r1a is shared in the parallel region); AFAR at HSA_XNACK=1 aborts at run time (SIGABRT), and
!   the program is correct when the inner parallel region and its do construct are removed.

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

Display only launched kernel:
Kernel 'omp target in _QQmain @ 10 (__omp_offloading_14_2a422fd5__QQmain_l10)'
OFFLOAD ERROR: memory access fault by GPU 6 (agent 0x5555556d55a0) at virtual address 0x555500000000. Reasons: Write access to a read-only page
Use 'OFFLOAD_TRACK_ALLOCATION_TRACES=true' to track device allocations

What the specification requires

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

OpenMP 5.2 §5.5.8 p.135 l.4-10

For the teams construct, one or more private copies of each list item are created for the initial task of each team in the league, as if the private clause had been used. For the loop construct, private copies are created and used in the construct according to the description and restrictions in Section 5.3. At the end of a region that corresponds to a construct for which the reduction clause was specified, the original list item is updated by combining its original value with the final value of each of the private copies, using the combiner of the specified reduction-identifier.

OpenMP 5.2 §5.5.8 p.135 l.26-27

A list item that appears in a reduction clause on a worksharing construct must be shared in the parallel region to which a corresponding worksharing region binds.

Evidence

Same compiler, one change

  • the inner parallel region and its do construct removed (the team runs the j loop sequentially): 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 = 48, m = 8
      integer, allocatable :: o1(:, :)
      integer :: i, j, r1a
      integer(8) :: cs
      allocate(o1(n, m))
      o1 = 0
      r1a = 65535
      !$omp target map(tofrom: r1a)
        !$omp teams reduction(iand: r1a)
          !$omp distribute
          do i = n, 1, -1
              do j = 1, m
                o1(i, j) = 0
                r1a = iand(r1a, i)
              end do
          end do
          !$omp end distribute
        !$omp end teams
      !$omp end target
      cs = 0
      cs = modulo(cs * 31_8 + int(r1a, 8), 2147483629_8)
      do j = 1, m
        do i = 1, n
          cs = modulo(cs * 31_8 + int(o1(i, j), 8), 2147483629_8)
        end do
      end do
      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, NVHPC 25.11, NVHPC 26.9, GCC 16.2.0

Reproducers of this issue