OffTarget

Observed issues › catalog/afar-flang-workdistribute-ice

Appears to behave incorrectlyCompiler crash · Fortran · OpenMP · Open

amdflang -fopenmp-version=60: compiler crash in MapInfoOp for target teams workdistribute

Legality: independently confirmed. 2 independent readings find the program legal and the result required. How this is checked

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.0behaves incorrectlybehaves incorrectlybehaves incorrectlybehaves incorrectlybehaves incorrectlyn/an/a
CCE 19.0.0fails another wayfails another wayfails another wayunknown
not run
unknown
not run
n/an/a
CCE 20.0.2fails another wayfails another wayfails another wayunknown
not run
unknown
not run
n/an/a
CCE 21.0.3fails another wayfails another wayfails another wayunknown
not run
unknown
not run
n/an/a
CCE 21.0.4fails another wayfails another wayfails another wayunknown
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.0fails another wayfails another wayfails another wayfails another wayfails another wayfails another wayn/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 incorrectlyAFAR 24.3.0, MI300A unified
AFAR 24.3.0, MI300A copy
show
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0.	Program arguments: $AFAR/lib/llvm/bin/flang-24 -fc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -fno-color-diagnostics -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu x86-64 -vectori
 #0 0x0000155543273e6a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) ($AFAR/lib/llvm/bin/../lib/libLLVM.so.24.0git+0x88ce6a)
 #1 0x0000155543270b46 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #2 0x0000155555116990 __restore_rt (/lib64/libpthread.so.0+0x12990)
 #3 0x000015554d667087 mlir::omp::MapInfoOp::getODSOperandIndexAndLength(unsigned int) ($AFAR/lib/llvm/bin/../lib/libMLIR.so.24.0git+0x3cf8087)
 #4 0x000015554f23a00c checkIfPointerMap(mlir::omp::MapInfoOp) OpenMPToLLVMIRTranslation.cpp:0:0
behaves incorrectlyAFAR 24.3.0, MI250X
show
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0.	Program arguments: $AFAR/lib/llvm/bin/flang-24 -fc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -fno-color-diagnostics -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu x86-64 -vectori
 #0 0x0000155543273e6a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) ($AFAR/lib/llvm/lib/libLLVM.so.24.0git+0x88ce6a)
 #1 0x0000155543270b46 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #2 0x0000155555116990 __restore_rt (/lib64/libpthread.so.0+0x12990)
 #3 0x000015554d66710c mlir::omp::MapInfoOp::getODSOperandIndexAndLength(unsigned int) ($AFAR/lib/llvm/lib/libMLIR.so.24.0git+0x3cf810c)
 #4 0x000015554f23a00c checkIfPointerMap(mlir::omp::MapInfoOp) OpenMPToLLVMIRTranslation.cpp:0:0
behaves incorrectlyAFAR 24.3.0, MI300X
show
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0.	Program arguments: $AFAR/lib/llvm/bin/flang-24 -fc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -fno-color-diagnostics -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu x86-64 -vectori
 #0 0x00007fdb9c28ce6a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) $AFAR/lib/llvm/lib/libLLVM.so.24.0git+0x88ce6a)
 #1 0x00007fdb9c289b46 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #2 0x00007fdb9b23ebf0 __restore_rt (/lib64/libc.so.6+0x3ebf0)
 #3 0x00007fdba66f810c mlir::omp::MapInfoOp::getODSOperandIndexAndLength(unsigned int) $AFAR/lib/llvm/lib/libMLIR.so.24.0git+0x3cf810c)
 #4 0x00007fdba82cb00c checkIfPointerMap(mlir::omp::MapInfoOp) OpenMPToLLVMIRTranslation.cpp:0:0
behaves incorrectlyAFAR 24.3.0, MI350X
show
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0.	Program arguments: $AFAR/lib/llvm/bin/flang-24 -fc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -fno-color-diagnostics -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu x86-64 -vectori
 #0 0x00007f0959e8ce6a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) $AFAR/lib/llvm/lib/libLLVM.so.24.0git+0x88ce6a)
 #1 0x00007f0959e89b46 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #2 0x00007f0958e3fc30 __restore_rt (/lib64/libc.so.6+0x3fc30)
 #3 0x00007f09642f8087 mlir::omp::MapInfoOp::getODSOperandIndexAndLength(unsigned int) $AFAR/lib/llvm/lib/libMLIR.so.24.0git+0x3cf8087)
 #4 0x00007f0965ecb00c checkIfPointerMap(mlir::omp::MapInfoOp) OpenMPToLLVMIRTranslation.cpp:0:0
