[petsc-dev] Avoid use of static in PETSc functions
Jed Brown
jedbrown at mcs.anl.gov
Fri Nov 16 22:05:53 CST 2012
The particular instance of caching for performance might be able to be
removed after
https://bitbucket.org/petsc/petsc-dev/changeset/4c3566b6cf576d089811005e78b5a1ad26db2853
since it removed several lookups and indirections.
The caching was always an ugly beast due to the ABA problem.
On Thu, Nov 15, 2012 at 7:56 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:
>
> 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.
>
> This means that PetscFinalize() should leave the data in the code in an
> equivalent state as before the first PetscInitialize() is called.
>
> 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.
>
> Please use static inside PETSc functions very carefully (if ever) and
> make sure they don't destroy the reentrancy.
>
> Thanks
>
> Barry
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20121116/f0d7bfa6/attachment.html>
More information about the petsc-dev
mailing list