<div dir="ltr">Update:<div><br></div><div>Additional support for MPI-enabled clients is under review at <a href="https://gitlab.com/gromacs/gromacs/-/merge_requests/3080">https://gitlab.com/gromacs/gromacs/-/merge_requests/3080</a></div><div><br></div><div>Whether in the current change or for follow-up, I appreciate any feedback on the documentation (gitlab.rst) or the CMake infrastructure (InstallLibInfo.cmake).</div><div><br></div><div>Best,</div><div>Eric</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Aug 19, 2022 at 12:57 PM Eric Irrgang &lt;<a href="mailto:ericirrgang@gmail.com">ericirrgang@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Thanks, Joe. I guess I didn&#39;t provide sufficient background.<br>
<br>
I should also say that this thread is especially targeted at anyone who is already building MPI-enabled software that links to libgromacs_mpi.so.<br>
<br>
We are trying to make it easier for gromacs libraries to be linked into MPI-aware client code and coordinate sharing of MPI resources by allocating subcommunicators. A key use case is to be able to build the Python gmxapi package such that an MPI communicator can be acquired from the mpi4py Python package, then passed to libgromacs for use instead of MPI_COMM_WORLD.<br>
<br>
We previously introduced an optional template header (<a href="https://gitlab.com/gromacs/gromacs/-/blob/main/api/gmxapi/include/resourceassignment.cmakein.h" rel="noreferrer" target="_blank">https://gitlab.com/gromacs/gromacs/-/blob/main/api/gmxapi/include/resourceassignment.cmakein.h</a>) to allow client code to pass MPI_Comm objects if and only if the installation and client build are mutually MPI compatible.<br>
<br>
This means, for instance, that a Python gmxapi _user_ (or `pip install`, on behalf of the user) needs to be able to find a tool chain that is mutually compatible between mpi4py and the GROMACS installation, which was likely installed at a different time, likely by a different person, and maybe without the benefit of HPC-style environment modules.<br>
<br>
&gt; As to the first question, do we have any evidence that the information we get from FindMPI.cmake is insufficient for our purposes? My default position would be that we should change our cmake to be more in line with standard usage rather than try to warp the standard usage to fit our legacy approach. <br>
<br>
Right. Both GROMACS and client software should use FindMPI.<br>
<br>
So, to clarify my first question:<br>
<br>
How do we help a client build system to get the same results from FindMPI that the GROMACS build system got?<br>
<br>
We added the gromacs-hints.cmake file to help client build systems find the same CMAKE_CXX_COMPILER, and that may be sufficient to force FindMPI to _fail_ in the client build system if it finds an incompatible mpicxx, but that&#39;s only half an answer.<br>
<br>
I would think we should record MPI_CXX_COMPILER (which is both an input and output of FindMPI) in gromacs-hints.cmake, but maybe someone on the list has an idea of why that would be inappropriate or insufficient.<br>
<br>
&gt; Since MPI_COMM_WORLD is no longer directly exposed, it might be the case that the answer to your second question involves making utility module an OBJECT so that MPI can be linked privately. Then we could just expose an API call that gives the MPI version/compiler info for the utility module. I am a bit out of my depth here, so let me know if this solution is way off base.<br>
<br>
This is about client software that is built against the GROMACS installation, and which does not have access to the build tree. It could be helpful to have run time checks, in case someone replaces their mpi4py package, for instance, but that is a secondary concern.<br>
<br>
The primary problem is getting a compatible tool chain. For that, we have to rely on machinery accessible through `find_package(gmxapi)` and/or `find_package(gromacs)`, augmented by the help we can provide through documentation, status messages, and the file we provide for use as `cmake -C path/to/gromacs-hints.cmake` (which we automatically insert under the hood of `pip install gmxapi`).<br>
<br>
&gt; On Wed, Aug 17, 2022 at 2:03 PM Eric Irrgang &lt;<a href="mailto:ericirrgang@gmail.com" target="_blank">ericirrgang@gmail.com</a>&gt; wrote:<br>
&gt; Hi Devs.<br>
&gt; <br>
&gt; I&#39;m writing to ask for input on improving support for integrating gromacs libraries into external MPI-aware code.<br>
&gt; <br>
&gt; Background: I&#39;m trying to finish up the Python bindings to allow an MPI communicator to be passed to libgromacs (to be used instead of MPI_COMM_WORLD).<br>
&gt; <br>
&gt; Here are some questions that need to be answered. If you have any input, please let me know.<br>
&gt; <br>
&gt; If you prefer to log your responses in the issue tracking system, please see <a href="https://gitlab.com/gromacs/gromacs/-/issues/3777" rel="noreferrer" target="_blank">https://gitlab.com/gromacs/gromacs/-/issues/3777</a> and <a href="https://gitlab.com/gromacs/gromacs/-/issues/4447" rel="noreferrer" target="_blank">https://gitlab.com/gromacs/gromacs/-/issues/4447</a><br>
&gt; <br>
&gt; <br>
&gt; Questions:<br>
&gt; <br>
&gt; * What should we add to <a href="https://gitlab.com/gromacs/gromacs/-/blob/main/src/gromacs/gromacs-hints.in.cmake" rel="noreferrer" target="_blank">https://gitlab.com/gromacs/gromacs/-/blob/main/src/gromacs/gromacs-hints.in.cmake</a> to help hint `find_package(MPI ...)`? (<a href="https://cmake.org/cmake/help/latest/module/FindMPI.html" rel="noreferrer" target="_blank">https://cmake.org/cmake/help/latest/module/FindMPI.html</a>)<br>
&gt; <br>
&gt; * If a user of a client project has difficulty determining the actual compiler path associated with the MPI compiler wrapper they are advised to use, how might we provide better feedback from our `gromacs_check_compiler()` CMake function? <a href="https://gitlab.com/gromacs/gromacs/-/blob/main/src/gromacs/gromacs-config.cmake.cmakein#L128" rel="noreferrer" target="_blank">https://gitlab.com/gromacs/gromacs/-/blob/main/src/gromacs/gromacs-config.cmake.cmakein#L128</a><br>
&gt; <br>
&gt; <br>
&gt; Additional background:<br>
&gt; <br>
&gt; With <a href="https://gitlab.com/gromacs/gromacs/-/issues/3671" rel="noreferrer" target="_blank">https://gitlab.com/gromacs/gromacs/-/issues/3671</a>, we resolved that the appropriate way to configure CMake is to provide the non-wrapper compilers to CMAKE_CXX_COMPILER and to provide the MPI-wrapper paths only to MPI_CXX_COMPILER (if necessary).<br>
&gt; <br>
&gt; However, FindMPI only reports the compiler wrapper path by setting MPI_&lt;lang&gt;_COMPILER. It does not gain or report any additional insight on the path to the wrapped compiler, as far as I can tell. It _does_ find and use the appropriate &quot;showme&quot; option and does its best to confirm that the wrapped compiler and the CMAKE_&lt;LANG&gt;_COMPILER is that same or compatible, but it FindMPI.cmake does not return the MPI_COMPILE_CMDLINE that it calculates, and it may not have an absolute path to the compiler, anyway.<br>
&gt; <br>
&gt; Best,<br>
&gt; Eric<br>
&gt; -- <br>
&gt; Gromacs Developers mailing list<br>
&gt; <br>
&gt; * Please search the archive at <a href="https://www.gromacs.org/gmx-devel.html" rel="noreferrer" target="_blank">https://www.gromacs.org/gmx-devel.html</a> before posting!<br>
&gt; <br>
&gt; * Can&#39;t post? Read <a href="https://www.gromacs.org/gmx-devel.html" rel="noreferrer" target="_blank">https://www.gromacs.org/gmx-devel.html</a><br>
&gt; <br>
&gt; * For (un)subscribe requests visit<br>
&gt; <a href="https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-developers" rel="noreferrer" target="_blank">https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-developers</a> or send a mail to <a href="mailto:gmx-developers-request@gromacs.org" target="_blank">gmx-developers-request@gromacs.org</a>.<br>
&gt; -- <br>
&gt; Gromacs Developers mailing list<br>
&gt; <br>
&gt; * Please search the archive at <a href="https://www.gromacs.org/gmx-devel.html" rel="noreferrer" target="_blank">https://www.gromacs.org/gmx-devel.html</a> before posting!<br>
&gt; <br>
&gt; * Can&#39;t post? Read <a href="https://www.gromacs.org/gmx-devel.html" rel="noreferrer" target="_blank">https://www.gromacs.org/gmx-devel.html</a><br>
&gt; <br>
&gt; * For (un)subscribe requests visit<br>
&gt; <a href="https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-developers" rel="noreferrer" target="_blank">https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-developers</a> or send a mail to <a href="mailto:gmx-developers-request@gromacs.org" target="_blank">gmx-developers-request@gromacs.org</a>.<br>
<br>
</blockquote></div>