OffTarget

Observed issues › stress/cce-acc-declare-create-scalar-serial-firstprivate

Appears to behave incorrectlyWrong answer · Fortran · OpenACC · Open

ftn -h acc: a module scalar in declare create is treated as firstprivate in a serial region (write lost)

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.0n/an/an/an/an/an/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/acorrectcorrect
NVHPC 26.9n/an/an/an/an/acorrectcorrect
GCC 16.2.0behaves incorrectlybehaves incorrectlybehaves incorrectlybehaves incorrectlybehaves incorrectlybehaves incorrectlyn/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
CCE 20.0.2, MI300A unified
CCE 20.0.2, MI300A copy
CCE 20.0.2, MI250X
CCE 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
GCC 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
g= 101

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 -h acc -O2 repro.f90 -o repro
HSA_XNACK=1 ./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 -h acc -O2 repro.f90 -o repro
HSA_XNACK=1 ./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 -h acc -O2 repro.f90 -o repro
HSA_XNACK=1 ./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 -h acc -O2 repro.f90 -o repro
HSA_XNACK=1 ./repro

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 -fopenacc -foffload=amdgcn-amdhsa -foffload-options=amdgcn-amdhsa=-march=gfx942 -O2 repro.f90 -o repro
HSA_XNACK=1 ./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 -fopenacc -foffload=nvptx-none -foffload-options=nvptx-none=-march=sm_80 -foffload-options=nvptx-none=-latomic -O2 repro.f90 -o repro
./repro

NVHPC 25.11, A100 separate (runs correctly)

export LD_LIBRARY_PATH=$NVHPC_25_11/compilers/lib
nvfortran -acc=gpu -gpu=cc80 -gpu=mem:separate -O2 repro.f90 -o repro
./repro
Program (39 lines)
! # Finding: CCE OpenACC treats a "declare create" module scalar as
! # firstprivate in a serial construct
!
! - compilers: CCE ftn 19.0.0, 20.0.2, 21.0.3 (-h acc), MI300A (gfx942) HSA_XNACK 1 and 0, and
!   MI250X (gfx90a, Tioga, HSA_XNACK 0); -O2
! - expected: g= 203. g is in a data clause on a declare directive, so its data attributes are
!   explicitly determined (OpenACC 3.4 §2.6 p.40 l.1331-1334); a variable in a data clause on a
!   visible declare directive gets no implicit data attribute (§2.6.2 p.41 l.1372-1373, 1387); the
!   data lifetime of a declare in a module's declaration section is the whole program (§2.13 p.81
!   l.2983-2986), and the global variable is statically allocated in device memory with structured
!   reference count one (§2.13.2 p.83 l.3051-3052). So the serial region writes the device copy
!   (set to 101 by "update device"), and "update self" returns 203
! - caveat: 3.4 does not define "visible" for a declare directive reached by USE association. Read
!   together, the sections above leave no textual support for a firstprivate reading, but the
!   finding rests on that reading of "visible"
! - actual: g= 101 (CCE 19/20/21, MI300A both XNACK settings; MI250X)
! - control (same compiler): serial present(g)
!   (data/reports/fuzz-stress-audit/r3-acc-declare-create-scalar-control.f90): 203 on CCE 19/20/21;
!   the earlier review's kernels form is 203 too
! - other families: NVHPC 25.11 and 26.9 (nvfortran -acc=gpu, A100, separate and managed) give 203
! - legality: legal by reading: serial, a module scalar, update device/self of a declared variable
! - evidence: results/stress/audit/runs.jsonl, runs-tioga.jsonl, runs-nvhpc.jsonl. The confirmer
!   gave needs_human (R22); the audit counts the A100 results as the other-family witness
module acc_scalar_m
  implicit none
  integer(8) :: g
  !$acc declare create(g)
end module acc_scalar_m
program acc_declare_scalar
  use acc_scalar_m
  implicit none
  g = 101
  !$acc update device(g)
  !$acc serial
    g = 2 * g + 1
  !$acc end serial
  !$acc update self(g)
  print '(a,i0)', 'g= ', g
end program acc_declare_scalar

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

g= 203

Observed where it behaves incorrectly

g= 101

What the specification requires

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

OpenACC 3.4 §2.6 p.40 l.1331-1334

OpenACC 3.4 §2.6.2 p.41 l.1372-1373

OpenACC 3.4 §2.13 p.81 l.2983-2986

OpenACC 3.4 §2.13.2 p.83 l.3051-3052

Evidence

Same compiler, one change

  • serial present(g): CCE 19.0.0: correct; CCE 20.0.2: correct; CCE 21.0.3: correct; CCE 21.0.4: correct
    Control program
    module acc_scalar_m
      implicit none
      integer(8) :: g
      !$acc declare create(g)
    end module acc_scalar_m
    program acc_declare_scalar
      use acc_scalar_m
      implicit none
      g = 101
      !$acc update device(g)
      !$acc serial present(g)
        g = 2 * g + 1
      !$acc end serial
      !$acc update self(g)
      print '(a,i0)', 'g= ', g
    end program acc_declare_scalar
    

Other compilers run it correctly

NVHPC 25.11, NVHPC 26.9