Observed issues › harvest/cce21-declare-target-link-module-variable-write-lost
ftn 21 loses a target region's write to a declare target link module variable mapped tofrom
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 | correct | correct | unknown not run | correct | correct | n/a | n/a |
| CCE 19.0.0 | correct | correct | unknown not run | unknown not run | unknown not run | n/a | n/a |
| CCE 20.0.2 | correct | correct | unknown not run | unknown not run | unknown not run | n/a | n/a |
| CCE 21.0.3 | behaves incorrectly | behaves incorrectly | unknown not run | unknown not run | unknown not run | n/a | n/a |
| CCE 21.0.4 | behaves incorrectly | behaves incorrectly | 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 | 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 |
|---|---|---|
| behaves incorrectly | CCE 21.0.3, MI300A unified CCE 21.0.3, MI300A copy CCE 21.0.4, MI300A unified CCE 21.0.4, MI300A copy | showv= 0 dev= T RESULT ran_on_host=0 check=fail |
Reproduce
CCE 21.0.3, MI300A unified
module load cce/21.0.3 craype-accel-amd-gfx942 rocm/7.2.0 module unload cray-mpich ftn -fopenmp -O2 repro.f90 -o repro HSA_XNACK=1 OMP_TARGET_OFFLOAD=mandatory ./repro
CCE 21.0.4, MI300A unified
module load cce/21.0.4 craype-accel-amd-gfx942 rocm/7.2.0 module unload cray-mpich ftn -fopenmp -O2 repro.f90 -o repro HSA_XNACK=1 OMP_TARGET_OFFLOAD=mandatory ./repro
AFAR 24.3.0, MI300A unified (runs correctly)
$AFAR/bin/amdflang -fopenmp --offload-arch=gfx942 -O2 repro.f90 -o repro HSA_XNACK=1 OMP_TARGET_OFFLOAD=mandatory ./repro
Program (60 lines)
! # Finding: CCE 21 ftn loses the target region's write to a module
! # variable in a declare target link clause that the target construct maps
! # tofrom (CCE 19 and 20 correct)
!
! - compilers: CCE ftn 21.0.3 and 21.0.4, -O2: this file on MI300A gfx942
! (HSA_XNACK 0 and 1); the two AOMP tests it comes from also on MI250X
! gfx90a with 21.0.3.
! - expected: v= 1 dev= T
! - actual: v= 0 dev= T (the region runs on the device; the original v keeps
! its value), every run, both memory modes.
! - rule: the link clause "does not map the list items. Instead, they are
! mapped according to the data-mapping rules described in Section 5.8"
! (5.2 §5.8.5 p.159 l.24-27), so map(tofrom: v) on the target construct
! maps v with a reference count of one and on exit "the original list item
! is updated as if the list item appeared in a from clause on a target
! update directive" (5.2 §5.8.3 p.154 l.3-5). OpenMP 4.5 already has the
! link clause.
! - regression: CCE 19.0.0 and 20.0.2 print v= 1 dev= T (gfx942 both modes;
! gfx90a).
! - same-compiler controls (CCE 21.0.3 and 21.0.4 correct, v= 1 dev= T):
! the same map on an enclosing target data construct (target data
! map(tofrom: v), then target without a map of v); v without the declare
! target directive. (With enter(v) instead of link(v) v= 0 is the expected
! result: the variable is present for the whole program and the exit update
! happens only at a reference count of one, 5.2 §5.8.3 p.154 l.3-5; AFAR and
! CCE 21 print v= 0, CCE 19 and 20 reject enter.)
! - other families: AFAR amdflang prints v= 1 dev= T (gfx942 X0 and X1,
! gfx90a).
! - harvest: dev programs h2-aomp-smoke-fort-declare-target-link-2 and
! h2-aomp-fortran-map-tests-even-basicer-example (data/bench/harvest2; AOMP
! test/smoke-fort/declare-target-link-2 and
! test/fortran-map-tests/even-basicer-example.f95), wrong_answer on CCE 21
! only, gate confirmed on gfx90a.
! - legality: offload.engine.prerun.check accepts it (the rules with the race
! rule, and the AFAR flang front end).
! CCE: ftn -fopenmp -O2 (module load cce/<v> craype-accel-amd-gfx942 rocm/<r>;
! module unload cray-mpich)
! Run: OMP_TARGET_OFFLOAD=mandatory ./a.out
module m
implicit none
integer :: v = 0
!$omp declare target link(v)
end module m
program p
use m
use omp_lib
implicit none
logical :: dev
dev = .false.
!$omp target map(tofrom: v) map(from: dev)
v = 1
dev = .not. omp_is_initial_device()
!$omp end target
print '(a,i0,a,l1)', 'v= ', v, ' dev= ', dev
if (v == 1) then
print '(a,i0,a)', 'RESULT ran_on_host=', merge(0, 1, dev), ' check=pass'
else
print '(a,i0,a)', 'RESULT ran_on_host=', merge(0, 1, dev), ' check=fail'
end if
end program p
Something to add? Dispute its legality · Report it fixed in a newer release · Report a mistake on this page
Expected and observed
Expected
v= 1 dev= T
Observed where it behaves incorrectly
v= 0 dev= T 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.8.5 p.159 l.24-27
does not map the list items. Instead, they are mapped according to the data-mapping rules described in Section 5.8
OpenMP 5.2 §5.8.3 p.154 l.3-5
the original list item is updated as if the list item appeared in a from clause on a target update directive
OpenMP 5.2 §5.8.3 p.154 l.3-5
Evidence
Other compilers run it correctly
AFAR 24.3.0, NVHPC 25.11, NVHPC 26.9, GCC 16.2.0