OffTarget

Observed issues › catalog/cce-flang-allocate-const-mem-ice

Appears to behave incorrectlyCompiler crash · Fortran · OpenMP · Open

ftn: internal compiler error "Too few arguments on the stack" for uses_allocators with an allocate clause in a target region

Legality: not independently confirmed. no independent review yet How this is checked

Same issue as catalog/cce-allocators-stack-ice; this program is another reproducer of it.

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.0fails another wayfails another wayfails another wayfails another wayfails another wayn/an/a
CCE 19.0.0behaves incorrectlybehaves incorrectlybehaves incorrectlyunknown
not run
unknown
not run
n/an/a
CCE 20.0.2behaves incorrectlybehaves incorrectlybehaves incorrectlyunknown
not run
unknown
not run
n/an/a
CCE 21.0.3behaves incorrectlybehaves incorrectlybehaves incorrectlyunknown
not run
unknown
not run
n/an/a
CCE 21.0.4behaves incorrectlybehaves incorrectlybehaves incorrectlyunknown
not run
unknown
not run
n/an/a
NVHPC 25.11n/an/an/an/an/afails another wayfails another way
NVHPC 26.9n/an/an/an/an/afails another wayfails another way
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
behaves incorrectlyCCE 19.0.0, MI300A unified
CCE 19.0.0, MI300A copy
CCE 19.0.0, MI250X
show
Warning:
 Headers and libraries from cray-libsci/25.03.0 will be ignored because depends on PE_MPICH which is unavailable..
*** Expected 2 arguments but only 1 on stack
    Contents of the expression stack:
---TOP---
1
---BOT---
*** error ***
behaves incorrectlyCCE 20.0.2, MI300A unified
CCE 20.0.2, MI300A copy
CCE 20.0.2, MI250X
show
Warning:
 Headers and libraries from cray-libsci/25.09.0 will be ignored because depends on PE_MPICH which is unavailable..
*** Expected 2 arguments but only 1 on stack
    Contents of the expression stack:
---TOP---
1
---BOT---
*** error ***
behaves incorrectlyCCE 21.0.3, MI300A unified
CCE 21.0.3, MI300A copy
CCE 21.0.3, MI250X
CCE 21.0.4, MI300A unified
CCE 21.0.4, MI300A copy
CCE 21.0.4, MI250X
show
Warning:
 Headers and libraries from cray-libsci/26.03.0 will be ignored because depends on PE_MPICH which is unavailable..
*** Expected 2 arguments but only 1 on stack
    Contents of the expression stack:
---TOP---
1
---BOT---
*** error ***
fails another wayAFAR 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: loc("cce-flang-allocate-const-mem-ice.f90":17:9): /__w/TheRock/TheRock/compiler/amd-llvm/flang/lib/Lower/OpenMP/ClauseProcessor.h:246: not yet implemented: Unhandled clause USES_ALLOCATORS in T
LLVM ERROR: aborting
fails another wayNVHPC 25.11, A100 separate
NVHPC 25.11, A100 managed
NVHPC 26.9, A100 separate
NVHPC 26.9, A100 managed
show
NVFORTRAN-S-0034-Syntax error at or near identifier allocate (cce-flang-allocate-const-mem-ice.f90: 17)
  0 inform,   0 warnings,   1 severes, 0 fatal for wide_prog

Reproduce

CCE 19.0.0, MI300A unified

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

CCE 20.0.2, MI300A unified

module load cce/20.0.2 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

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

GCC 16.2.0, MI300A unified (runs correctly)

