Skip to content

Implement MDI Support

Taylor Arnold Barnes requested to merge taylor-a-barnes/inq:mdi into master

This PR implements Molssi Driver Interface support in INQ, enabling it to function as an MDI engine. This allows external codes, called MDI drivers, to use the functionality of INQ as part of higher-level methodologies, such as QM/MM, advanced sampling, machine learning, etc. Communication through MDI can happen through any of three different mechanisms, selected by the end-user at runtime: (1) communication via TCP/IP sockets (allowing INQ to act similarly to a server), (2) communication via MPI, or (3) directly linking the MDI driver to INQ as a shared library. Because of this last option, this PR effectively implements the ability for INQ to be compiled and used as a library, with a standardized API defined by MDI.

I've made efforts to implement MDI support in a minimally invasive way. The primary changes made by this PR are as follows:

  • Changes the .gitmodules to point to absolute paths instead of relative ones. This change doesn't have anything to do with MDI per se, but was necessary in order to make forks of INQ work. Without this change, git searched for submodules in my personal GitLab account, instead of the NPNEQ account.
  • Adds the MDI Library as an external dependency, including CMake build support.
  • Adds files examples/inq_mdi.cpp and examples/inq_mdi.h, as well as CMake build support for them. All of the MDI-specific code is located in these files. CMake will build these files into both an executable and a shared library, which can be used by external MDI drivers to utilize INQ in a standardized way.

There are currently a couple of problems with this implementation, which are both related to MPI:

  • When INQ is run as a library, it should not call MPI_Init() - that is the job of the calling code. If I understand correctly, initializing an inq::input::environment causes MPI_Init() to be called. Is there a way to avoid this?
  • When MDI handles communication via MPI, all of the communicating codes (both the driver and any engines) are launched as part of a single MPMD run. Because of this, MPI_COMM_WORLD can potentially span multiple different codes in the context of MDI. Instead of using MPI_COMM_WORLD, MDI-supporting codes should receive an MPI communicator from MDI, which will span only a single code, and use this communicator whenever MPI_COMM_WORLD would otherwise be used. Is there a way to assign the MPI communicator that is used by INQ?

Merge request reports