<div dir="ltr"><div dir="ltr"><br><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Oct 22, 2021 at 9:13 PM Barry Smith <<a href="mailto:bsmith@petsc.dev">bsmith@petsc.dev</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
One technical reason is that PetscHeaderDestroy_Private() may call PetscCommDestroy() which may call MPI_Comm_free() which is defined by the standard to be collective. Though PETSc tries to limit its use of new MPI communicators (for example generally many objects shared the same communicator) if we did not free those we no longer need when destroying objects we could run out.<br></blockquote><div>PetscCommDestroy() might call MPI_Comm_free() , but it is very unlikely. Petsc uses reference counting on communicators, so in PetscCommDestroy(), it likely just decreases the count. In other words, PetscCommDestroy() is cheap and in effect not collective.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
I cannot off-hand think of another specific technical reason they must be collective besides this good housekeeping. <br>
<br>
In what use case can you not call them collectively?<br>
<br>
Barry<br>
<br>
<br>
> On Oct 22, 2021, at 9:21 PM, Alberto F. Martín <<a href="mailto:amartin@cimne.upc.edu" target="_blank">amartin@cimne.upc.edu</a>> wrote:<br>
> <br>
> Dear PETSc users,<br>
> <br>
> What is the main reason underlying PetscDestroy subroutines having global collective semantics? Is this actually true for all PETSc objects? Can this be relaxed/deactivated by, e.g., compilation macros/configuration options?<br>
> <br>
> Thanks in advance!<br>
> <br>
> Best regards,<br>
> <br>
> Alberto.<br>
> <br>
<br>
</blockquote></div></div>