OMP006 target-map-in-loop
warning opt-inAn OpenMP target region inside a loop maps data on every iteration, with no target data around it.
Why
map(to: a) / map(tofrom: a) on a target construct copies the array to the device when the region starts and back when it ends, unless the data is already present. Inside a time or iteration loop that means two full transfers per iteration, usually far more expensive than the kernel. Make the data resident once: a !$omp target data region around the loop, or !$omp target enter data at allocation and exit data at deallocation, then target update only for what the host really needs.
Reported
do it = 1, nsteps
!$omp target teams distribute parallel do map(tofrom: u) map(to: f)
do i = 1, n
u(i) = u(i) + dt * f(i)
end do
end doPreferred
!$omp target data map(tofrom: u) map(to: f)
do it = 1, nsteps
!$omp target teams distribute parallel do
do i = 1, n
u(i) = u(i) + dt * f(i)
end do
end do
!$omp end target dataSuppressing
For one occurrence, with the reason on the same line (or alone on the line before the statement):
! fobis: ignore[OMP006] <why this occurrence is fine>For the whole project, ignore = OMP006 in the fobos [lint] section.
References
Sections of the shipped knowledge packs behind this rule:
hpc-practice:gpu-practice#data-movement(fobis kb show hpc-practice:gpu-practice#data-movement)