Observed issues › harvest/afar-flang-strided-target-update
Appears to behave incorrectlyWrong answer · Fortran · OpenMP · Open
amdflang: target update from a strided array section copies the whole array
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 | behaves incorrectly | behaves incorrectly | unknown not run | behaves incorrectly | behaves incorrectly | n/a | n/a |
| CCE 19.0.0 | fails another way | fails another way | unknown not run | unknown not run | unknown not run | n/a | n/a |
| CCE 20.0.2 | fails another way | fails another way | unknown not run | unknown not run | unknown not run | n/a | n/a |
| CCE 21.0.3 | fails another way | fails another way | unknown not run | unknown not run | unknown not run | n/a | n/a |
| CCE 21.0.4 | fails another way | fails another way | 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 | AFAR 24.3.0, MI300A unified | showa: 11.0 12.0 13.0 14.0 15.0 16.0 17.0 18.0 strided bad= 4 contiguous bad= 4 RESULT ran_on_host=0 check=fail |
| behaves incorrectly | AFAR 24.3.0, MI300A copy AFAR 24.3.0, MI300X AFAR 24.3.0, MI350X | showa: 11.0 12.0 13.0 14.0 15.0 16.0 17.0 18.0 strided bad= 4 contiguous bad= 0 RESULT ran_on_host=0 check=fail |
| fails another way | CCE 19.0.0, MI300A unified CCE 19.0.0, MI300A copy | showWarning:
Headers and libraries from cray-libsci/25.03.0 will be ignored because depends on PE_MPICH which is unavailable..
!$omp target update from(a(1:7:2))
^
ftn-1747 ftn: ERROR STRIDED_F, File = site-harvest--afar-flang-strided-target-update.f90, Line = 69, Column = 29
The stride specified for array "A" must not be greater than 1. Subarray references in the MAP clause must be to contiguous memory.
Cray Fortran : 93 source lines
Cray Fortran : 1 errors, 0 warnings, 0 other messages, 0 ansi |
| fails another way | CCE 20.0.2, MI300A unified CCE 20.0.2, MI300A copy | showWarning:
Headers and libraries from cray-libsci/25.09.0 will be ignored because depends on PE_MPICH which is unavailable..
!$omp target update from(a(1:7:2))
^
ftn-1747 ftn: ERROR STRIDED_F, File = site-harvest--afar-flang-strided-target-update.f90, Line = 69, Column = 29
The stride specified for array "A" must not be greater than 1. Subarray references in the MAP clause must be to contiguous memory.
Cray Fortran : 93 source lines
Cray Fortran : 1 errors, 0 warnings, 0 other messages, 0 ansi |
| fails another way | CCE 21.0.3, MI300A unified CCE 21.0.3, MI300A copy CCE 21.0.4, MI300A unified CCE 21.0.4, MI300A copy | showWarning:
Headers and libraries from cray-libsci/26.03.0 will be ignored because depends on PE_MPICH which is unavailable..
!$omp target update from(a(1:7:2))
^
ftn-1747 ftn: ERROR STRIDED_F, File = site-harvest--afar-flang-strided-target-update.f90, Line = 69, Column = 29
The stride specified for array "A" in the MAP clause must not be greater than 1.
Cray Fortran : 93 source lines
Cray Fortran : 1 errors, 0 warnings, 0 other messages, 0 ansi |
| fails another way | NVHPC 25.11, A100 separate NVHPC 25.11, A100 managed NVHPC 26.9, A100 separate NVHPC 26.9, A100 managed | showNVFORTRAN-S-0034-Syntax error at or near : (site-harvest--afar-flang-strided-target-update.f90: 69) 0 inform, 0 warnings, 1 severes, 0 fatal for strided_f |
| 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 | showsite-harvest--afar-flang-strided-target-update.f90:69:28:
69 | !$omp target update from(a(1:7:2))
| 1~~~~~~~
Error: Array is not contiguous at (1)
site-harvest--afar-flang-strided-target-update.f90:69:28:
69 | !$omp target update from(a(1:7:2))
| 1~~~~~~~
Error: Stride should not be specified for array section in FROM clause at (1) |
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
Program (93 lines)
! # Finding: AFAR amdflang ignores the stride of a Fortran array
! # section in `target update`: from(a(1:7:2)) copies all of a
!
! - compilers: AFAR amdflang 24.0.0git (drop 24.3.0), -O2: MI300A gfx942
! (HSA_XNACK=0; gate below) and MI250X gfx90a (HSA_XNACK=0; one probe of
! three runs, not gated)
! - expected: a: 11.0 2.0 13.0 4.0 15.0 6.0 17.0 8.0
! / strided bad= 0 contiguous bad= 0
! - actual: a: 11.0 12.0 13.0 14.0 15.0 16.0 17.0 18.0
! / strided bad= 4 (every element of a, a(8) too, comes back)
! (results/harvest/probe/gate/afar-flang-strided.r*.jsonl; gfx90a:
! results/harvest/probe/f1f2.jsonl, strided_f.f90)
! - gate (four environments on gfx942 X0, tools/campaigns/harvest_probe.py
! --gate-envs, offload.engine.gate.judge): the stored run (three repeats) and
! (a), (b), (d) on <host>, (c) on <host>: the same wrong
! answer in every run; confirmed.
! - rule: "The list items may include array sections with stride
! expressions ... If a list item is an array or array section then it is
! treated as if it is replaced by each of its array elements in the
! clause" (OpenMP 5.2 §5.9 p.165 l.13-17); a(1:7:2) is a(1), a(3), a(5),
! a(7) (a subscript triplet, Fortran 2008 6.5.3.3.2).
! - copy mode only: with storage shared between host and device
! (HSA_XNACK=1) every device write is visible, so elements outside the
! section may differ legitimately.
! - same-compiler controls (correct): update from(b(1:4)) (contiguous);
! AFAR amdclang's C form from(a[0:4:2]) (harvest/cce-c-strided-target-update.c).
! - other families: none runs it: CCE ftn 19.0.0, 20.0.2, 21.0.3 reject it
! ("ftn-1747: The stride specified for array "A" in the MAP clause must
! not be greater than 1", although its man page says "Non-contiguous
! updates are supported for normal array slice expressions that specify a
! lower bound, upper bound, and optional stride"); NVHPC nvfortran 25.11
! and 26.9 reject it (NVFORTRAN-S-0034 syntax error at the stride).
! - legality: legal by the quoted spec text only (no independent compiler
! witness: AFAR is the compiler under test, and CCE and NVHPC reject the
! stride). offload.engine.rules with the race rule accepts it. 5.2 §5.9 allows
! strided array sections in motion clauses; the map clause's contiguity
! restriction (CCE's ftn-1747 speaks of "the MAP clause") does not apply
! to `target update`. CCE's rejection is the finding
! fuzz/s1-6888-cce21.f90 (ftn-1747); NVHPC's is a candidate defect. That
! finding calls AFAR correct on its strided `to`: its program checks the
! updated elements only, where an ignored stride would not show.
! - found by: while reducing the CCE C strided-update failures of
! llvm-project offload/test/offloading/strided_update/ (no Fortran test
! there).
! AFAR: amdflang -fopenmp --offload-arch=gfx942 -O2
! Run: OMP_TARGET_OFFLOAD=mandatory HSA_XNACK=0 ./a.out
program strided_f
use omp_lib
implicit none
real(8) :: a(8), b(8)
integer :: i, bad_a, bad_b, on_host
do i = 1, 8
a(i) = i
b(i) = i
end do
on_host = 1
!$omp target data map(to: a, b)
!$omp target map(from: on_host)
if (omp_is_initial_device()) then
on_host = 1
else
on_host = 0
end if
do i = 1, 8
a(i) = a(i) + 10
b(i) = b(i) + 10
end do
!$omp end target
!$omp target update from(a(1:7:2))
!$omp target update from(b(1:4))
!$omp end target data
bad_a = 0
bad_b = 0
do i = 1, 8
if (mod(i, 2) == 1) then
if (a(i) /= i + 10) bad_a = bad_a + 1
else
if (a(i) /= i) bad_a = bad_a + 1
end if
if (i <= 4) then
if (b(i) /= i + 10) bad_b = bad_b + 1
else
if (b(i) /= i) bad_b = bad_b + 1
end if
end do
print '(a,8f6.1)', 'a:', a
print '(a,i0,a,i0)', 'strided bad= ', bad_a, ' contiguous bad= ', bad_b
if (bad_a == 0) then
print '(a,i0,a)', 'RESULT ran_on_host=', on_host, ' check=pass'
else
print '(a,i0,a)', 'RESULT ran_on_host=', on_host, ' check=fail'
end if
end program strided_f
Something to add? Dispute its legality · Report it fixed in a newer release · Report a mistake on this page
Expected and observed
Expected
a: 11.0 2.0 13.0 4.0 15.0 6.0 17.0 8.0
Observed where it behaves incorrectly
a: 11.0 12.0 13.0 14.0 15.0 16.0 17.0 18.0 strided bad= 4 contiguous bad= 4 RESULT ran_on_host=0 check=fail
What the specification requires
The specification text this program relies on and the compiler is expected to support.
OpenMP 5.2 §5.9 p.165 l.13-17
The list items may include array sections with stride expressions ... If a list item is an array or array section then it is treated as if it is replaced by each of its array elements in the clause
OpenMP 5.2 §5.9