petsc-3.10.5 2019-03-28
Report Typos and Errors

PetscOmpCtrlBarrier

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

Synopsis

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

Input Parameter

ctrl -a PETSc OMP controler

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