xref: /petsc/src/sys/utils/pbarrier.c (revision e2df7a95c5ea77c899beea10ff9effd6061e7c8f)
1 #define PETSC_DLL
2 
3 #include "petsc.h"              /*I "petsc.h" I*/
4 
5 /* Logging support */
6 PetscEvent PETSC_Barrier = 0;
7 
8 #undef __FUNCT__
9 #define __FUNCT__ "PetscBarrier"
10 /*@
11     PetscBarrier - Blocks until this routine is executed by all
12                    processors owning the object A.
13 
14    Input Parameters:
15 .  A - PETSc object  (Mat, Vec, IS, SNES etc...)
16         Must be caste with a (PetscObject), can use PETSC_NULL (for MPI_COMM_WORLD)
17 
18   Level: intermediate
19 
20   Notes:
21   This routine calls MPI_Barrier with the communicator of the PETSc Object "A".
22 
23    Concepts: barrier
24 
25 @*/
26 PetscErrorCode PETSC_DLLEXPORT PetscBarrier(PetscObject obj)
27 {
28   PetscErrorCode ierr;
29   MPI_Comm comm;
30 
31   PetscFunctionBegin;
32   if (obj) PetscValidHeader(obj,1);
33   ierr = PetscLogEventBegin(PETSC_Barrier,obj,0,0,0);CHKERRQ(ierr);
34   if (obj) {
35     ierr = PetscObjectGetComm(obj,&comm);CHKERRQ(ierr);
36   } else {
37     comm = PETSC_COMM_WORLD;
38   }
39   ierr = MPI_Barrier(comm);CHKERRQ(ierr);
40   ierr = PetscLogEventEnd(PETSC_Barrier,obj,0,0,0);CHKERRQ(ierr);
41   PetscFunctionReturn(0);
42 }
43 
44