Observed issues › catalog/afar-flang-absent-optional-target-crash
Appears to behave incorrectlyCrashes or aborts at run time · Fortran · OpenMP · Open · regression
An absent OPTIONAL dummy array referenced with PRESENT() in a target region crashes the run
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 | behaves incorrectly | behaves incorrectly | behaves incorrectly | 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 |
|---|---|---|
| behaves incorrectly | AFAR 24.3.0, MI300A unified | showomptarget error: Call to getTargetPointer returned null pointer (device failure or illegal mapping). omptarget error: Call to targetDataBegin failed, abort target. omptarget error: Failed to process data before launching the kernel. omptarget error: Consult https://openmp.llvm.org/design/Runtimes.html for debugging options. omptarget error: Source location information not present. Compile with -g or -gline-tables-only. omptarget fatal error 1: failure of target construct while offloading is mandatory |
| behaves incorrectly | AFAR 24.3.0, MI300A copy AFAR 24.3.0, MI250X | showRUN_FAIL |
| behaves incorrectly | AFAR 24.3.0, MI300X AFAR 24.3.0, MI350X | showtimeout: the monitored command dumped core |
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 (70 lines)
! # Draft finding: omp52-w-optional-absent on afar
!
! - compiler: afar
! - toolchain: afar; arch: gfx942; machine: tuolumne; memory mode: unified; opt: -O2
! - program: catalog omp52-w-optional-absent (f90, version 52, sha256 a951b1f34bd1c3af)
! - expected: check=pass (trusted; elision + model)
! - actual: crash (crash: SIGABRT; without mandatory: crash: SIGABRT)
! - verdict: compiler_bug by rule R20-runtime-bug: a legal program fails at run time, deterministically, against an expected value
! from two or more independent sources with an executed witness, and another toolchain, mode, arch or the elision gives the
! expected value
! - reason: expected trusted check=pass (elision + model): stored main verdict: elision + model agree; witnesses:
! cce19/gfx942/unified, cce20/gfx942/unified, cce21/gfx942/unified, elision
! - citations: RUL-DERIVED-NEEDS-EXECUTION (rulings.md); RUL-WITNESS-PER-MODE (rulings.md);
! RUL-SAME-COMPILER-RUNS (rulings.md); RUL-PRESENCE-WITNESS (rulings.md); RUL-METAMORPHIC-OTHER-FAMILY
! (rulings.md)
! - legality: legal: 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
! - witnesses: cce19/gfx942/unified, cce20/gfx942/unified, cce21/gfx942/unified, elision
! - withdrawn: none
!
! Generated by compliance.widen (OpenMP 5.2, free-form Fortran; catalog widening). Do not edit.
! id: omp52-w-optional-absent
! primary atom: base.device.optional_absent
! atoms: base.device.optional_absent
! legal: yes
! observable: yes
! ran_on_host: inside the target region of interest
! evidence: construct
! needs: none
! std: f2008
! feature: an absent OPTIONAL dummy array referenced with PRESENT() in a target region of the procedure
! spec: OpenMP 5.2 §3.2.1, p.61: a list item that is an absent optional dummy is ignored, and the data-sharing and data-mapping
! rules of an absent optional referenced in a construct are ignored
program wide_prog
use omp_lib, only: omp_is_initial_device
implicit none
integer, parameter :: n = 64
integer :: a(n), b(n), ref(n)
integer :: i, host_flag
logical :: ok
do i = 1, n
a(i) = i
b(i) = 0
ref(i) = 2*i + 1
end do
host_flag = 1
call work(a, b, host_flag)
ok = all(b == ref)
print '(a,i0,a,a)', 'RESULT ran_on_host=', host_flag, ' check=', merge('pass', 'fail', ok)
contains
subroutine work(x, y, hf, c)
integer, intent(in) :: x(n)
integer, intent(inout) :: y(n)
integer, intent(inout) :: hf
integer, intent(in), optional :: c(n)
integer :: k
!$omp target teams distribute parallel do map(to: x) map(tofrom: y, hf)
do k = 1, n
if (present(c)) then
y(k) = x(k) + c(k)
else
y(k) = 2*x(k) + 1
end if
if (k == 1) hf = merge(1, 0, omp_is_initial_device())
end do
!$omp end target teams distribute parallel do
end subroutine work
end program wide_prog
Something to add? Dispute its legality · Report it fixed in a newer release · Report a mistake on this page
Expected and observed
Expected
check=pass
Observed where it behaves incorrectly
omptarget error: Call to getTargetPointer returned null pointer (device failure or illegal mapping). omptarget error: Call to targetDataBegin failed, abort target. omptarget error: Failed to process data before launching the kernel. omptarget error: Consult https://openmp.llvm.org/design/Runtimes.html for debugging options. omptarget error: Source location information not present. Compile with -g or -gline-tables-only. omptarget fatal error 1: failure of target construct while offloading is mandatory
What the specification requires
The specification text this program relies on and the compiler is expected to support.
OpenMP 5.2 §3.2.1 p.61
Evidence
Same compiler, one change
- the PRESENT(c) branch removed (the absent dummy is not referenced in the region): 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 wide_prog use omp_lib, only: omp_is_initial_device implicit none integer, parameter :: n = 64 integer :: a(n), b(n), ref(n) integer :: i, host_flag logical :: ok do i = 1, n a(i) = i b(i) = 0 ref(i) = 2*i + 1 end do host_flag = 1 call work(a, b, host_flag) ok = all(b == ref) print '(a,i0,a,a)', 'RESULT ran_on_host=', host_flag, ' check=', merge('pass', 'fail', ok) contains subroutine work(x, y, hf, c) integer, intent(in) :: x(n) integer, intent(inout) :: y(n) integer, intent(inout) :: hf integer, intent(in), optional :: c(n) integer :: k !$omp target teams distribute parallel do map(to: x) map(tofrom: y, hf) do k = 1, n y(k) = 2*x(k) + 1 if (k == 1) hf = merge(1, 0, omp_is_initial_device()) end do !$omp end target teams distribute parallel do end subroutine work end program wide_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