Main Content

Use Different MPI Builds onUNIXSystems

Build MPI

On Linux®operating systems, you can use an MPI build that differs from the one provided with Parallel Computing Toolbox™. This topic outlines the steps for creating an MPI build for use with the generic scheduler interface. If you already have an alternative MPI build, proceed toUse Your MPI Build.

  1. Unpack the MPI sources into the target file system on your machine. For example, suppose you have downloadedmpich2-distro.tgzand want to unpack it into/optfor building:

    # cd /opt # mkdir mpich2 && cd mpich2 # tar zxvf path/to/mpich2-distro.tgz # cd mpich2-1.4.1p1
  2. Build your MPI using theenable-sharedoption (this is vital, as you must build a shared library MPI, binary compatible withMPICH2-1.4.1p1for R2013b to R2018b, orMPICH3.2.1for R2019a and later). For example, the following commands build an MPI with thenemesischannel device and thegforkerlauncher.

    #。/配置前缀= / opt/mpich2/mpich2-1.4.1p1 \ --enable-shared --with-device=ch3:nemesis \ --with-pm=gforker 2>&1 | tee log # make 2>&1 | tee -a log # make install 2>&1 | tee -a log

Use Your MPI Build

When your MPI build is ready, this stage highlights the steps to use it with a generic scheduler. To get your cluster working with a different MPI build, follow these steps.

  1. Test your build by running thempiexecexecutable. The build should be ready to test if itsbin/mpiexecandlib/libmpich.soare available in the MPI installation location.

    下面的例子Build MPI,/opt/mpich2/mpich2-1.4.1p1/bin/mpiexecand/opt/mpich2/mpich2-1.4.1p1/lib/libmpich.soare ready to use, so you can test the build with:

    $ /opt/mpich2/mpich2-1.4.1p1/bin/mpiexec -n 4 hostname
  2. Create anmpiLibConf(Parallel Computing Toolbox)function to direct Parallel Computing Toolbox to use your new MPI. Write yourmpiLibConf.mto return the appropriate information for your build. For example:

    function [primary, extras] = mpiLibConf primary = '/opt/mpich2/mpich2-1.4.1p1/lib/libmpich.so'; extras = {};

    Theprimarypathmustbe validon the cluster; and yourmpiLibConf.mfile must be higher on the cluster workers’ path thanmatlabroot/toolbox/parallel/mpi. (SendingmpiLibConf.mas an attached file for this purpose does not work. You can get thempiLibConf.mfunction on the worker path by either moving the file into a folder on the path, or by having the scheduler usecd在其命令启动MATLAB®worker from within the folder that contains the function.)

  3. Determine necessary daemons and command-line options.

    • Determine all necessary daemons (often something likempdbootorsmpd). Thegforkerbuild example in this section uses an MPI that needs no services or daemons running on the cluster, but it can use only the local machine.

    • Determine the correct command-line options to pass tompiexec.

  4. To set up your cluster to use your new MPI build, modify your communicating job wrapper script to pick up the correctmpiexec. Additionally, there might be a stage in the wrapper script where the MPI process manager daemons are launched.

    The communicating job wrapper script must:

    • Determine which nodes are allocated by the scheduler.

    • Start required daemon processes. For example, for the MPD process manager this means calling"mpdboot -f ".

    • Define whichmpiexecexecutable to use for starting workers.

    • Stop the daemon processes. For example, for the MPD process manager this means calling"mpdallexit".

    For examples of communicating job wrapper scripts, seeSample Plugin Scripts(Parallel Computing Toolbox).

Baidu
map