[petsc-dev] PETSc object management of MPI communicators

Jed Brown jedbrown at mcs.anl.gov
Thu Jan 9 15:00:46 CST 2014


"Garth N. Wells" <gnw20 at cam.ac.uk> writes:

> Hi Jed,
>
> I've been poking around the PETSc code to see how objects manage the MPI 
> communicator that is passed in, and running some simple tests using 
> MPI_Comm_compare. Does a PETSc object (say a Vec) always duplicate the 
> communicator? From tests with MPI_Comm_compare this looks to be the 
> case.

The first time a communicator is encountered by a PETSc object,
PetscCommDuplicate dups it, yielding an "inner" communicator.  It
attaches the inner communicator, a reference count, and a tag dispenser
to the outer communicator that you just passed in.  We always use the
tag dispenser to get new tags, always perform operations on the inner
communicator.  The user never handles the inner communicator.
Subsequent calls to PetscCommDuplicate will find the attribute and just
pull out the inner communicator.

The outer communicator can be passed around, including through other
libraries, and back into PETSc, yet there will still only ever be one
inner comm per outer comm.  When an object is destroyed, the reference
count decreases and the inner communicator is destroyed when the
reference count drops to zero.

Barry, this code has been around for ages, but we should write a short
report explaining what we do and why.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20140109/0971463d/attachment.sig>


More information about the petsc-dev mailing list