<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255);" dir="auto">
Hi Erik,</div>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255);" dir="auto">
<br>
</div>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255);" dir="auto">
You can try and run your application with MUST: <a href="https://itc.rwth-aachen.de/must/">
https://itc.rwth-aachen.de/must/</a></div>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255);" dir="auto">
<br>
</div>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255);" dir="auto">
The report should tell you what cleanup is missing and most probably also why your application deadlocks in finalize. To get source line information, you should build your code (and Julia runtime?) with debug flag. Also check the section about backward in the
 documentation of MUST.</div>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255);" dir="auto">
<br>
</div>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255);" dir="auto">
While the most recent version was not tested on MacOS yet, it should work on both Linux and MacOS. It might be interesting to see whether analysis results differ between the different os</div>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255);" dir="auto">
<br>
</div>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255);" dir="auto">
Best</div>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255);" dir="auto">
Joachim</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Erik Schnetter via discuss <discuss@mpich.org><br>
<b>Sent:</b> Tuesday, November 30, 2021 4:54:28 PM<br>
<b>To:</b> Zhou, Hui <zhouh@anl.gov><br>
<b>Cc:</b> Erik Schnetter <schnetter@gmail.com>; discuss@mpich.org <discuss@mpich.org><br>
<b>Subject:</b> Re: [mpich-discuss] Why stuck in MPI_Finalize?</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Hui<br>
<br>
A garbage collector can't reliably reclaim resources. When<br>
MPI_Finalize is called by the garbage collector, then there's a chance<br>
it won't be run (e.g. if things live in global variables), and then<br>
the application won't shut down completely. Therefore, MPI_Finalize is<br>
called explicitly, while e.g. MPI_Comm_free usually would be called<br>
automatically.<br>
<br>
Is there a way to see what is happening during MPI_Finalize, maybe<br>
some kind of `verbose` setting?<br>
<br>
-erik<br>
<br>
On Mon, Nov 29, 2021 at 11:18 PM Zhou, Hui <zhouh@anl.gov> wrote:<br>
><br>
> Hi Erik,<br>
><br>
> Shouldn't MPI_Finalize run by the garbage collector as well by treating the entire MPI as an object?<br>
><br>
> --<br>
> Hui Zhou<br>
> ________________________________<br>
> From: Erik Schnetter <schnetter@gmail.com><br>
> Sent: Monday, November 29, 2021 7:23 PM<br>
> To: Zhou, Hui <zhouh@anl.gov><br>
> Cc: discuss@mpich.org <discuss@mpich.org><br>
> Subject: Re: [mpich-discuss] Why stuck in MPI_Finalize?<br>
><br>
> Hui<br>
><br>
> Julia is garbage collected, and our MPI wrappers free MPI handles<br>
> automatically when the wrapped handles become garbage collected. I<br>
> thus don't have direct control over when and which handles are freed<br>
> before MPI_Finalize is called at the end of the test case. Our<br>
> approach is to let things be as they are, ensuring that no MPI calls<br>
> are made any more when MPI_Finalized returns true. That means that<br>
> different MPI processes might (or might not ) free handles before<br>
> calling MPI_Finalize. I notice that this seems to work fine on Linux,<br>
> but not always on macOS. I don't have a simple reproducer in C.<br>
><br>
> Pointers to setting up Julia: See e.g.<br>
> <<a href="https://github.com/JuliaParallel/MPI.jl/blob/master/.github/workflows/UnitTests.yml">https://github.com/JuliaParallel/MPI.jl/blob/master/.github/workflows/UnitTests.yml</a>><br>
> which runs the unit tests for the Julia package `MPI.jl` which wraps<br>
> MPI implementations. There are several stanzas; the one called<br>
> `test-system-brew` runs MPI.jl on a system-provided (external MPI)<br>
> installation that has been installed via Homebrew on macOS. You would<br>
> replace the step "Install MPI via homebrew" by a step that downloads<br>
> and installs MPICH into /usr/local. I'll be happy to discuss details,<br>
> possibly over Zoom.<br>
><br>
> -erik<br>
><br>
><br>
> On Mon, Nov 29, 2021 at 5:12 PM Zhou, Hui <zhouh@anl.gov> wrote:<br>
> ><br>
> > Hi Erik,<br>
> ><br>
> > It is not just a barrier in MPI_Finalize. It also needs to make sure pending communications are completed. Sometimes this is the user's fault, such as mismatched communication or partially freed communicators. But sometimes this is due to lower-level network
 library. For example, some libfabric provider does not always flush send. We tried to detect and prevent all cases that result in hanging, but there always seem to be cases that escape our solution. If you can drill down some simple reproducible (even with
 5% chance) cases, please create a github issue and we'll track it down.<br>
> ><br>
> > By the way, if you have pointers on setting up Julia CI testing, we can try to setup nightly testing on our end as well. Catching the errors when it appear always makes troubleshooting easier.<br>
> ><br>
> > --<br>
> > Hui<br>
> > ________________________________<br>
> > From: Erik Schnetter via discuss <discuss@mpich.org><br>
> > Sent: Monday, November 29, 2021 12:30 PM<br>
> > To: discuss@mpich.org <discuss@mpich.org><br>
> > Cc: Erik Schnetter <schnetter@gmail.com><br>
> > Subject: [mpich-discuss] Why stuck in MPI_Finalize?<br>
> ><br>
> > I have a Julia test case on macOS where MPICH randomly gets stuck in<br>
> > MPI_Finalize (with about a 5% chance). See e.g.<br>
> > <a href="https://github.com/JuliaParallel/MPI.jl/runs/4357341818">https://github.com/JuliaParallel/MPI.jl/runs/4357341818</a><br>
> ><br>
> > Can you advise under what circumstances MPICH could get stuck there?<br>
> > The respective run uses 3 processes, and all 3 processes call into<br>
> > MPI_Finalize, but no process returns.<br>
> ><br>
> > I assume that MPI_Finalize contains internally the equivalent to an<br>
> > MPI_Barrier, but that should succeed here. Are there other actions<br>
> > taken in MPI_Finalize that would require some kind of consistent state<br>
> > across the application? For example, if a communicator was created on<br>
> > all processes, but freed only on some processes, could this cause such<br>
> > a deadlock?<br>
> ><br>
> > -erik<br>
> ><br>
> > --<br>
> > Erik Schnetter <schnetter@gmail.com><br>
> > <a href="http://www.perimeterinstitute.ca/personal/eschnetter/">http://www.perimeterinstitute.ca/personal/eschnetter/</a><br>
> > _______________________________________________<br>
> > discuss mailing list     discuss@mpich.org<br>
> > To manage subscription options or unsubscribe:<br>
> > <a href="https://lists.mpich.org/mailman/listinfo/discuss">https://lists.mpich.org/mailman/listinfo/discuss</a><br>
><br>
><br>
><br>
> --<br>
> Erik Schnetter <schnetter@gmail.com><br>
> <a href="http://www.perimeterinstitute.ca/personal/eschnetter/">http://www.perimeterinstitute.ca/personal/eschnetter/</a><br>
<br>
<br>
<br>
-- <br>
Erik Schnetter <schnetter@gmail.com><br>
<a href="http://www.perimeterinstitute.ca/personal/eschnetter/">http://www.perimeterinstitute.ca/personal/eschnetter/</a><br>
_______________________________________________<br>
discuss mailing list     discuss@mpich.org<br>
To manage subscription options or unsubscribe:<br>
<a href="https://lists.mpich.org/mailman/listinfo/discuss">https://lists.mpich.org/mailman/listinfo/discuss</a><br>
</div>
</span></font></div>
</body>
</html>