The particular instance of caching for performance might be able to be removed after<br><br><a href="https://bitbucket.org/petsc/petsc-dev/changeset/4c3566b6cf576d089811005e78b5a1ad26db2853">https://bitbucket.org/petsc/petsc-dev/changeset/4c3566b6cf576d089811005e78b5a1ad26db2853</a><br>
<br>since it removed several lookups and indirections.<br><br>The caching was always an ugly beast due to the ABA problem.<div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Nov 15, 2012 at 7:56 PM, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
PetscInitialize() and PetscFinalize() are reentrant. These means that one can call them several times in the same program (one must call MPI_Int() and MPI_Finalize() explicitly outside of these calls.<br>
<br>
This means that PetscFinalize() should leave the data in the code in an equivalent state as before the first PetscInitialize() is called.<br>
<br>
I just spent a couple hours banging my head against the wall due to two static variables in a function placed there on the assumption that PETSc was not reentrant.<br>
<br>
Please use static inside PETSc functions very carefully (if ever) and make sure they don't destroy the reentrancy.<br>
<br>
Thanks<br>
<span class="HOEnZb"><font color="#888888"><br>
Barry<br>
<br>
</font></span></blockquote></div><br></div>