FOR005 cpu-time-for-wall-clock
warning enabled by defaultcpu_time measures time in code that runs in parallel (OpenMP, OpenACC, MPI).
Why
cpu_time returns processor time of the calling process or thread, not elapsed time. With threads it adds up (or not, depending on the compiler) the time of all threads; with a GPU it reports almost nothing, because the host thread just waits. Measure elapsed time with system_clock (count and count_rate), omp_get_wtime() or MPI_Wtime(), after synchronising asynchronous work (!$acc wait).
Reported
fortran
call cpu_time(t0)Preferred
fortran
call system_clock(c0, rate)
...
call system_clock(c1)
elapsed = real(c1 - c0) / rateSuppressing
For one occurrence, with the reason on the same line (or alone on the line before the statement):
fortran
! fobis: ignore[FOR005] <why this occurrence is fine>For the whole project, ignore = FOR005 in the fobos [lint] section.
References
Sections of the shipped knowledge packs behind this rule:
hpc-practice:gpu-practice#gpu-benchmark-timing(fobis kb show hpc-practice:gpu-practice#gpu-benchmark-timing)openmp:patterns#portable-timing(fobis kb show openmp:patterns#portable-timing)