From 3095d2dde0863cd3998c98db03f37d21b1adb1e5 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Mon, 1 Jul 2024 10:06:35 -0400 Subject: [PATCH 1/2] configure: Add --with-mpi-moduledir configure CLI option Parameterize the install location of Fortran MPI bindings modulefiles via the configure --with-mpi-moduledir CLI option (default to $libdir, per all prior versions of Open MPI). Signed-off-by: Jeff Squyres (cherry picked from commit 73385943a72413b29b8cd71ee7774fad2a98eb6a) --- config/ompi_configure_options.m4 | 9 +++++++++ config/opal_setup_wrappers.m4 | 4 ++-- docs/installing-open-mpi/configure-cli-options/mpi.rst | 5 +++++ ompi/mpi/fortran/mpiext-use-mpi-f08/Makefile.am | 8 ++++---- ompi/mpi/fortran/mpiext-use-mpi/Makefile.am | 8 ++++---- ompi/mpi/fortran/use-mpi-f08/Makefile.am | 8 ++++---- ompi/mpi/fortran/use-mpi-f08/mod/Makefile.am | 8 ++++---- ompi/mpi/fortran/use-mpi-ignore-tkr/Makefile.am | 8 ++++---- ompi/mpi/fortran/use-mpi-tkr/Makefile.am | 8 ++++---- ompi/mpi/fortran/use-mpi/Makefile.am | 8 ++++---- 10 files changed, 44 insertions(+), 30 deletions(-) diff --git a/config/ompi_configure_options.m4 b/config/ompi_configure_options.m4 index 70353f0fe41..1ebf01f0dc4 100644 --- a/config/ompi_configure_options.m4 +++ b/config/ompi_configure_options.m4 @@ -166,6 +166,15 @@ case "x$enable_mpi_fortran" in ;; esac +AC_MSG_CHECKING([where to install Fortran MPI modules]) +AC_ARG_WITH([mpi-moduledir], + [AS_HELP_STRING([--with-mpi-moduledir], + [specify where to install Fortran MPI modules (default: $libdir)])], + [OMPI_FORTRAN_MODULEDIR=$withval], + [OMPI_FORTRAN_MODULEDIR=$libdir]) +AC_SUBST(OMPI_FORTRAN_MODULEDIR) +AC_MSG_RESULT([$OMPI_FORTRAN_MODULEDIR]) + # Remove these when we finally kill them once and for all AC_ARG_ENABLE([mpi1-compatibility], [AS_HELP_STRING([--enable-mpi1-compatibility], diff --git a/config/opal_setup_wrappers.m4 b/config/opal_setup_wrappers.m4 index bf1012802c4..3bfd6e465c5 100644 --- a/config/opal_setup_wrappers.m4 +++ b/config/opal_setup_wrappers.m4 @@ -541,7 +541,7 @@ AC_DEFUN([OPAL_SETUP_WRAPPER_FINAL],[ OMPI_WRAPPER_FCFLAGS='-I${includedir}'" ${wrapper_extra_fcflags} ${with_wrapper_fcflags}" AS_IF([test -n "${OMPI_FC_MODULE_FLAG}"], [dnl deal with some interesting expansion behavior in OPAL_APPEND - wrapper_tmp_arg="${OMPI_FC_MODULE_FLAG}"'${libdir}' + wrapper_tmp_arg="${OMPI_FC_MODULE_FLAG} ${OMPI_FORTRAN_MODULEDIR}" OPAL_APPEND([OMPI_WRAPPER_FCFLAGS], [${wrapper_tmp_arg}])]) AC_SUBST([OMPI_WRAPPER_FCFLAGS]) AC_MSG_RESULT([$OMPI_WRAPPER_EXTRA_FCFLAGS]) @@ -780,7 +780,7 @@ AC_DEFUN([OPAL_SETUP_WRAPPER_FINAL],[ OSHMEM_WRAPPER_FCFLAGS='-I${includedir}'" ${wrapper_extra_fcflags} ${with_wrapper_fcflags}" AS_IF([test -n "${OMPI_FC_MODULE_FLAG}"], [dnl deal with some interesting expansion behavior in OPAL_APPEND - wrapper_tmp_arg="${OMPI_FC_MODULE_FLAG}"'${libdir}' + wrapper_tmp_arg="${OMPI_FC_MODULE_FLAG} ${OMPI_FORTRAN_MODULEDIR}" OPAL_APPEND([OSHMEM_WRAPPER_FCFLAGS], [${wrapper_tmp_arg}])]) AC_SUBST([OSHMEM_WRAPPER_FCFLAGS]) AC_MSG_RESULT([$OSHMEM_WRAPPER_EXTRA_FCFLAGS]) diff --git a/docs/installing-open-mpi/configure-cli-options/mpi.rst b/docs/installing-open-mpi/configure-cli-options/mpi.rst index 150b0f80949..6205175443d 100644 --- a/docs/installing-open-mpi/configure-cli-options/mpi.rst +++ b/docs/installing-open-mpi/configure-cli-options/mpi.rst @@ -60,6 +60,11 @@ MPI API behaviors that can be used with ``configure``: ``--disable-mpi-fortran``). This is mutually exclusive with building the OpenSHMEM Fortran interface. +* ``--with-mpi-moduledir=DIR``: + Specify a specific ``DIR`` directory where to install the MPI + Fortran bindings modulefiles. By default, Open MPI will install + Fortran modulefiles into ``$libdir``. + * ``--enable-mpi-ext[=LIST]``: Enable Open MPI's non-portable API extensions. ``LIST`` is a comma-delmited list of extensions. If no ``LIST`` is specified, all diff --git a/ompi/mpi/fortran/mpiext-use-mpi-f08/Makefile.am b/ompi/mpi/fortran/mpiext-use-mpi-f08/Makefile.am index 5e5312f6e2d..50d8445905b 100644 --- a/ompi/mpi/fortran/mpiext-use-mpi-f08/Makefile.am +++ b/ompi/mpi/fortran/mpiext-use-mpi-f08/Makefile.am @@ -73,14 +73,14 @@ CLEANFILES += *.i90 # install-exec-hook: @ for file in `ls *.mod`; do \ - echo $(INSTALL) $$file $(DESTDIR)$(libdir); \ - $(INSTALL) $$file $(DESTDIR)$(libdir); \ + echo $(INSTALL) $$file $(DESTDIR)$(OMPI_FORTRAN_MODULEDIR); \ + $(INSTALL) $$file $(DESTDIR)$(OMPI_FORTRAN_MODULEDIR); \ done uninstall-local: @ for file in `ls *.mod`; do \ - echo rm -f $(DESTDIR)$(libdir)/$$file; \ - rm -f $(DESTDIR)$(libdir)/$$file; \ + echo rm -f $(DESTDIR)$(OMPI_FORTRAN_MODULEDIR)/$$file; \ + rm -f $(DESTDIR)$(OMPI_FORTRAN_MODULEDIR)/$$file; \ done else diff --git a/ompi/mpi/fortran/mpiext-use-mpi/Makefile.am b/ompi/mpi/fortran/mpiext-use-mpi/Makefile.am index 825da31f1a8..25d53171ffd 100644 --- a/ompi/mpi/fortran/mpiext-use-mpi/Makefile.am +++ b/ompi/mpi/fortran/mpiext-use-mpi/Makefile.am @@ -71,14 +71,14 @@ CLEANFILES += *.i90 # install-exec-hook: @ for file in `ls *.mod`; do \ - echo $(INSTALL) $$file $(DESTDIR)$(libdir); \ - $(INSTALL) $$file $(DESTDIR)$(libdir); \ + echo $(INSTALL) $$file $(DESTDIR)$(OMPI_FORTRAN_MODULEDIR); \ + $(INSTALL) $$file $(DESTDIR)$(OMPI_FORTRAN_MODULEDIR); \ done uninstall-local: @ for file in `ls *.mod`; do \ - echo rm -f $(DESTDIR)$(libdir)/$$file; \ - rm -f $(DESTDIR)$(libdir)/$$file; \ + echo rm -f $(DESTDIR)$(OMPI_FORTRAN_MODULEDIR)/$$file; \ + rm -f $(DESTDIR)$(OMPI_FORTRAN_MODULEDIR)/$$file; \ done else diff --git a/ompi/mpi/fortran/use-mpi-f08/Makefile.am b/ompi/mpi/fortran/use-mpi-f08/Makefile.am index d788d56c2da..9440b7a9c23 100644 --- a/ompi/mpi/fortran/use-mpi-f08/Makefile.am +++ b/ompi/mpi/fortran/use-mpi-f08/Makefile.am @@ -566,14 +566,14 @@ mpi-f08.lo: $(module_sentinel_files) $(SIZEOF_H) install-exec-hook: @ for file in `ls *.mod`; do \ - echo $(INSTALL) $$file $(DESTDIR)$(libdir); \ - $(INSTALL) $$file $(DESTDIR)$(libdir); \ + echo $(INSTALL) $$file $(DESTDIR)$(OMPI_FORTRAN_MODULEDIR); \ + $(INSTALL) $$file $(DESTDIR)$(OMPI_FORTRAN_MODULEDIR); \ done uninstall-local: @ for file in `ls *.mod`; do \ - echo rm -f $(DESTDIR)$(libdir)/$$file; \ - rm -f $(DESTDIR)$(libdir)/$$file; \ + echo rm -f $(DESTDIR)$(OMPI_FORTRAN_MODULEDIR)/$$file; \ + rm -f $(DESTDIR)$(OMPI_FORTRAN_MODULEDIR)/$$file; \ done endif diff --git a/ompi/mpi/fortran/use-mpi-f08/mod/Makefile.am b/ompi/mpi/fortran/use-mpi-f08/mod/Makefile.am index 87f1c2db8ba..bf6595c0d9f 100644 --- a/ompi/mpi/fortran/use-mpi-f08/mod/Makefile.am +++ b/ompi/mpi/fortran/use-mpi-f08/mod/Makefile.am @@ -102,14 +102,14 @@ pmpi-f08-interfaces.lo: mpi-f08-rename.h install-exec-hook: @ for file in `ls *.mod`; do \ - echo $(INSTALL) $$file $(DESTDIR)$(libdir); \ - $(INSTALL) $$file $(DESTDIR)$(libdir); \ + echo $(INSTALL) $$file $(DESTDIR)$(OMPI_FORTRAN_MODULEDIR); \ + $(INSTALL) $$file $(DESTDIR)$(OMPI_FORTRAN_MODULEDIR); \ done uninstall-local: @ for file in `ls *.mod`; do \ - echo rm -f $(DESTDIR)$(libdir)/$$file; \ - rm -f $(DESTDIR)$(libdir)/$$file; \ + echo rm -f $(DESTDIR)$(OMPI_FORTRAN_MODULEDIR)/$$file; \ + rm -f $(DESTDIR)$(OMPI_FORTRAN_MODULEDIR)/$$file; \ done endif diff --git a/ompi/mpi/fortran/use-mpi-ignore-tkr/Makefile.am b/ompi/mpi/fortran/use-mpi-ignore-tkr/Makefile.am index 73a04972bf0..ed23a0fdea7 100644 --- a/ompi/mpi/fortran/use-mpi-ignore-tkr/Makefile.am +++ b/ompi/mpi/fortran/use-mpi-ignore-tkr/Makefile.am @@ -136,14 +136,14 @@ CLEANFILES += *.i90 install-exec-hook: @ for file in `ls *.mod`; do \ - echo $(INSTALL) $$file $(DESTDIR)$(libdir); \ - $(INSTALL) $$file $(DESTDIR)$(libdir); \ + echo $(INSTALL) $$file $(DESTDIR)$(OMPI_FORTRAN_MODULEDIR); \ + $(INSTALL) $$file $(DESTDIR)$(OMPI_FORTRAN_MODULEDIR); \ done uninstall-local: @ for file in `ls *.mod`; do \ - echo rm -f $(DESTDIR)$(libdir)/$$file; \ - rm -f $(DESTDIR)$(libdir)/$$file; \ + echo rm -f $(DESTDIR)$(OMPI_FORTRAN_MODULEDIR)/$$file; \ + rm -f $(DESTDIR)$(OMPI_FORTRAN_MODULEDIR)/$$file; \ done endif diff --git a/ompi/mpi/fortran/use-mpi-tkr/Makefile.am b/ompi/mpi/fortran/use-mpi-tkr/Makefile.am index d44aa22244f..ddbbc418169 100644 --- a/ompi/mpi/fortran/use-mpi-tkr/Makefile.am +++ b/ompi/mpi/fortran/use-mpi-tkr/Makefile.am @@ -168,14 +168,14 @@ DISTCLEANFILES = $(nodist_lib@OMPI_LIBMPI_NAME@_usempi_la_SOURCES) install-exec-hook: @ for file in `ls *.mod`; do \ - echo $(INSTALL) $$file $(DESTDIR)$(libdir); \ - $(INSTALL) $$file $(DESTDIR)$(libdir); \ + echo $(INSTALL) $$file $(DESTDIR)$(OMPI_FORTRAN_MODULEDIR); \ + $(INSTALL) $$file $(DESTDIR)$(OMPI_FORTRAN_MODULEDIR); \ done uninstall-local: @ for file in `ls *.mod`; do \ - echo rm -f $(DESTDIR)$(libdir)/$$file; \ - rm -f $(DESTDIR)$(libdir)/$$file; \ + echo rm -f $(DESTDIR)$(OMPI_FORTRAN_MODULEDIR)/$$file; \ + rm -f $(DESTDIR)$(OMPI_FORTRAN_MODULEDIR)/$$file; \ done # if OMPI_BUILD_FORTRAN_USEMPI_TKR_BINDINGS diff --git a/ompi/mpi/fortran/use-mpi/Makefile.am b/ompi/mpi/fortran/use-mpi/Makefile.am index 3f1bc6b1760..edc2b088ddc 100644 --- a/ompi/mpi/fortran/use-mpi/Makefile.am +++ b/ompi/mpi/fortran/use-mpi/Makefile.am @@ -55,13 +55,13 @@ mpi-types.lo: mpi-types.F90 install-exec-hook: @ for file in `ls *.mod`; do \ - echo $(INSTALL) $$file $(DESTDIR)$(libdir); \ - $(INSTALL) $$file $(DESTDIR)$(libdir); \ + echo $(INSTALL) $$file $(DESTDIR)$(OMPI_FORTRAN_MODULEDIR); \ + $(INSTALL) $$file $(DESTDIR)$(OMPI_FORTRAN_MODULEDIR); \ done uninstall-local: @ for file in `ls *.mod`; do \ - echo rm -f $(DESTDIR)$(libdir)/$$file; \ - rm -f $(DESTDIR)$(libdir)/$$file; \ + echo rm -f $(DESTDIR)$(OMPI_FORTRAN_MODULEDIR)/$$file; \ + rm -f $(DESTDIR)$(OMPI_FORTRAN_MODULEDIR)/$$file; \ done endif From 479c1c38c2ac8d22c4af62b57aff5f5d67766105 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Wed, 10 Jul 2024 17:37:54 -0400 Subject: [PATCH 2/2] docs: Add explicit docs about --with-mpi-moduledir As a follow on to 73385943a7, add some additional information about the --with-mpi-moduledir configure CLI option, especially as it pertains to making relocatable Open MPI installations. Also, remove an errant space that crept into the mpifort wrapper compiler flags in 73385943a7. Signed-off-by: Jeff Squyres (cherry picked from commit 105050930c41a7c842cd58666d2c3e34c267d47d) --- config/opal_setup_wrappers.m4 | 4 +- .../configure-cli-options/misc.rst | 32 +++++++++++++++ .../installation-location.rst | 39 +++++++++++++++++++ 3 files changed, 73 insertions(+), 2 deletions(-) diff --git a/config/opal_setup_wrappers.m4 b/config/opal_setup_wrappers.m4 index 3bfd6e465c5..697f4652248 100644 --- a/config/opal_setup_wrappers.m4 +++ b/config/opal_setup_wrappers.m4 @@ -541,7 +541,7 @@ AC_DEFUN([OPAL_SETUP_WRAPPER_FINAL],[ OMPI_WRAPPER_FCFLAGS='-I${includedir}'" ${wrapper_extra_fcflags} ${with_wrapper_fcflags}" AS_IF([test -n "${OMPI_FC_MODULE_FLAG}"], [dnl deal with some interesting expansion behavior in OPAL_APPEND - wrapper_tmp_arg="${OMPI_FC_MODULE_FLAG} ${OMPI_FORTRAN_MODULEDIR}" + wrapper_tmp_arg="${OMPI_FC_MODULE_FLAG}${OMPI_FORTRAN_MODULEDIR}" OPAL_APPEND([OMPI_WRAPPER_FCFLAGS], [${wrapper_tmp_arg}])]) AC_SUBST([OMPI_WRAPPER_FCFLAGS]) AC_MSG_RESULT([$OMPI_WRAPPER_EXTRA_FCFLAGS]) @@ -780,7 +780,7 @@ AC_DEFUN([OPAL_SETUP_WRAPPER_FINAL],[ OSHMEM_WRAPPER_FCFLAGS='-I${includedir}'" ${wrapper_extra_fcflags} ${with_wrapper_fcflags}" AS_IF([test -n "${OMPI_FC_MODULE_FLAG}"], [dnl deal with some interesting expansion behavior in OPAL_APPEND - wrapper_tmp_arg="${OMPI_FC_MODULE_FLAG} ${OMPI_FORTRAN_MODULEDIR}" + wrapper_tmp_arg="${OMPI_FC_MODULE_FLAG}${OMPI_FORTRAN_MODULEDIR}" OPAL_APPEND([OSHMEM_WRAPPER_FCFLAGS], [${wrapper_tmp_arg}])]) AC_SUBST([OSHMEM_WRAPPER_FCFLAGS]) AC_MSG_RESULT([$OSHMEM_WRAPPER_EXTRA_FCFLAGS]) diff --git a/docs/installing-open-mpi/configure-cli-options/misc.rst b/docs/installing-open-mpi/configure-cli-options/misc.rst index 0059d88307b..30d93f22786 100644 --- a/docs/installing-open-mpi/configure-cli-options/misc.rst +++ b/docs/installing-open-mpi/configure-cli-options/misc.rst @@ -63,3 +63,35 @@ above categories that can be used with ``configure``: See the section on :ref:`customizing wrapper compiler behavior ` to see how to alter the wrapper compiler behavior at run time. + +* ``--with-mpi-moduledir``: Specify the directory where the Fortran + MPI module files are installed. + + For historical reasons, Open MPI's Fortran MPI modulefiles are + installed into ``$libdir`` by default. This option lets you change + where they are installed; some users prefer Fortran module files + installed into ``$installdir``, for example. + + .. note:: If you intend to make your Open MPI installation + relocatable :ref:`via the OPAL_PREFIX mechanism + `, you will want to ensure + to specify the module directory relative to the + ``prefix``. For example: + + .. code-block:: + + $ ./configure --prefix=/opt/openmpi --with-mpi-moduledir='${includedir}/modules`... + + Note the additional shell quoting that is likely necessary + to prevent shell variable expansion, and the additional + ``${}`` around ``includedir`` that is necessary for Open MPI + to recognize that it is a special name that needs to be + expanded. + + Finally, note that the Fortran module installation + directory is *not* one of the :ref:`recognized directories + that can be specified via environment variable at run time + `. + Instead, to make the Fortran module directory relocatable, + it needs to be relative to one of the other recognized + directories. diff --git a/docs/installing-open-mpi/installation-location.rst b/docs/installing-open-mpi/installation-location.rst index 142e2467f93..ee90b5bb432 100644 --- a/docs/installing-open-mpi/installation-location.rst +++ b/docs/installing-open-mpi/installation-location.rst @@ -162,6 +162,8 @@ variables to the new location where Open MPI now resides). There are three methods. +.. _install-location-opal-prefix: + Move an existing Open MPI installation to a new prefix ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -171,6 +173,41 @@ MPI. For example, if Open MPI had initially been installed to ``/home/openmpi``, setting ``OPAL_PREFIX`` to ``/home/openmpi`` will enable Open MPI to function properly. +.. note:: The ``OPAL_PREFIX`` mechanism relies on all installation + directories being specified as relative to the ``prefix`` + directory specified during ``configure``. + + For example, if Open MPI is configured the following way: + + .. code-block:: + + $ ./configure --prefix=/opt/openmpi --libdir=/usr/lib ... + + Then setting ``OPAL_PREFIX`` will not affect the run-time + implications of ``libdir``, since ``/usr/lib`` is not + specified as relative to ``/opt/openmpi``. + + Instead of specifying absolute directories, you can make + them relative to other ``configure``-recognized directories. + For example: + + .. code-block:: + + $ ./configure --prefix=/opt/openmpi --libdir='${exec_prefix}/x86_64/lib' ... + + Note the additional shell quoting that is likely necessary + to prevent shell variable expansion, and the additional + ``${}`` around ``exec_prefix`` that is necessary for Open MPI + to recognize that it is a special name that needs to be + expanded. + + The directory names recognized by Open MPI are listed in the + :ref:`Overriding individual directories + ` + section (below), without the ``OPAL_`` prefix, and in lower + case. For example, the ``OPAL_SYSCONFDIR`` environment + variable corresponds to ``${sysconfdir}``. + "Stage" an Open MPI installation in a temporary location ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -189,6 +226,8 @@ 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. +.. _install-location-overriding-individual-directories: + Overriding individual directories ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^