.. _label-quickstart-building-open-mpi:

Quick start: Installing Open MPI
================================

Although this section skips many details, it offers examples that will
probably work in many environments.

.. caution:: Note that this section is a "Quick start" |mdash| it does
   not attempt to be comprehensive or describe how to build Open MPI
   in all supported environments.  The examples below may therefore
   not work exactly as shown in your environment.

   Please consult the other sections in this chapter for more details,
   if necessary.

.. important:: If you have checked out a *developer's copy* of Open MPI
   (i.e., you cloned from Git), you really need to read :doc:`the
   Developer's Guide </developers/index>` before attempting to build Open
   MPI. Really.

Binary packages
---------------

Although the Open MPI community itself does not distribute binary
packages for Open MPI, many downstream packagers do.

For example, many Linux distributions include Open MPI packages
|mdash| even if they are not installed by default.  You should consult
the documentation and/or package list for your Linux distribution to
see if you can use its built-in package system to install Open MPI.

The MacOS package managers `Homebrew <https://brew.sh/>`_ and
`MacPorts <https://macports.org/>`_ both offer binary Open MPI
packages:

.. code-block:: sh

   # For Homebrew
   shell$ brew install openmpi

   # For MacPorts
   shell$ port install openmpi

.. important:: Binary packages may or may not include support for
               features that are required on your platform (e.g., a
               specific networking stack).  Or the binary packages
               available to you may be older / out of date.  As such,
               it may be better to build and install Open MPI from a
               source tarball available from `the main Open MPI web
               site <https://www.open-mpi.org/>`_.

Building from source
--------------------

Open MPI uses a traditional ``configure`` script paired with ``make``
to build.  Typical installs can be of the pattern:

.. code-block:: sh

   shell$ tar xf openmpi-<version>.tar.bz2
   shell$ cd openmpi-<version>
   shell$ ./configure --prefix=<path> [...options...] 2>&1 | tee config.out
   <... lots of output ...>

   # Use an integer value of N for parallel builds
   shell$ make [-j N] all 2>&1 | tee make.out

   # ...lots of output...

   # Depending on the <prefix> chosen above, you may need root access
   # for the following:
   shell$ make install 2>&1 | tee install.out

   # ...lots of output...

Note that VPATH builds are fully supported.  For example:

.. code-block:: sh

   shell$ tar xf openmpi-<version>.tar.bz2
   shell$ cd openmpi-<version>
   shell$ mkdir build
   shell$ cd build
   shell$ ../configure --prefix=<path> 2>&1 | tee config.out
   # ...etc.

The above patterns can be used in many environments.

Note that there are many, many configuration options available in the
``./configure`` step.  Some of them may be needed for your particular
HPC network interconnect type and/or computing environment; see the
rest of this chapter for descriptions of the available options.
