VecGhost and state

Matthew Knepley knepley at gmail.com
Thu Apr 30 08:27:40 CDT 2009


On Thu, Apr 30, 2009 at 8:12 AM, Jed Brown <jed at 59a2.org> wrote:

> Matthew Knepley wrote:
> > I misunderstood. I thought you were checking for element maxima, which
> > would tell you if something changed. You are just checking state
> > numbers?
>
> Yes.
>
> > I did not think these had any guarantees of synchronization.
>
> They don't, currently they are unrelated.  But if the state is
> syncronized with MAX on these operations, the state is guaranteed to
> increase if the state changes on either vector.  Since these vectors
> point to the same memory, I think this is desired behavior.
>

Maybe I still misunderstand. Example:

  1) gVec(state 21)

  2) GetLocalForm(gVec) --> lVec(state 0)

  3) Change lVec, which changes gVec

  4) RestoreLocalForm(lVec) --> gVec(state max(21,1))

Here it does not seem to do what you want. I guess if you explicitly
synchronized
the state in GetLocalForm(), then you could do this.

I am opposed to this, because I really do not like the state mechanism in
the first
place. It is dangerous (as your debugging shows), and relying on it makes it
very
easy for people to introduce errors, as we see.

However, if you really want to synchronize the state of local and global
vectors,
I will not stop it this time. If there is another error, I am wiping this
out altogether.

  Matt


> >>> The local form is meaningless after restore so its state is
> unimportant.
> >> VecGhostGetLocalForm(g,&lf);
> >> VecNorm(lf,NORM_1,&nrm);
> >> VecGhostRestoreLocalForm(g,&lf);
> >> VecSet(g,0);
> >> VecGhostGetLocalForm(g,&lf);
> >> VecNorm(lf,NORM_1,&nrm); /* will erroneously use cached norm */
> >>
> >> You might say that the user should not do this (the ghost values are
> >> stale, and the norm of a local vector has dubious value), but it doesn't
> >> cost anything to at least do it in a consistent way.  This is why I
> >> prefer to syncronize state on both GetLocalForm and RestoreLocalForm.
> >
> >
> > You are not guaranteed to get the same local vector.
>
> True, if a new local vector was created in VecGhostGetLocalForm (not the
> way it's implemented), then you would get a different vector.  In
> practice, the local vector is retained in Vec_MPI::localrep.  This is
> actually crucial because the global vector doesn't know how much memory
> is there, it only sees the owned part.  Since the local vector is
> retained, state-dependent information (like cached norms) are also
> preserved, so the state of the local vector *must* increase if the
> values change.
>
> You could do this by just increasing the state of the local form on
> GetLocalForm, and increasing the state of the global form on
> RestoreLocalForm.  Unless I'm missing some very peculiar use of state,
> syncronizing to the maximum is equally safe, but doesn't unnecessarily
> invalidate the cache.
>
> Jed
>
>


-- 
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20090430/b07e8203/attachment.html>


More information about the petsc-dev mailing list