OffTarget

Observed issues › afar-flang-loop-bind-teams-reduction

Appears not to supportRefused at compile time · Fortran · OpenMP · Open

amdflang: reduction on loop bind(teams) nested in a target teams region rejected

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.0not supportednot supportednot supportednot supportednot supportedn/an/a
CCE 19.0.0correctcorrectcorrectunknown
not run
unknown
not run
n/an/a
CCE 20.0.2correctcorrectcorrectunknown
not run
unknown
not run
n/an/a
CCE 21.0.3correctcorrectcorrectunknown
not run
unknown
not run
n/an/a
CCE 21.0.4correctcorrectcorrectunknown
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
not supportedAFAR 24.3.0, MI300A unified
AFAR 24.3.0, MI300A copy
AFAR 24.3.0, MI250X
AFAR 24.3.0, MI300X
AFAR 24.3.0, MI350X
show
error: Semantic errors in afar-flang-loop-bind-teams-reduction.f90
afar-flang-loop-bind-teams-reduction.f90:6:28: error: 'REDUCTION' clause not allowed with '!$OMP LOOP BIND(TEAMS)'.
      !$omp loop bind(teams) reduction(+: r)
                             ^^^^^^^^^^^^^^^

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 (20 lines)
program p
  implicit none
  integer :: r, i
  r = 0
  !$omp target teams map(tofrom: r)
    !$omp loop bind(teams) reduction(+: r)
    do i = 1, 10
      r = r + i
    end do
  !$omp end target teams
  print *, 'r =', r
end program p
! spec (requirement): The reduction clause is permitted on the loop construct.
! "bind, collapse, lastprivate, order, private, reduction" (5.2 §11.7 p.257 l.4)
! spec (requirement): The behavior of a reduction clause on a loop with bind(teams) is unspecified only when the loop
!   is not nested inside a teams construct (and executes on a non-host device); nested inside teams it is specified.
! "then the behavior of a reduction clause that appears on the corresponding loop construct is unspecified if the
!   construct is not nested inside a teams construct." (5.2 §11.7.1 p.259 l.5-7)
! spec (this program): The loop bind(teams) reduction(+: r) is strictly nested in the teams region of target teams,
!   the case the restriction leaves specified, so r must be 55; amdflang rejects the reduction.

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

error: Semantic errors in afar-flang-loop-bind-teams-reduction.f90
afar-flang-loop-bind-teams-reduction.f90:6:28: error: 'REDUCTION' clause not allowed with '!$OMP LOOP BIND(TEAMS)'.
      !$omp loop bind(teams) reduction(+: r)
                             ^^^^^^^^^^^^^^^

What the specification requires

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

OpenMP 5.2 §11.7 p.257 l.4

bind, collapse, lastprivate, order, private, reduction

OpenMP 5.2 §11.7.1 p.259 l.5-7

then the behavior of a reduction clause that appears on the corresponding loop construct is unspecified if the construct is not nested inside a teams construct.

Evidence

Same compiler, one change

  • bind(teams) removed (the loop binds to the teams region by default): 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 p
      implicit none
      integer :: r, i
      r = 0
      !$omp target teams map(tofrom: r)
        !$omp loop reduction(+: r)
        do i = 1, 10
          r = r + i
        end do
      !$omp end target teams
      print *, 'r =', r
    end program p
    

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