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