> On Jun 19, 2015, at 3:54 AM, Dave May <[email protected]> wrote: > > I was wondering why there is different behaviour between > PetscLogEventGetId() > and > PetscLogStageGetId() > > PetscLogEventGetId() returns -1 if the event isn't found, > whilst PetscLogStageGetId() throws an error if the stage isn't found.
Likely Matt had a few more beers between writing the first one and the second one. > > My use case is that within one of my custom preconditioners, I wanted > to call PetscLogStageRegister() during the creation phase, but obviously > I can only register the stage once. To enable multiple instances of the > preconditioner to exist, I need to ensure that the stage is only registered > once. > Hence I would like to check for the existence of the stage prior to calling > the register function. > > Is there currently a way to check for the existence of a registered stage? No, we don't recommend doing it this way. The way we do it in PETSc is to have a static global variable that contains the stage ID and simply check the value of that id to determine if it has been set (set it to -1 at compile time) so your test can then just be that it is not -1. The stage register stuff goes through string comparisons so it should not be called a bunch of times. Barry
fix-petscslogstagegetid.patch
Description: Binary data
> > > Cheers > Dave > >
