Actual source code: pbarrier.c
1: #include <petsc/private/petscimpl.h>
3: /* Logging support */
4: PetscLogEvent PETSC_Barrier;
6: /*@
7: PetscBarrier - Blocks until this routine is executed by all processors owning the object `obj`.
9: Input Parameter:
10: . obj - PETSc object (`Mat`, `Vec`, `IS`, `SNES` etc...)
12: Level: intermediate
14: Notes:
15: The object must be cast with a (`PetscObject`). `NULL` can be used to indicate the barrier
16: should be across `PETSC_COMM_WORLD`.
18: Developer Notes:
19: This routine calls `MPI_Barrier()` with the communicator of the `PetscObject`
21: Fortran Notes:
22: You may pass `PETSC_NULL_VEC` or any other PETSc null object, such as `PETSC_NULL_MAT`, to
23: indicate the barrier should be across `PETSC_COMM_WORLD`. You can also pass in any PETSc
24: object, `Vec`, `Mat`, etc.
26: .seealso: `PetscObject`
27: @*/
28: PetscErrorCode PetscBarrier(PetscObject obj)
29: {
30: MPI_Comm comm = PETSC_COMM_WORLD;
32: PetscFunctionBegin;
33: if (obj) {
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: }