Skip to content

OMP007 mpi-in-threaded-region-without-thread-support ​

warning enabled by default

MPI is called inside an OpenMP parallel region but initialised with mpi_init, not mpi_init_thread.

Why ​

mpi_init provides the MPI_THREAD_SINGLE level: only one thread may exist, let alone call MPI. MPI calls made by threads of a parallel region (even in master/single) need mpi_init_thread requesting MPI_THREAD_FUNNELED, SERIALIZED or MULTIPLE, and a check of the level actually provided. Reported only when the project calls mpi_init and never mpi_init_thread.

Reported ​

fortran
call mpi_init(ierr)
...
!$omp parallel
call mpi_send(buf, n, MPI_REAL, dest, tag, comm, ierr)
!$omp end parallel

Preferred ​

fortran
call mpi_init_thread(MPI_THREAD_MULTIPLE, provided, ierr)
if (provided < MPI_THREAD_MULTIPLE) error stop 'MPI thread level'

Suppressing ​

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

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

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

References ​

Sections of the shipped knowledge packs behind this rule:

  • mpi:overview#init-threads-ch-11-2 (fobis kb show mpi:overview#init-threads-ch-11-2)