OffTarget

Observed issues › fuzz/gcc-declare-reduction-module-not-found

Appears not to supportRefused at compile time · Fortran · OpenMP · Open

A declare reduction in a module is not found through use association

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

A user-defined reduction declared in a module's specification part is accessible through use association. GCC 16.2's Fortran front end rejects its use in a target teams distribute parallel do reduction clause ("!$OMP DECLARE REDUCTION padd not found"), for both offload targets and on the host. With the declare reduction directive in the program's own specification part the program compiles and runs correctly.

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 wayunknown
not run
correctcorrectn/an/a
CCE 19.0.0fails another wayfails another wayunknown
not run
unknown
not run
unknown
not run
n/an/a
CCE 20.0.2fails another wayfails another wayunknown
not run
unknown
not run
unknown
not run
n/an/a
CCE 21.0.3fails another wayfails another wayunknown
not run
unknown
not run
unknown
not run
n/an/a
CCE 21.0.4fails another wayfails another wayunknown
not run
unknown
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.0not supportednot supportednot supportednot supportednot supportednot supportedn/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
not supportedGCC 16.2.0, MI300A unified
GCC 16.2.0, MI300A copy
GCC 16.2.0, MI300X
GCC 16.2.0, MI350X
show
site-fuzz--gcc-declare-reduction-module-not-found.f90:50:54:
   50 |   !$omp target teams distribute parallel do reduction(padd: s) map(tofrom: s, host_flag)
      |                                                      1
Error: !$OMP DECLARE REDUCTION padd not found at (1)
not supportedGCC 16.2.0, MI250X
GCC 16.2.0, A100 separate
show
site-fuzz--gcc-declare-reduction-module-not-found.f90:39:54:
   39 |   !$omp target teams distribute parallel do reduction(padd: s) map(tofrom: s, host_flag)
      |                                                      1
Error: !$OMP DECLARE REDUCTION padd not found at (1)
fails another wayAFAR 24.3.0, MI300A unified
AFAR 24.3.0, MI300A copy
show
ld.lld: error: undefined symbol: flang_rt_verbose_abort(char const*, ...)
>>> referenced by <dir>:(std::__1::__throw_bad_variant_access[abi:nqn240000](char const*))
>>> referenced by <dir>:(std::__1::__throw_bad_variant_access[abi:nqn240000](char const*))
ld.lld: error: undefined symbol: Fortran::runtime::io::descr::DescriptorIoTicket<(Fortran::runtime::io::Direction)1>::Begin(Fortran::runtime::WorkQueue&)
>>> referenced by <dir>:(_FortranAInitialize)
>>> referenced by <dir>:(_FortranAInitialize)
ld.lld: error: undefined symbol: Fortran::runtime::io::descr::DescriptorIoTicket<(Fortran::runtime::io::Direction)0>::Begin(Fortran::runtime::WorkQueue&)
>>> referenced by <dir>:(_FortranAInitialize)
fails another wayCCE 19.0.0, MI300A unified
CCE 19.0.0, MI300A copy
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 distribute parallel do reduction(padd: s) map(tofrom: s, host_flag)
ftn-7032 ftn: ERROR UDR_USE_ASSOCIATION, File = site-fuzz--gcc-declare-reduction-module-not-found.f90, Line = 39 
  Unsupported OpenMP construct Calls -- $udr_i_1PAIR_M
fails another wayCCE 20.0.2, MI300A unified
CCE 20.0.2, MI300A copy
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 distribute parallel do reduction(padd: s) map(tofrom: s, host_flag)
ftn-7032 ftn: ERROR UDR_USE_ASSOCIATION, File = site-fuzz--gcc-declare-reduction-module-not-found.f90, Line = 39 
  Unsupported OpenMP construct Calls -- $udr_i_1PAIR_M
fails another wayCCE 21.0.3, MI300A unified
CCE 21.0.3, MI300A copy
CCE 21.0.4, MI300A unified
CCE 21.0.4, MI300A copy
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 distribute parallel do reduction(padd: s) map(tofrom: s, host_flag)
ftn-7032 ftn: ERROR UDR_USE_ASSOCIATION, File = site-fuzz--gcc-declare-reduction-module-not-found.f90, Line = 39 
  Unsupported OpenMP construct Calls -- $udr_i_1PAIR_M
