Skip to content

ACC012 sequential-device-loop ​

warning enabled by default

A loop in an OpenACC compute region runs sequentially: the compiler found a loop-carried dependence.

Why ​

In a kernels region the compiler parallelises only the loops it can prove independent. A loop-carried dependence (y(i) = y(i) + y(i-1)) makes it generate a serial kernel: the loop runs on one GPU thread, often slower than on the host. Restructure the computation (a scan, a different loop order), or move the loop off the device; if the dependence is only apparent (aliasing the compiler cannot rule out), say so with !$acc loop independent. Reported only with fobis lint --compiler-feedback LOG (see the linting guide).

Reported ​

fortran
!$acc kernels
do i = 2, n
  y(i) = y(i) + y(i-1)      ! nvfortran: Loop carried dependence of y prevents parallelization
end do
!$acc end kernels

Preferred ​

fortran
!$acc parallel loop independent   ! only when the dependence is not real

Suppressing ​

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

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

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