PetscOmpCtrlBarrier#

Do barrier on MPI ranks in omp_comm contained by the PETSc OMP controller (to let slave ranks free their CPU)

Synopsis#

#include "petscsys.h"  
PetscErrorCode PetscOmpCtrlBarrier(PetscOmpCtrl ctrl)

Input Parameter#

  • ctrl - a PETSc OMP controller

Notes#

this is a pthread barrier on MPI ranks. Using MPI_Barrier() instead is conceptually correct. But MPI standard does not require processes blocked by MPI_Barrier() free their CPUs to let other processes progress. In practice, to minilize latency, MPI ranks stuck in MPI_Barrier() keep polling and do not free CPUs. In contrast, pthread_barrier has this requirement.

A code using PetscOmpCtrlBarrier() would be like this,

    if (is_omp_master) {
      PetscOmpCtrlOmpRegionOnMasterBegin(ctrl);
      Call the library using OpenMP
      PetscOmpCtrlOmpRegionOnMasterEnd(ctrl);
    }
    PetscOmpCtrlBarrier(ctrl);

See Also#

PetscOmpCtrlOmpRegionOnMasterBegin(), PetscOmpCtrlOmpRegionOnMasterEnd(), PetscOmpCtrlCreate(), PetscOmpCtrlDestroy(),

Level#

developer

Location#

src/sys/utils/mpishm.c


Edit on GitLab

Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages