Skip to content

ACC003 firstprivate-associate-name ​

warning enabled by default

An associate name appears in an OpenACC firstprivate clause.

Why ​

Some compilers (nvfortran among them) mishandle firstprivate of an associate name: the private copy is not initialised from the associated entity, and the kernel computes with garbage. copyin gives each gang the value reliably.

Reported ​

fortran
associate (dx => grid%dx)
  !$acc parallel loop firstprivate(dx)

Preferred ​

fortran
associate (dx => grid%dx)
  !$acc parallel loop copyin(dx)

Suppressing ​

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

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

For the whole project, ignore = ACC003 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)