1 #include <petsc/private/petscimpl.h> /*I "petscsys.h" I*/ 2 3 /* Logging support */ 4 PetscLogEvent PETSC_Barrier; 5 6 /*@ 7 PetscBarrier - Blocks until this routine is executed by all processors owning the object `obj`. 8 9 Input Parameter: 10 . obj - PETSc object (`Mat`, `Vec`, `IS`, `SNES` etc...) 11 12 Level: intermediate 13 14 Fortran Note: 15 You may pass `PETSC_NULL_VEC` or any other PETSc null object, such as `PETSC_NULL_MAT`, to 16 indicate the barrier should be across `PETSC_COMM_WORLD`. You can also pass in any PETSc 17 object, `Vec`, `Mat`, etc. 18 19 Note: 20 The object must be cast with a (`PetscObject`). `NULL` can be used to indicate the barrier 21 should be across `PETSC_COMM_WORLD`. 22 23 Developer Note: 24 This routine calls `MPI_Barrier()` with the communicator of the `PetscObject` 25 26 .seealso: `PetscObject`, `MPI_Comm`, `MPI_Barrier` 27 @*/ 28 PetscErrorCode PetscBarrier(PetscObject obj) 29 { 30 MPI_Comm comm = PETSC_COMM_WORLD; 31 32 PetscFunctionBegin; 33 if (obj) { 34 PetscValidHeader(obj, 1); 35 PetscCall(PetscObjectGetComm(obj, &comm)); 36 } 37 PetscCall(PetscLogEventBegin(PETSC_Barrier, obj, 0, 0, 0)); 38 PetscCallMPI(MPI_Barrier(comm)); 39 PetscCall(PetscLogEventEnd(PETSC_Barrier, obj, 0, 0, 0)); 40 PetscFunctionReturn(PETSC_SUCCESS); 41 } 42