fails another wayCCE 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..
  !$omp target teams workdistribute map(to: a) map(from: b) default(none) shared(a, b, on_dev)
                     ^                                                                         
ftn-1519 ftn: ERROR GEN_PROG, File = afar-flang-workdistribute-ice.f90, Line = 27, Column = 22 
  Invalid clause "WORKDISTRIBUTE" for directive !$OMP TARGET TEAMS.  Valid clauses: IF, PRIVATE, SHARED, FIRSTPRIVATE, DEFAULT, REDUCTION, DEVICE, HAS_DEVICE_ADDR, MAP, NUM_TEAMS, THREAD_LIMIT, DEPEND
  !$omp end target teams workdistribute
                         ^              
fails another wayCCE 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..
  !$omp target teams workdistribute map(to: a) map(from: b) default(none) shared(a, b, on_dev)
                     ^                                                                         
ftn-1519 ftn: ERROR GEN_PROG, File = afar-flang-workdistribute-ice.f90, Line = 27, Column = 22 
  Invalid clause "WORKDISTRIBUTE" for directive !$OMP TARGET TEAMS.  Valid clauses: IF, PRIVATE, SHARED, FIRSTPRIVATE, DEFAULT, REDUCTION, DEVICE, HAS_DEVICE_ADDR, MAP, NUM_TEAMS, THREAD_LIMIT, DEPEND
  !$omp end target teams workdistribute
                         ^              
fails another wayCCE 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..
  !$omp target teams workdistribute map(to: a) map(from: b) default(none) shared(a, b, on_dev)
                     ^                                                                         
ftn-1519 ftn: ERROR GEN_PROG, File = afar-flang-workdistribute-ice.f90, Line = 27, Column = 22 
  Invalid clause "WORKDISTRIBUTE" for directive !$OMP TARGET TEAMS.  Valid clauses: IF, PRIVATE, SHARED, FIRSTPRIVATE, DEFAULT, REDUCTION, DEVICE, HAS_DEVICE_ADDR, MAP, NUM_TEAMS, THREAD_LIMIT, DEPEND
  !$omp end target teams workdistribute
                         ^              
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 workdistribute (afar-flang-workdistribute-ice.f90: 27)
NVFORTRAN-S-0034-Syntax error at or near identifier workdistribute (afar-flang-workdistribute-ice.f90: 29)
  0 inform,   0 warnings,   2 severes, 0 fatal for gen_prog
fails another wayGCC 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
show
afar-flang-workdistribute-ice.f90:27:22:
   27 |   !$omp target teams workdistribute map(to: a) map(from: b) default(none) shared(a, b, on_dev)
      |                      1
Error: Failed to match clause at (1)
afar-flang-workdistribute-ice.f90:29:25:
   29 |   !$omp end target teams workdistribute
      |                         1
Error: Unexpected junk at (1)

Reproduce

AFAR 24.3.0, MI300A unified

