Observed issues › afar-flang-loop-bind-teams-reduction
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
| 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 | not supported | not supported | not supported | not supported | not supported | n/a | n/a |
| CCE 19.0.0 | correct | correct | correct | unknown not run | unknown not run | n/a | n/a |
| CCE 20.0.2 | correct | correct | correct | unknown not run | unknown not run | n/a | n/a |
| CCE 21.0.3 | correct | correct | correct | unknown not run | unknown not run | n/a | n/a |
| CCE 21.0.4 | correct | correct | correct | unknown not run | unknown not run | n/a | n/a |
| NVHPC 25.11 | n/a | n/a | n/a | n/a | n/a | correct | correct |
| NVHPC 26.9 | n/a | n/a | n/a | n/a | n/a | correct | correct |
| GCC 16.2.0 | correct | correct | correct | correct | correct | correct | 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 |
|---|---|---|
| not supported | AFAR 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 | showerror: 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.
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