petsc-3.12.4 2020-02-04
Report Typos and Errors

# 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 processes. 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 processes 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()

### Level

developer

### Location

src/sys/utils/mpishm.c
Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages