
.. _building-open-mpi-installation-location-label:

Installation location
=====================

A common environment to run Open MPI is in a "Beowulf"-class or
similar cluster (e.g., a bunch of 1U servers in a bunch of racks).
Simply stated, Open MPI can run on a group of servers or workstations
connected by a network.

This raises the question for Open MPI system administrators: where to
install the Open MPI binaries, header files, etc.?  This discussion
mainly addresses this question for homogeneous clusters (i.e., where
all nodes and operating systems are the same), although elements of
this discussion apply to heterogeneous clusters as well.

.. important:: For simplicity, the Open MPI team *strongly* recommends
   that you install Open MPI at the same path location on all nodes in
   your cluster.  This *greatly* simplifies the user experience of
   running MPI jobs across multiple nodes in your cluster.

   It is *possible* to install Open MPI in unique path locations in
   the different nodes in your cluster, but it is not *advisable*.

Filesystem types
----------------

There are two common approaches.

Network filesystem
^^^^^^^^^^^^^^^^^^

Have a common filesystem, such as NFS, between all the machines to be
used.  Install Open MPI such that the installation directory is the
*same value* on each node.  This will *greatly* simplify user's shell
startup scripts (e.g., ``.bashrc``, ``.cshrc``, ``.profile`` etc.)
|mdash| the ``PATH`` can be set without checking which machine the
user is on.  It also simplifies the system administrator's job; when
the time comes to patch or otherwise upgrade Open MPI, only one copy
needs to be modified.

For example, consider a cluster of four machines: ``inky``,
``blinky``, ``pinky``, and ``clyde``.

* Install Open MPI on ``inky``'s local hard drive in the directory
  ``/opt/openmpi-VERSION``.  The system administrator then mounts
  ``inky:/opt/openmpi-VERSION`` on the remaining three machines, such
  that ``/opt/openmpi-VERSION`` on all machines is effectively "the
  same".  That is, the following directories all contain the Open MPI
  installation:

  .. code-block::

     inky:/opt/openmpi-VERSION
     blinky:/opt/openmpi-VERSION
     pinky:/opt/openmpi-VERSION
     clyde:/opt/openmpi-VERSION

* Install Open MPI on ``inky``'s local hard drive in the directory
  ``/usr/local/openmpi-VERSION``.  The system administrator then
  mounts ``inky:/usr/local/openmpi-VERSION`` on *all four* machines in
  some other common location, such as ``/opt/openmpi-VERSION`` (a
  symbolic link can be installed on ``inky`` instead of a mount point
  for efficiency).  This strategy is typically used for environments
  where one tree is NFS exported, but another tree is typically used
  for the location of actual installation.  For example, the following
  directories all contain the Open MPI installation:

  .. code-block::

     inky:/opt/openmpi-VERSION
     blinky:/opt/openmpi-VERSION
     pinky:/opt/openmpi-VERSION
      clyde:/opt/openmpi-VERSION

  Notice that there are the same four directories as the previous
  example, but on ``inky``, the directory is *actually* located in
  ``/usr/local/openmpi-VERSION``.

There is a bit of a disadvantage in this approach; each of the remote
nodes have to incur NFS (or whatever filesystem is used) delays to
access the Open MPI directory tree.  However, both the administration
ease and low cost (relatively speaking) of using a networked file
system usually greatly outweighs the cost.  Indeed, once an MPI
application is past MPI initialization, it doesn't use the Open MPI
binaries very much.

Local filesystem
^^^^^^^^^^^^^^^^

If you are concerned with networked filesystem costs of accessing the
Open MPI binaries, you can install Open MPI on the local hard drive of
each node in your system.  Again, it is *highly* advisable to install
Open MPI in the *same* directory on each node so that each user's
``PATH`` can be set to the same value, regardless of the node that a
user has logged on to.

This approach will save some network latency of accessing the Open MPI
binaries, but is typically only used where users are very concerned
about squeezing every single cycle out of their machines, or are
running at extreme scale where a networked filesystem may get
overwhelmed by filesystem requests for Open MPI binaries when running
very large parallel jobs.

.. _building-open-mpi-install-overwrite-label:

Installing over a prior Open MPI installation
---------------------------------------------

.. warning:: The Open MPI team does not recommend installing a new
   version of Open MPI over an existing / older installation of Open
   MPI.

In its default configuration, an Open MPI installation consists of
several shared libraries, header files, executables, and plugins
(dynamic shared objects |mdash| DSOs).  These installation files act
together as a single entity.  The specific filenames and
contents of these files are subject to change between different
versions of Open MPI.

.. important:: Installing one version of Open MPI does *not* uninstall
   another version.

If you install a new version of Open MPI over an older version, this
may not overwrite all the files from the older version.  Hence, you
may end up with an incompatible muddle of files from two different
installations |mdash| which can cause problems.

The Open MPI team recommends one of the following methods for
upgrading your Open MPI installation:

