[petsc-users] Logging object creation and destruction counts
Matthew Knepley
knepley at gmail.com
Mon Nov 20 09:00:04 CST 2023
On Mon, Nov 20, 2023 at 8:00 AM Wells, David <drwells at email.unc.edu> wrote:
> Hi everyone,
>
> I just upgraded to PETSc 3.20 and read up on the new logging
> infrastructure - its a very nice improvement over the old version.
>
> I have some code which checks that every construction has a corresponding
> destruction via
>
>
> PetscStageLog stageLog;
> ierr = PetscLogGetStageLog(&stageLog);
> for (int i = 0; i < stageLog->stageInfo->classLog->numClasses; ++i)
> {
> if (stageLog->stageInfo->classLog->classInfo[i].destructions !=
> stageLog->stageInfo->classLog->classInfo[i].creations)
> {
> crash();
> }
> }
>
>
> This no longer works and I can't figure out how to port it. In particular,
> it looks like I need to get a PetscLogEvent number for creation and another
> for destruction to retrieve the relevant PetscEventPerfInfo objects
> per-class - is there some straightforward way to do that for every
> registered PETSc class?
>
1. The above code seems to require that creation and destruction occur
within the same stage, which might not be true.
2. https://petsc.org/main/manualpages/Profiling/PetscLogStateGetNumClasses/
gets the numbet of classes. You can recreate this loop with the code
from PetscLogHandlerObjectCreate_Default() I think,
which is in logdefault.c. However, as I said, this will not properly match
up across stages.
3. At logdefault.c:1657 we output all the creations and destructions, so
you could copy these loops, but sum across stages.
4. You could register a callback that just increments and decrements for
each classid, and then calls PetscLogHandlerObjectCreate/Destroy_Default(),
which might be cleaner.
Thanks,
Matt
> Best,
> David Wells
>
--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20231120/0b6a019f/attachment-0001.html>
More information about the petsc-users
mailing list