[petsc-users] Logging object creation and destruction counts

Wells, David drwells at email.unc.edu
Tue Nov 21 10:47:49 CST 2023


Hi Matt,

Thanks! I think the third point is what I need to get this working correctly. I'll report back when I have this working (or not working).

Best,
David
________________________________
From: Matthew Knepley <knepley at gmail.com>
Sent: Monday, November 20, 2023 10:00 AM
To: Wells, David <drwells at email.unc.edu>
Cc: petsc-users at mcs.anl.gov <petsc-users at mcs.anl.gov>
Subject: Re: [petsc-users] Logging object creation and destruction counts

On Mon, Nov 20, 2023 at 8:00 AM Wells, David <drwells at email.unc.edu<mailto: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/20231121/10ab42c9/attachment.html>


More information about the petsc-users mailing list