Actual source code: pbarrier.c


  2: #include <petsc/private/petscimpl.h>

  4: /* Logging support */
  5: PetscLogEvent PETSC_Barrier;

  7: /*@C
  8:     PetscBarrier - Blocks until this routine is executed by all processors owning the object `obj`.

 10:    Input Parameter:
 11: .  obj - PETSc object  (`Mat`, `Vec`, `IS`, `SNES` etc...)
 12:         The object must be cast with a (`PetscObject`). `NULL` can be used to indicate the barrier should be across `PETSC_COMM_WORLD`

 14:   Level: intermediate

 16:   Developer Note:
 17:   This routine calls `MPI_Barrier()` with the communicator of the `PetscObject`

 19:   Fortran Note:
 20:     You may pass `PETSC_NULL_VEC` or any other PETSc null object, such as `PETSC_NULL_MAT`, to indicate the barrier should be
 21:     across `PETSC_COMM_WORLD`. You can also pass in any PETSc object, `Vec`, `Mat`, etc

 23: @*/
 24: PetscErrorCode PetscBarrier(PetscObject obj)
 25: {
 26:   MPI_Comm comm;

 28:   PetscFunctionBegin;
 30:   PetscCall(PetscLogEventBegin(PETSC_Barrier, obj, 0, 0, 0));
 31:   if (obj) PetscCall(PetscObjectGetComm(obj, &comm));
 32:   else comm = PETSC_COMM_WORLD;
 33:   PetscCallMPI(MPI_Barrier(comm));
 34:   PetscCall(PetscLogEventEnd(PETSC_Barrier, obj, 0, 0, 0));
 35:   PetscFunctionReturn(PETSC_SUCCESS);
 36: }