* Install newer versions of Open MPI into a different directory. For
  example, install into ``/opt/openmpi-a.b.c`` and
  ``/opt/openmpi-x.y.z`` for versions a.b.c and x.y.z, respectively.
* Completely uninstall the old version of Open MPI before installing
  the new version.  The ``make uninstall`` process from Open MPI a.b.c
  build tree should completely uninstall that version from the
  installation tree, making it safe to install a new version (e.g.,
  version x.y.z) into the same installation tree.
* Remove the old installation directory entirely and then install the
  new version.  For example ``rm -rf /opt/openmpi`` *(assuming that
  there is nothing else of value in this tree!)* The installation of
  Open MPI x.y.z will safely re-create the ``/opt/openmpi`` tree.
  This method is preferable if you no longer have the source and build
  trees to Open MPI a.b.c available from which to ``make
  uninstall``.
* Go into the Open MPI a.b.c installation directory and manually
  remove all old Open MPI files.  Then install Open MPI x.y.z into the
  same installation directory.  This can be a somewhat painful,
  annoying, and error-prone process.  *We do not recommend it.*
  Indeed, if you no longer have access to the original Open MPI a.b.c
  source and build trees, it may be far simpler to download Open MPI
  version a.b.c again from the Open MPI web site, configure it with
  the same installation prefix, and then run ``make uninstall``.  Or
  use one of the other methods, above.

Relocating an Open MPI installation
-----------------------------------

It can be desirable to initially install Open MPI to one location
(e.g., ``/path/to/openmpi``) and then later move it to another
location (e.g., ``/opt/myproduct/bundled-openmpi-a.b.c``).

.. note:: Open MPI hard-codes some directory paths in its executables
          based on installation paths specified by the ``configure``
          script.  For example, if you configure with an installation
          prefix of ``/opt/openmpi/``, Open MPI encodes in its
          executables that it should be able to find its help files in
          ``/opt/openmpi/share/openmpi``.

The "installdirs" functionality in Open MPI lets you change any of
these hard-coded directory paths at run time (*assuming* that you have
already adjusted your ``PATH`` and/or ``LD_LIBRARY_PATH`` environment
variables to the new location where Open MPI now resides).

There are three methods.

Move an existing Open MPI installation to a new prefix
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Set the ``OPAL_PREFIX`` environment variable before launching Open
MPI.  For example, if Open MPI had initially been installed to
``/opt/openmpi`` and the entire ``openmpi`` tree was later moved to
``/home/openmpi``, setting ``OPAL_PREFIX`` to ``/home/openmpi`` will
enable Open MPI to function properly.

"Stage" an Open MPI installation in a temporary location
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

When *creating* self-contained installation packages, systems such as
RPM install Open MPI into temporary locations.  The package system
then bundles up everything under the temporary location into a package
that can be installed into its real location later.  For example, when
*creating* an RPM that will be installed to ``/opt/openmpi``, the RPM
system will transparently prepend a "destination directory" (or
"destdir") to the installation directory.  As such, Open MPI will
think that it is installed in ``/opt/openmpi``, but it is actually
temporarily installed in (for example)
``/var/rpm/build.1234/opt/openmpi``.  If it is necessary to *use* Open
MPI while it is installed in this staging area, the ``OPAL_DESTDIR``
environment variable can be used; setting ``OPAL_DESTDIR`` to
``/var/rpm/build.1234`` will automatically prefix every directory such
that Open MPI can function properly.

Overriding individual directories
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Open MPI uses the GNU-specified directories (per Autoconf/Automake),
and can be overridden by setting environment variables directly
related to their common names.  The list of environment variables that
can be used is:

* ``OPAL_PREFIX``
* ``OPAL_EXEC_PREFIX``
* ``OPAL_BINDIR``
* ``OPAL_SBINDIR``
* ``OPAL_LIBEXECDIR``
* ``OPAL_DATAROOTDIR``
* ``OPAL_DATADIR``
* ``OPAL_SYSCONFDIR``
* ``OPAL_SHAREDSTATEDIR``
* ``OPAL_LOCALSTATEDIR``
* ``OPAL_LIBDIR``
* ``OPAL_INCLUDEDIR``
* ``OPAL_INFODIR``
* ``OPAL_MANDIR``
* ``OPAL_PKGDATADIR``
* ``OPAL_PKGLIBDIR``
* ``OPAL_PKGINCLUDEDIR``

Note that not all of the directories listed above are used by Open
MPI; they are listed here in entirety for completeness.

Also note that several directories listed above are defined in terms
of other directories.  For example, the ``$bindir`` is defined by
default as ``$prefix/bin``.  Hence, overriding the ``$prefix`` (via
``OPAL_PREFIX``) will automatically change the first part of the
``$bindir`` (which is how method 1 described above works).
Alternatively, ``OPAL_BINDIR`` can be set to an absolute value that
ignores ``$prefix`` altogether.