fails another wayNVHPC 25.11, A100 separate
NVHPC 25.11, A100 managed
NVHPC 26.9, A100 separate
NVHPC 26.9, A100 managed
show
NVFORTRAN-W-0155-Unimplemented feature - DECLARE REDUCTION  (site-fuzz--gcc-declare-reduction-module-not-found.f90: 26)
  0 inform,   1 warnings,   0 severes, 0 fatal for pair_m
NVFORTRAN-S-0155-The reduction intrinsic must be MAX, MIN, IAND, IOR, or IEOR, not padd (site-fuzz--gcc-declare-reduction-module-not-found.f90: 39)
  0 inform,   0 warnings,   1 severes, 0 fatal for udr_use_association

Reproduce

GCC 16.2.0, MI300A unified

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

GCC 16.2.0, A100 separate

export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=$GCC_16_2/lib64
$GCC_16_2/bin/gfortran -fopenmp -foffload=nvptx-none -foffload-options=nvptx-none=-march=sm_80 -foffload-options=nvptx-none=-latomic -O2 repro.f90 -o repro
OMP_TARGET_OFFLOAD=mandatory ./repro

AFAR 24.3.0, MI300X (runs correctly)

$AFAR/bin/amdflang -fopenmp --offload-arch=gfx942 -O2 repro.f90 -o repro
HSA_XNACK=0 OMP_TARGET_OFFLOAD=mandatory ./repro
Program (58 lines)
! # Finding (GCC 16.2, fuzz sample): a declare reduction in a module is not found through use association
!
! - toolchains: gcc_g90 (GCC 16.2.0, AMD Instinct MI250X gfx90a, Tioga) and gcc_sm80 (GCC 16.2.0, NVIDIA A100 sm_80, wingtip);
!   separate memory only; -O2
! - build: gfortran -fopenmp -foffload=amdgcn-amdhsa -foffload-options=amdgcn-amdhsa=-march=gfx90a -O2 (gcc_g90);
!   -foffload=nvptx-none -foffload-options=nvptx-none=-march=sm_80 -foffload-options=nvptx-none=-latomic -O2 (gcc_sm80)
! - failure: rejected: !$OMP DECLARE REDUCTION padd not found
! - observed: `Error: !$OMP DECLARE REDUCTION padd not found at (1)` at the reduction clause, on both targets; the same happens on a
!   host parallel do
! - expected: compiles; prints `s%a= 5050 s%b= 100` and `RESULT ran_on_host=0 check=pass`
! - rule: "If the reduction identifier is defined in a declare reduction directive, the declare reduction directive must be in the
!   same subprogram, or accessible by host or use association" (5.2 §5.5.5 p.133 l.10-11): the directive is in module pair_m, which
!   the program uses.
! - same-compiler control (compiles; correct, gcc_sm80: mandatory pass 5 of 5; unset pass 5 of 5; gcc_g90: mandatory pass 5 of 5;
!   unset pass 5 of 5 (results/parity/<machine>/<tc>/probes.jsonl)): the same declare reduction directive in the program's own
!   specification part (controls/gcc-declare-reduction-module-control.f90).
! - GCC's documentation: no row of libgomp.texi's tables names it (undocumented; user-defined reductions are OpenMP 4.0's).
! - other families: no family runs this file: CCE 19/20/21/21.0.4 reject the reduction clause too, AFAR's front end accepts it and
!   its link fails (flang_rt_verbose_abort undefined) and NVHPC 25.11/26.9 do not implement declare reduction (site matrix); on the
!   fuzz programs every other family fails at another construct first. The claim rests on the rule and on GCC's own control. The
!   site's finding matrix runs this file on every compiler.
! - fuzz programs (380 cells (190 gcc_g90, 190 gcc_sm80); gate: confirmed 380; confirmer: needs_human (R12b-compile-undecided) 380):
!   n1:121, n1:22, n1:234, n1:31, n1:312, n1:362, n1:371, n1:41, n1:428, n1:430, n1:511, n1:748, n1:804, n1:809, n1:813, n1:832,
!   n1:841, n1:939, n1:944, n1:987, s1:1198, s1:1204, s1:1205, s1:1222, s1:1240, s1:1261, s1:1300, s1:1344, s1:1362, s1:1375,
!   s1:1455, s1:1556, s1:1610, s1:1631, s1:1723, s1:1727, s1:1802, s1:1849, s1:1899, s1:1957, and 150 more (the index entry lists
!   them)
! - legality: two witnesses that are neither GCC nor a compiler this finding is about, offload.engine.rules and AFAR flang's
!   front end,
!   accept this file and its control (offload.engine.prerun.check; results/parity/tioga/results/parity/legality.jsonl) and the fuzz
!   programs (the campaign's legality gate; its base-language check, gfortran -std=f2008 without OpenMP, is a syntax check of the
!   base language only and no witness). GCC is a compiler under test only and never a legality witness.
module pair_m
  implicit none
  type :: pair_t
    integer :: a, b
  end type pair_t
  !$omp declare reduction(padd: pair_t: omp_out = &
  !$omp& pair_t(omp_out%a + omp_in%a, omp_out%b + omp_in%b)) &
  !$omp& initializer(omp_priv = pair_t(0, 0))
end module pair_m

program udr_use_association
  use omp_lib, only: omp_is_initial_device
  use pair_m
  implicit none
  type(pair_t) :: s
  integer :: i, host_flag
  s = pair_t(0, 0)
  host_flag = 1
  !$omp target teams distribute parallel do reduction(padd: s) map(tofrom: s, host_flag)
  do i = 1, 100
    if (i == 1) host_flag = merge(1, 0, omp_is_initial_device())
    s%a = s%a + i
    s%b = s%b + 1
  end do
  print '(a,i0,a,i0)', 's%a= ', s%a, ' s%b= ', s%b
  print '(a,i0,a,a)', 'RESULT ran_on_host=', host_flag, ' check=', merge('pass', 'fail', s%a == 5050 .and. s%b == 100)
end program udr_use_association

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

Expected

check=pass

Observed where it behaves incorrectly

site-fuzz--gcc-declare-reduction-module-not-found.f90:50:54:
   50 |   !$omp target teams distribute parallel do reduction(padd: s) map(tofrom: s, host_flag)
      |                                                      1
Error: !$OMP DECLARE REDUCTION padd not found at (1)

What the specification requires

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

OpenMP 5.2 §5.5.5 p.133 l.10-11

If the reduction identifier is defined in a declare reduction directive, the declare reduction directive must be in the same subprogram, or accessible by host or use association

Evidence

Same compiler, one change

  • the declare reduction directive in the program itself: not run yet
    Control program
    ! Control of fuzz/gcc-declare-reduction-module-not-found.f90: the declare reduction directive in the program's own
    ! specification part (compiles; correct on gcc_g90 and gcc_sm80).
    module pair_m
      implicit none
      type :: pair_t
        integer :: a, b
      end type pair_t
    end module pair_m
    
    program udr_use_association
      use omp_lib, only: omp_is_initial_device
      use pair_m
      implicit none
      type(pair_t) :: s
      !$omp declare reduction(padd: pair_t: omp_out = &
      !$omp& pair_t(omp_out%a + omp_in%a, omp_out%b + omp_in%b)) &
      !$omp& initializer(omp_priv = pair_t(0, 0))
      integer :: i, host_flag
      s = pair_t(0, 0)
      host_flag = 1
      !$omp target teams distribute parallel do reduction(padd: s) map(tofrom: s, host_flag)
      do i = 1, 100
        if (i == 1) host_flag = merge(1, 0, omp_is_initial_device())
        s%a = s%a + i
        s%b = s%b + 1
      end do
      print '(a,i0,a,i0)', 's%a= ', s%a, ' s%b= ', s%b
      print '(a,i0,a,a)', 'RESULT ran_on_host=', host_flag, ' check=', merge('pass', 'fail', s%a == 5050 .and. s%b == 100)
    end program udr_use_association
    

Other compilers run it correctly

AFAR 24.3.0