diff --git a/IPython/kernel/scripts/ipcluster.py b/IPython/kernel/scripts/ipcluster.py index 640a41a..f740169 100644 --- a/IPython/kernel/scripts/ipcluster.py +++ b/IPython/kernel/scripts/ipcluster.py @@ -513,7 +513,8 @@ def main_local(args): dstart.addErrback(lambda f: f.raiseException()) -def main_mpirun(args): +def main_mpi(args): + print vars(args) cont_args = [] cont_args.append('--logfile=%s' % pjoin(args.logdir,'ipcontroller')) @@ -524,7 +525,7 @@ def main_mpirun(args): cl = ControllerLauncher(extra_args=cont_args) dstart = cl.start() def start_engines(cont_pid): - raw_args = ['mpirun'] + raw_args = [args.cmd] raw_args.extend(['-n',str(args.n)]) raw_args.append('ipengine') raw_args.append('-l') @@ -665,7 +666,7 @@ def get_args(): parser_mpirun = subparsers.add_parser( 'mpirun', - help='run a cluster using mpirun', + help='run a cluster using mpirun (mpiexec also works)', parents=[base_parser] ) parser_mpirun.add_argument( @@ -674,7 +675,20 @@ def get_args(): dest="mpi", # Don't put a default here to allow no MPI support help="how to call MPI_Init (default=mpi4py)" ) - parser_mpirun.set_defaults(func=main_mpirun) + parser_mpirun.set_defaults(func=main_mpi, cmd='mpirun') + + parser_mpiexec = subparsers.add_parser( + 'mpiexec', + help='run a cluster using mpiexec (mpirun also works)', + parents=[base_parser] + ) + parser_mpiexec.add_argument( + "--mpi", + type=str, + dest="mpi", # Don't put a default here to allow no MPI support + help="how to call MPI_Init (default=mpi4py)" + ) + parser_mpiexec.set_defaults(func=main_mpi, cmd='mpiexec') parser_pbs = subparsers.add_parser( 'pbs', diff --git a/docs/source/parallel/parallel_process.txt b/docs/source/parallel/parallel_process.txt index d35ffc9..0c4b7d3 100644 --- a/docs/source/parallel/parallel_process.txt +++ b/docs/source/parallel/parallel_process.txt @@ -85,33 +85,40 @@ To see other command line options for the local mode, do:: $ ipcluster local -h -Using :command:`ipcluster` in mpirun mode ------------------------------------------ +Using :command:`ipcluster` in mpiexec/mpirun mode +------------------------------------------------- -The mpirun mode is useful if you: +The mpiexec/mpirun mode is useful if you: 1. Have MPI installed. -2. Your systems are configured to use the :command:`mpirun` command to start - processes. +2. Your systems are configured to use the :command:`mpiexec` or + :command:`mpirun` commands to start MPI processes. + +.. note:: + + The preferred command to use is :command:`mpiexec`. However, we also + support :command:`mpirun` for backwards compatibility. The underlying + logic used is exactly the same, the only difference being the name of the + command line program that is called. If these are satisfied, you can start an IPython cluster using:: - $ ipcluster mpirun -n 4 + $ ipcluster mpiexec -n 4 This does the following: 1. Starts the IPython controller on current host. -2. Uses :command:`mpirun` to start 4 engines. +2. Uses :command:`mpiexec` to start 4 engines. On newer MPI implementations (such as OpenMPI), this will work even if you don't make any calls to MPI or call :func:`MPI_Init`. However, older MPI implementations actually require each process to call :func:`MPI_Init` upon starting. The easiest way of having this done is to install the mpi4py [mpi4py]_ package and then call ipcluster with the ``--mpi`` option:: - $ ipcluster mpirun -n 4 --mpi=mpi4py + $ ipcluster mpiexec -n 4 --mpi=mpi4py Unfortunately, even this won't work for some MPI implementations. If you are having problems with this, you will likely have to use a custom Python executable that itself calls :func:`MPI_Init` at the appropriate time. Fortunately, mpi4py comes with such a custom Python executable that is easy to install and use. However, this custom Python executable approach will not work with :command:`ipcluster` currently. Additional command line options for this mode can be found by doing:: - $ ipcluster mpirun -h + $ ipcluster mpiexec -h More details on using MPI with IPython can be found :ref:`here `.