[petsc-users] Destroy ghosted vector that was used to duplicate

Barry Smith bsmith at mcs.anl.gov
Wed Jun 19 17:59:44 CDT 2013


  John,

   When a VecCreateGhost() is duplicated the new vector shares the VecScatter with the original vector. In your example below vec2 and vec3 share the VecScatter. Hence the VecScatter has a reference count of 3. When you call VecDestroy(vec1) the reference count for that scatter falls to 2. Once vec2 and vec3 are destroyed the reference count for the VecScatter falls to zero and it is destroyed. Hence no memory (or MPI persistent communication resources) should be lost. 

    Note that even if you do not plan to use the "local vector" part of vec2 and vec3 that VecScatter will still be around until you destroy vec2 and vec3 and any other Vecs obtained by VecDuplicating any of these. If you want to eliminate the VecScatter then don't use a VecDuplicate() on the ghosted vector instead create a non-ghosted vector.


   This is the way it is suppose to be anyways. Are you observing something different that could be reproduced in a somewhat reasonably small example?

   Barry

On Jun 19, 2013, at 2:45 PM, John Mousel <john.mousel at gmail.com> wrote:

> Looking at the message queue graph in Totalview, it seems that I'm running up the number of persistent communications when I try to resize a vector by duplicating, copying, destroying, and calling VecCreateGhost. 
> 
> 
> On Wed, Jun 19, 2013 at 2:42 PM, Matthew Knepley <knepley at gmail.com> wrote:
> On Wed, Jun 19, 2013 at 6:24 PM, John Mousel <john.mousel at gmail.com> wrote:
> Is it legal to destroy a ghosted vector if it has been used in VecDuplicate?
> 
> This is fine.
> 
>    MAtt
>  
> Something like:
> 
> VecCreateGhost(...,vec1)
> VecDuplicate(vec1,vec2)
> VecDuplicate(vec1,vec3)
> VecDestroy(vec1)
> VecAXPY(vec2,1.0,vec3)
> 
> Is this legal or are the scatters left hanging in the ether?
> 
> 
> John
> 
> 
> 
> -- 
> What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
> -- Norbert Wiener
> 



More information about the petsc-users mailing list