MPI run on a local machine
NONMEM supports parallel computation through Message Passing Interface (MPI). As modern hardware advacement gifts destop computation with multicore processors, so that MPI runs can be executed locally to speed up computation, as opposite to dispatched remotely to a server. This article describes the steps for local parallel runs using the precompiled NONMEM library. User need to ensure the build toolchain has been installed.
To utilize the parallel feature one must have the MPI library available. Please consult vendor documentation such as by Microsoft MPI, OpenMPI, and MPICH. Note that NONMEM contains libraries for Microsoft MPI (MSMPI), so users need only install the MSMPI executable but not the SDK.
Build
To build a parallel NONMEM executable, follow the common "configure-build-install" process and use the relevant MPI options.
-
Create a build directory at, say
/path/to/build,1mkdir /path/to/build && cd /path/to/build -
Assume NONMEM is located at
/path/to/nonmem, to build a model at/path/to/model/model-name.ctl, in the build directory, do1 2# configure cmake /path/to/nonmem -B. -GNinja -Dmodel=/path/to/model/model-name.ctl -Dmpi=ONHere option
-Dmpi=ONrequests for MPI builds. One can use additional cmake options to customize MPI build. For example, one can use-DMPI_HOME=to help cmake locate the MPI library:1cmake /path/to/nonmem -B. -GNinja -Dmodel=/path/to/model/model-name.ctl -Dmpi=ON -DMPI_HOME=/path/to/mpich-4.3.2The above line enables MPI build using the library
mpich-4.3.2.For Windows users with Microsoft MPI (MSMPI), a special option
mpi=MSMPI1cmake /path/to/nonmem -B. -GNinja -Dmodel=/path/to/model/model-name.ctl -Dmpi=MSMPIenables MSMPI build. The
MPI_HOMEoption is then ignored. -
The other steps are the same as the sequential build:
1 2 3 4# build cmake --build . -j2 # -j2: use 2 threads to build faster # install cmake --install .
Run
To run the model in parallel, do
|
|
Here -parafile=LOCALNODE requests a "local node" MPI run, and
num_nodes is the number of cores user needs to specify. The
subjects in the model will be distributed to the specified cores and
their contribution to OFV will be calculated
in paralle. For example,
|
|
says that the population will be distributed to four cores, assuming there are more than four cores in the machine.
User can explore additional vendor-depedent options in MPI runs. For
example, it is often desirable to use the --bind-to core option
|
|
so that num_nodes would indicate the number of hardware cores, as
opposite to hardware threads (vCPUs).
Run using nmf2
User can simplify the workflow by using nonmem/util/nmf2.sh
(Linux/MacOS) or nonmem/util/nmf2.bat (Windows) scripts. These are
thin wrappers of the above cmake procedures. See more about the
script here.
The nodes= option of the nmf2 script enables MPI build and run. It
specifies the number of cores from your local machine to be used. Note
that by default nmf2 uses Microsoft MPI (MSMPI) to build the
executable. To use an alternative MPI library, specify it using
-mpi_home= option. Thus
|
|
will build the model using MSMPI and run it with 4 cores; while
|
|
will build the model using specified MPI library mpich-4.3.2 and run
it with 4 cores.