Molssi Driver Interface Library
|
The MDI Library enables inter-code communication in a manner compliant with the MDI Standard.
The MDI Library currently supports the following communication methods:
Whenever a code is launched as a driver or engine, it must be provided either the "-mdi"
or "--mdi"
runtime option (see MDI Ecosystem for details regarding which codes use the single dash and which codes use the double dash). The argument for this option is a string, in quotes, consisting of a sequence of options used by the MDI Library. The following options are available:
-role
DRIVER
- The code will run as a driverENGINE
- The code will run as an engine-name
-method
TCP
- The codes will communicate via the TCP/IP protocolMPI
- The codes will communicate via MPI using a Multiple Programs, Multiple Data (MPMD) approach-hostname
method=TCP
and role=ENGINE
-port
method=TCP
-ipi
-out
method=MPI
(e.g., running all of the codes as part of a single MPMD launch). When method=MPI
, all codes will by default write to the same output file, which typically leads to unreadably mangled output. The -out option allows the user to override this behavior, specifying a unique output file for each driver and engine.For more information about running or developing codes that use the MDI Library, please see the tutorials.
Launching a driver using TCP communication involves the general format:
<driver_executable> <driver_options> -mdi "-role DRIVER -name driver -method TCP -port 8021" &
Launching an engine using TCP communication involves the general format:
<engine_executable> <engine_options> -mdi "-role ENGINE -name my_name -method TCP -port 8021 -hostname localhost" &
The ampersand ("&") causes the code to run in the background, allowing additional drivers and/or engines to be launched from the same terminal or job script.
Note that some codes may use "--mdi"
instead of "-mdi"
.
When using MPI communication, the driver and engines must be launched as part of a single mpiexec
launch command. The general format for this is:
mpiexec -n <driver_nprocs> <driver_executable> -mdi "-role DRIVER -name driver -method MPI -out driver.out" : \ -n <engine1_nprocs> <engine1_executable> -mdi "-role ENGINE -name engine1 -method MPI -out engine1.out" : \ -n <engine2_nprocs> <engine2_executable> -mdi "-role ENGINE -name engine2 -method MPI -out engine2.out"
The MDI Library uses CMake to compile. If you do not already have CMake installed on your machine, please follow the instructions on the official website to do so.
With CMake installed, you can build the MDI Library as follows:
By default, the CMake build will compile all necessary wrappers to support linking to C/C++, Fortran, and Python codes. The build can be restricted to only support a subset of these languages by using the -Dlanguage
option. For example, doing the following will compile a build that only supports linking to C/C++ codes:
The following is a full list of CMake options:
-Dlanguage
C
- The build will only support C/C++Fortran
- The build will only support C/C++ and FortranPython
- The build will only support C/C++ and Python-Dlibtype
SHARED
- The build will be compiled as a shared library (default)STATIC
- The build will be compiled as a static library (NOTE: this option prevents Python codes from using the library)MDI function calls are made in a similar style to that of MPI, with MDI_Send and MDI_Recv functions being conceptually analagous to MPI_Send and MPI_Recv, respectively. The key functions are: