On Thu, Apr 30, 2009 at 8:12 AM, Jed Brown <span dir="ltr"><<a href="mailto:jed@59a2.org">jed@59a2.org</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">Matthew Knepley wrote:<br>
> I misunderstood. I thought you were checking for element maxima, which<br>
> would tell you if something changed. You are just checking state<br>
> numbers?<br>
<br>
</div>Yes.<br>
<div class="im"><br>
> I did not think these had any guarantees of synchronization.<br>
<br>
</div>They don't, currently they are unrelated.  But if the state is<br>
syncronized with MAX on these operations, the state is guaranteed to<br>
increase if the state changes on either vector.  Since these vectors<br>
point to the same memory, I think this is desired behavior.<br><div class="im"></div></blockquote><div><br>Maybe I still misunderstand. Example:<br><br>  1) gVec(state 21)<br><br>  2) GetLocalForm(gVec) --> lVec(state 0)<br>
<br>  3) Change lVec, which changes gVec<br><br>  4) RestoreLocalForm(lVec) --> gVec(state max(21,1))<br><br>Here it does not seem to do what you want. I guess if you explicitly synchronized<br>the state in GetLocalForm(), then you could do this.<br>
<br>I am opposed to this, because I really do not like the state mechanism in the first<br>place. It is dangerous (as your debugging shows), and relying on it makes it very<br>easy for people to introduce errors, as we see.<br>
<br>However, if you really want to synchronize the state of local and global vectors,<br>I will not stop it this time. If there is another error, I am wiping this out altogether.<br><br>  Matt<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">
>>> The local form is meaningless after restore so its state is unimportant.<br>
>> VecGhostGetLocalForm(g,&lf);<br>
>> VecNorm(lf,NORM_1,&nrm);<br>
>> VecGhostRestoreLocalForm(g,&lf);<br>
>> VecSet(g,0);<br>
>> VecGhostGetLocalForm(g,&lf);<br>
>> VecNorm(lf,NORM_1,&nrm); /* will erroneously use cached norm */<br>
>><br>
>> You might say that the user should not do this (the ghost values are<br>
>> stale, and the norm of a local vector has dubious value), but it doesn't<br>
>> cost anything to at least do it in a consistent way.  This is why I<br>
>> prefer to syncronize state on both GetLocalForm and RestoreLocalForm.<br>
><br>
><br>
> You are not guaranteed to get the same local vector.<br>
<br>
</div>True, if a new local vector was created in VecGhostGetLocalForm (not the<br>
way it's implemented), then you would get a different vector.  In<br>
practice, the local vector is retained in Vec_MPI::localrep.  This is<br>
actually crucial because the global vector doesn't know how much memory<br>
is there, it only sees the owned part.  Since the local vector is<br>
retained, state-dependent information (like cached norms) are also<br>
preserved, so the state of the local vector *must* increase if the<br>
values change.<br>
<br>
You could do this by just increasing the state of the local form on<br>
GetLocalForm, and increasing the state of the global form on<br>
RestoreLocalForm.  Unless I'm missing some very peculiar use of state,<br>
syncronizing to the maximum is equally safe, but doesn't unnecessarily<br>
invalidate the cache.<br>
<font color="#888888"><br>
Jed<br>
<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener<br>