export LD_LIBRARY_PATH=$GCC_16_2/lib64:/opt/rocm-7.2.1/lib
$GCC_16_2/bin/gfortran -fopenmp -foffload=amdgcn-amdhsa -foffload-options=amdgcn-amdhsa=-march=gfx942 -O2 repro.f90 -o repro
HSA_XNACK=1 OMP_TARGET_OFFLOAD=mandatory ./repro
Program (59 lines)
! # Draft finding: omp52-w-allocate-const-firstprivate on cce19
!
! - compiler: cce19
! - toolchain: cce19; arch: gfx942; machine: tuolumne; memory mode: unified; opt: -O2
! - program: catalog omp52-w-allocate-const-firstprivate (f90, version 52, sha256 367be03382f737d3)
! - expected: None (None; )
! - actual: ice  (ice: INTERNAL COMPILER ERROR:  "Too few arguments on the stack" (/workspace/crayftn/pdgcs/v_fei.c, line 11730,
!   version cc4d36e4ff3377d45f0e6e892b5dacd82009a0ca))
! - verdict: compiler_bug by rule R10-compile-ice: an internal compiler error (or the compiler rejecting code it generated) on a
!   legal program: always the compiler's defect
! - reason: 
! - citations: RUL-COMPILE-TIME (rulings.md)
! - legality: legal: offload.engine.prerun.check accepts it (rerun: offload.engine.rules with the
!   race rule and the restriction checks, and the AFAR flang front end, not under test here); no
!   compiler under test, gfortran or gcc is a legality witness
! - witnesses: none
! - withdrawn: none
!
! Generated by compliance.widen (OpenMP 5.2, free-form Fortran; catalog widening). Do not edit.
! id: omp52-w-allocate-const-firstprivate
! primary atom: pair.omp.clause.allocate+omp.clause.firstprivate
! atoms: pair.omp.clause.allocate+omp.clause.firstprivate, omp.clause.allocate, omp.clause.firstprivate
! legal: yes
! observable: yes
! ran_on_host: inside the target region of interest
! evidence: construct
! needs: none
! std: f2008
! feature: a firstprivate scalar allocated with omp_const_mem_alloc (uses_allocators) on a target loop
! spec: OpenMP 5.2 §6.6 (allocate clause) and §13.8, p.285: an allocator in a uses_allocators clause may be used in an allocate
! clause on the target construct
! pair of: omp.clause.allocate + omp.clause.firstprivate (each has a program of its own)
program wide_prog
  use omp_lib, only: omp_is_initial_device
  use omp_lib, only: omp_const_mem_alloc
  implicit none
  integer, parameter :: n = 64
  integer :: a(n), b(n), ref(n)
  integer :: x
  integer :: i, host_flag
  logical :: ok
  do i = 1, n
    a(i) = i
    b(i) = 0
    ref(i) = i + 5
  end do
  host_flag = 1
  x = 5
  !$omp target teams distribute parallel do map(to: a) map(from: b) &
  !$omp& map(tofrom: host_flag) firstprivate(x) allocate(omp_const_mem_alloc: x) &
  !$omp& uses_allocators(omp_const_mem_alloc)
  do i = 1, n
    b(i) = a(i) + x
    if (i == 1) host_flag = merge(1, 0, omp_is_initial_device())
  end do
  !$omp end target teams distribute parallel do
  ok = all(b == ref)
  print '(a,i0,a,a)', 'RESULT ran_on_host=', host_flag, ' check=', merge('pass', 'fail', ok)
end program wide_prog

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

Warning:
 Headers and libraries from cray-libsci/25.03.0 will be ignored because depends on PE_MPICH which is unavailable..
*** Expected 2 arguments but only 1 on stack
    Contents of the expression stack:
---TOP---
1
---BOT---
*** error ***

What the specification requires

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

OpenMP 5.2 §6.6

OpenMP 5.2 §13.8 p.285

Evidence

Same compiler, one change

  • the allocate and uses_allocators clauses removed (x firstprivate only): 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
      use omp_lib, only: omp_const_mem_alloc
      implicit none
      integer, parameter :: n = 64
      integer :: a(n), b(n), ref(n)
      integer :: x
      integer :: i, host_flag
      logical :: ok
      do i = 1, n
        a(i) = i
        b(i) = 0
        ref(i) = i + 5
      end do
      host_flag = 1
      x = 5
      !$omp target teams distribute parallel do map(to: a) map(from: b) &
      !$omp& map(tofrom: host_flag) firstprivate(x)
      do i = 1, n
        b(i) = a(i) + x
        if (i == 1) host_flag = merge(1, 0, omp_is_initial_device())
      end do
      !$omp end target teams distribute parallel do
      ok = all(b == ref)
      print '(a,i0,a,a)', 'RESULT ran_on_host=', host_flag, ' check=', merge('pass', 'fail', ok)
    end program wide_prog
    

Other compilers run it correctly

GCC 16.2.0