$AFAR/bin/amdflang -fopenmp --offload-arch=gfx942 -fopenmp-version=60 -fopenmp-version=60 -O2 repro.f90 -o repro
HSA_XNACK=1 OMP_TARGET_OFFLOAD=mandatory ./repro
Program (65 lines)
! # Draft finding: omp60-directive-target_teams_workdistribute on afar
!
! - compiler: afar
! - toolchain: afar; arch: gfx942; machine: tuolumne; memory mode: unified; opt: -O2
! - program: catalog omp60-directive-target_teams_workdistribute (f90, version 60, sha256 d86b846044944953)
! - expected: None (None; )
! - actual: ice  (ice: PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace
!   and instructions to reproduce the bug.)
! - 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 (legal by construction: offload.engine.gen / c_gen / acc_gen check every program against the catalog rules
!   and the
!   offload scope as it is built (no compiler))
! - witnesses: none
! - withdrawn: none
!
! Generated by compliance.gen (OpenMP 6.0, free-form Fortran). Do not edit.
! id: omp60-directive-target_teams_workdistribute
! primary atom: omp.directive.target_teams_workdistribute
! legal: yes
! observable: yes
! ran_on_host: probe (a target region just before the region of interest, which may not call the OpenMP API)
! evidence: construct
! needs: none
! std: f2008
! unverified: no toolchain compiles this (6.0 workdistribute), so the on_dev evidence is untested here
! derivation (check=pass): on_dev is a declare_target variable: the first target region sets the device's copy to 1, and it keeps
! derivation: its value on the device; target teams workdistribute divides the array assignment b = 2*a + on_dev into units of work
! derivation: each executed once (6.0 §13.5 p.412), so b(i) = 2*i + 1 on the device, mapped from: b = ref; the check accepts
module gen_mod
  implicit none
  integer :: on_dev = 0
  !$omp declare target(on_dev)
end module gen_mod

program gen_prog
  use omp_lib, only: omp_is_initial_device
  use gen_mod
  implicit none
  integer, parameter :: n = 64
  integer, allocatable, target :: a(:), b(:)
  integer :: ref(n)
  integer :: i, host_flag
  logical :: ok
  allocate(a(n), b(n))
  do i = 1, n
    a(i) = i
    b(i) = 0
    ref(i) = 2*i + 1
  end do
  host_flag = 1
  !$omp target map(tofrom: host_flag)
    host_flag = merge(1, 0, omp_is_initial_device())
    on_dev = 1
  !$omp end target
  !$omp target teams workdistribute map(to: a) map(from: b) default(none) shared(a, b, on_dev)
    b = 2*a + on_dev
  !$omp end target teams workdistribute
  if (all(b == 2*a)) host_flag = 1
  ok = all(b == ref)
  print '(a,i0,a,a)', 'RESULT ran_on_host=', host_flag, ' check=', merge('pass', 'fail', ok)
  deallocate(a, b)
end program gen_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

PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0.	Program arguments: $AFAR/lib/llvm/bin/flang-24 -fc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -fno-color-diagnostics -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu x86-64 -vectori
 #0 0x0000155543273e6a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) ($AFAR/lib/llvm/bin/../lib/libLLVM.so.24.0git+0x88ce6a)
 #1 0x0000155543270b46 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #2 0x0000155555116990 __restore_rt (/lib64/libpthread.so.0+0x12990)
 #3 0x000015554d667087 mlir::omp::MapInfoOp::getODSOperandIndexAndLength(unsigned int) ($AFAR/lib/llvm/bin/../lib/libMLIR.so.24.0git+0x3cf8087)
 #4 0x000015554f23a00c checkIfPointerMap(mlir::omp::MapInfoOp) OpenMPToLLVMIRTranslation.cpp:0:0

What the specification requires

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

OpenMP 6.0 §13.5 p.412

Evidence

Same compiler, one change

  • a plain target construct around the array assignment instead of target teams workdistribute: 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
    module gen_mod
      implicit none
      integer :: on_dev = 0
      !$omp declare target(on_dev)
    end module gen_mod
    
    program gen_prog
      use omp_lib, only: omp_is_initial_device
      use gen_mod
      implicit none
      integer, parameter :: n = 64
      integer, allocatable, target :: a(:), b(:)
      integer :: ref(n)
      integer :: i, host_flag
      logical :: ok
      allocate(a(n), b(n))
      do i = 1, n
        a(i) = i
        b(i) = 0
        ref(i) = 2*i + 1
      end do
      host_flag = 1
      !$omp target map(tofrom: host_flag)
        host_flag = merge(1, 0, omp_is_initial_device())
        on_dev = 1
      !$omp end target
      !$omp target map(to: a) map(from: b)
        b = 2*a + on_dev
      !$omp end target
      if (all(b == 2*a)) host_flag = 1
      ok = all(b == ref)
      print '(a,i0,a,a)', 'RESULT ran_on_host=', host_flag, ' check=', merge('pass', 'fail', ok)
      deallocate(a, b)
    end program gen_prog