Skip to content

ACC010 private-array-in-contained-kernel ​

info opt-in

A compute region of a contained (internal) procedure has a private array.

Why ​

nvfortran has been observed to mis-privatise arrays listed in private inside OpenACC kernels of contained procedures: runtime-sized private arrays get garbage that depends on the gang count, and even fixed-size ones can bleed between threads. Advisory: prefer scalar accumulation, or move the kernel to a module procedure, and verify against a CPU run.

Reported ​

fortran
contains
  subroutine fill()
    real :: buf(5)
    !$acc parallel loop private(buf)

Preferred ​

fortran
! module procedure, or scalar temporaries instead of buf(5)

Suppressing ​

For one occurrence, with the reason on the same line (or alone on the line before the statement):

fortran
! fobis: ignore[ACC010] <why this occurrence is fine>

For the whole project, ignore = ACC010 in the fobos [lint] section.

References ​

Sections of the shipped knowledge packs behind this rule:

  • hpc-practice:gpu-practice#device-code-pitfalls (fobis kb show hpc-practice:gpu-practice#device-code-pitfalls)