VecGhost and state

Jed Brown jed at 59A2.org
Thu Apr 30 08:12:42 CDT 2009


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.

>>> 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

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


More information about the petsc-dev mailing list