Should PetscObjectName be collective?

Jed Brown jed at 59A2.org
Tue Nov 17 18:01:04 CST 2009


Barry Smith wrote:
> 
> On Nov 17, 2009, at 5:08 PM, Jed Brown wrote:
>> Browsing tagm.c,
>> MPI_Keyval_free is never called for the other attributes.  This explains
>> some valgrind warnings under Open MPI but not under MPICH (presumably
>> MPICH frees zombie keyvals in MPI_Finalize() but OMPI does not).
> 
>    We should refactor the code to move the body of the code block below
> into  PetscIntialize()
>   if (Petsc_Tag_keyval == MPI_KEYVAL_INVALID) {
>     ierr =
> MPI_Keyval_create(MPI_NULL_COPY_FN,Petsc_DelTag,&Petsc_Tag_keyval,(void*)0);CHKERRQ(ierr);
> 
>     ierr =
> MPI_Keyval_create(MPI_NULL_COPY_FN,Petsc_DelComm,&Petsc_InnerComm_keyval,(void*)0);CHKERRQ(ierr);
> 
>     ierr =
> MPI_Keyval_create(MPI_NULL_COPY_FN,Petsc_DelComm,&Petsc_OuterComm_keyval,(void*)0);CHKERRQ(ierr);
> 
>   }
> and put a corresponding set of frees() into PetscFinalize().

Yup.

>     No, we don't want to share across MPI_Comm_dup(). They are different
> communicators so should have their own name counters. Note that it would
> be rare that there are MPI_Comm_dup()s lying around anyways unless the
> user explicitly calls it.

Thanks.

>    I am not sure what reference counting you are talking about but PETSc
> currently reference counts how many objects reference a communicator
> attribute (this is tagvalp[1]).  When it gets down to zero it deletes
> the attribute and the inner communicator.

This is the reference counting I was referring to, it would be
duplicated if we weren't reusing the attribute (which we couldn't do if
they were to have different sharing semantics).

>    To get a counter for object names you can increase the size of
> tagvalp[2] to tagvalp[3], then each time you get a name crank the value
> up by 1, much like PetscCommGetNewTag() No need to add new attributes.

Great.  May as well make this a struct instead of an array

typedef struct {PetscMPIInt tag,namecount,refcount;} PetscCommAttribute;



Jed

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 261 bytes
Desc: OpenPGP digital signature
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20091118/4c0b8b61/attachment.sig>


More information about the petsc-dev mailing list