Skip to content

Commit 44850ae

Browse files
authored
Merge pull request #8530 from bwbarrett/feature/external-prrte
build: Support building against external PRRTE
2 parents a53326c + 73c626a commit 44850ae

File tree

2 files changed

+189
-76
lines changed

2 files changed

+189
-76
lines changed

config/ompi_setup_prrte.m4

Lines changed: 184 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,121 @@
1-
# -*- shell-script -*-
2-
#
3-
# Copyright (c) 2004-2009 The Trustees of Indiana University and Indiana
4-
# University Research and Technology
5-
# Corporation. All rights reserved.
6-
# Copyright (c) 2004-2021 The University of Tennessee and The University
7-
# of Tennessee Research Foundation. All rights
8-
# reserved.
9-
# Copyright (c) 2004-2007 High Performance Computing Center Stuttgart,
10-
# University of Stuttgart. All rights reserved.
11-
# Copyright (c) 2004-2005 The Regents of the University of California.
12-
# All rights reserved.
13-
# Copyright (c) 2006-2009 Cisco Systems, Inc. All rights reserved.
14-
# Copyright (c) 2006-2008 Sun Microsystems, Inc. All rights reserved.
15-
# Copyright (c) 2006-2007 Los Alamos National Security, LLC. All rights
16-
# reserved.
17-
# Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
18-
# Copyright (c) 2019-2020 Intel, Inc. All rights reserved.
19-
# Copyright (c) 2020 Amazon.com, Inc. or its affiliates.
20-
# All Rights reserved.
21-
# Copyright (c) 2021 Nanook Consulting. All rights reserved.
22-
# $COPYRIGHT$
23-
#
24-
# Additional copyrights may follow
25-
#
26-
# $HEADER$
27-
#
28-
29-
# Check for / configure PRRTE package. Unlike the other 3rd party
30-
# packages, prrte is either internal or not used (since prrte is a
31-
# pmix server, we don't need to link against it or such in the
32-
# external case). So we don't have to do some of the complex steps we
33-
# do for pmix or hwloc in terms of external hunting.
34-
#
35-
# This macro will not change the environment.
36-
#
37-
# A Makefile conditional OMPI_WANT_PRRTE will be defined based on the
38-
# results of the build. Unless --disable-internal-rte is specified,
39-
# the top-level configure will abort if the PRRTE configure fails.
1+
dnl -*- autoconf -*-
2+
dnl
3+
dnl Copyright (c) 2004-2009 The Trustees of Indiana University and Indiana
4+
dnl University Research and Technology
5+
dnl Corporation. All rights reserved.
6+
dnl Copyright (c) 2004-2021 The University of Tennessee and The University
7+
dnl of Tennessee Research Foundation. All rights
8+
dnl reserved.
9+
dnl Copyright (c) 2004-2007 High Performance Computing Center Stuttgart,
10+
dnl University of Stuttgart. All rights reserved.
11+
dnl Copyright (c) 2004-2005 The Regents of the University of California.
12+
dnl All rights reserved.
13+
dnl Copyright (c) 2006-2009 Cisco Systems, Inc. All rights reserved.
14+
dnl Copyright (c) 2006-2008 Sun Microsystems, Inc. All rights reserved.
15+
dnl Copyright (c) 2006-2007 Los Alamos National Security, LLC. All rights
16+
dnl reserved.
17+
dnl Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
18+
dnl Copyright (c) 2019-2020 Intel, Inc. All rights reserved.
19+
dnl Copyright (c) 2020 Amazon.com, Inc. or its affiliates.
20+
dnl All Rights reserved.
21+
dnl Copyright (c) 2021 Nanook Consulting. All rights reserved.
22+
dnl $COPYRIGHT$
23+
dnl
24+
dnl Additional copyrights may follow
25+
dnl
26+
dnl $HEADER$
27+
dnl
28+
29+
dnl Check for / configure PRRTE package. Prefer finding an external
30+
dnl PRRTE, build our internal one if required. If we can not find an
31+
dnl external PRRTE and the internal one fails to configure, abort.
32+
dnl
33+
dnl This macro wil change the environment in the following way:
34+
dnl
35+
dnl * PRTE_PATH will be AC_SUBST'ed to the full path (minus the EXE
36+
dnl extension) of the prte binary.
37+
dnl
38+
dnl A Makefile conditional OMPI_WANT_PRRTE will be defined based on the
39+
dnl results of the build.
4040
AC_DEFUN([OMPI_SETUP_PRRTE],[
41-
OPAL_VAR_SCOPE_PUSH([internal_prrte_build])
41+
OPAL_VAR_SCOPE_PUSH([prrte_setup_internal_happy prrte_setup_external_happy prrte_setup_success_var])
42+
43+
opal_show_subtitle "Configuring PRRTE"
4244
43-
internal_prrte_build=0
45+
# Don't use OPAL_3RDPARTY_WITH because it will not allow packages
46+
# to be disabled
4447
m4_ifdef([package_prrte],
45-
[OMPI_SETUP_PRRTE_INTERNAL([internal_prrte_build=1], [internal_prrte_build=0])])
48+
[AC_ARG_WITH([prrte],
49+
[AC_HELP_STRING([--with-prrte(=DIR)],
50+
[Build PRTE support. DIR can take one of four values: "internal", "external", "no", or a valid directory name. "internal" forces Open MPI to use its internal copy of PRRTE. "external" forces Open MPI to use an external installation of PRRTE. Supplying a valid directory name also forces Open MPI to use an external installation of PRRTE, and adds DIR/include, DIR/lib, and DIR/lib64 to the search path for headers and libraries. If no argument is specified, Open MPI will search default locations for PRRTE and fall back to an internal version if one is not found.])])],
51+
[AC_ARG_WITH([prrte],
52+
[AC_HELP_STRING([--with-prrte(=DIR)],
53+
[Build PRRTE support. DIR can take one of three values: "external", "no", or a valid directory name. "external" forces Open MPI to use an external installation of PRRTE. Supplying a valid directory name also forces Open MPI to use an external installation of PRRTE, and adds DIR/include, DIR/lib, and DIR/lib64 to the search path for headers and libraries. If no argument is specified, Open MPI will search default locations for PRRTE and disable creating mpirun symlinks if one is not found.])])])
54+
55+
# clean up $with_prrte so that it contains only a path or empty
56+
# string. To determine internal or external preferences, use
57+
# $opal_prrte_mode.
58+
AS_IF([test "$with_prrte" = "yes"], [with_prrte=])
59+
AS_CASE([$with_prrte],
60+
["internal"], [with_prrte=""
61+
opal_prrte_mode="internal"],
62+
["external"], [with_prrte=""
63+
opal_prrte_mode="external"],
64+
[""], [opal_prrte_mode="unspecified"],
65+
["no"], [opal_prrte_mode="disabled"],
66+
[opal_prrte_mode="external"])
67+
68+
echo "with_prrte: $with_prrte"
69+
echo "opal_prrte_mode: $opal_prrte_mode"
70+
71+
m4_ifdef([package_prrte], [],
72+
[AS_IF([test "$opal_prrte_mode" = "internal"],
73+
[AC_MSG_WARN([Invalid argument to --with-prrte: internal.])
74+
AC_MSG_ERROR([Cannot continue])])])
75+
76+
prrte_setup_internal_happy=0
77+
m4_ifdef([package_prrte], [
78+
# always configure the internal prrte, so that
79+
# make dist always works.
80+
AS_IF([test "$opal_prrte_mode" = "disabled"], [prrte_setup_success_var=0], [prrte_setup_success_var=1])
81+
_OMPI_SETUP_PRRTE_INTERNAL([prrte_setup_internal_happy=$prrte_setup_success_var])])
82+
83+
# unless internal specifically requested by the user, try to find
84+
# an external that works.
85+
prrte_setup_external_happy=0
86+
AS_IF([test "$opal_prrte_mode" != "internal" -o "$opal_prrte_mode" != "disabled"],
87+
[_OMPI_SETUP_PRRTE_EXTERNAL(
88+
[prrte_setup_external_happy=1
89+
opal_prrte_mode="external"],
90+
[AS_IF([test "$opal_prrte_mode" = "external"],
91+
[AC_MSG_ERROR([External PRRTE requested but not found.])])])])
92+
93+
# external did not work out and customer did not specify external,
94+
# so try the internal version.
95+
AS_IF([test "$prrte_setup_external_happy" = "0" -a "$prrte_setup_internal_happy" = "1"],
96+
[opal_prrte_mode="internal"
97+
_OMPI_SETUP_PRRTE_INTERNAL_POST()])
4698
47-
AM_CONDITIONAL([OMPI_WANT_PRRTE], [test "$internal_prrte_build" = "1"])
99+
AS_IF([test "$opal_prrte_mode" != "disabled"],
100+
[AS_IF([test "$prrte_setup_external_happy" = "0" -a "$prrte_setup_internal_happy" = "0"],
101+
[AC_MSG_ERROR([Could not find viable prrte build.])])])
102+
103+
AC_SUBST([PRTE_PATH])
104+
105+
AM_CONDITIONAL([OMPI_WANT_PRRTE],
106+
[test "$prrte_setup_internal_happy" = "1" -o "$prrte_setup_external_happy" = "1"])
107+
108+
OPAL_SUMMARY_ADD([[Miscellaneous]], [[prrte]], [prrte], [$opal_prrte_mode])
48109
49110
OPAL_VAR_SCOPE_POP
50111
])
51112

52-
AC_DEFUN([OMPI_SETUP_PRRTE_INTERNAL], [
53-
OPAL_VAR_SCOPE_PUSH([internal_prrte_args internal_prrte_extra_libs internal_prrte_happy deprecated_prefix_by_default print_prrte_warning internal_prrte_CPPFLAGS])
54113

55-
opal_show_subtitle "Configuring PRRTE"
56-
57-
AC_ARG_ENABLE([internal-rte],
58-
[AC_HELP_STRING([--enable-internal-rte],
59-
[Enable internal runtime support and provide mpiexec/mpirun (default: enabled)])])
114+
dnl _OMPI_SETUP_PRRTE_INTERNAL([action-if-success], [action-if-not-success])
115+
dnl
116+
dnl Attempt to configure the built-in PRRTE.
117+
AC_DEFUN([_OMPI_SETUP_PRRTE_INTERNAL], [
118+
OPAL_VAR_SCOPE_PUSH([internal_prrte_args internal_prrte_extra_libs internal_prrte_happy deprecated_prefix_by_default print_prrte_warning internal_prrte_CPPFLAGS])
60119
61120
# This is really a PRTE option that should not be in Open MPI, but
62121
# there is not a great way to support the orterun/mpirun checks
@@ -88,10 +147,6 @@ AC_DEFUN([OMPI_SETUP_PRRTE_INTERNAL], [
88147
AS_IF([test -n "$prte_prefix_by_default" -a -n "$deprecated_prefix_by_default"],
89148
[AC_MSG_ERROR([--enable-prte-prefix-by-default cannot be used with --enable-mpirun-prefix-by-default or --enable-orterun-prefix-by-default. Please only specify --enable-prte-prefix-by-default.])])
90149
91-
internal_prrte_happy="yes"
92-
AS_IF([test "$enable_internal_rte" = "no"],
93-
[internal_prrte_happy="no"])
94-
95150
internal_prrte_CPPFLAGS=
96151
internal_prrte_args="--with-proxy-version-string=$OPAL_VERSION --with-proxy-package-name=\"Open MPI\" --with-proxy-bugreport=\"https://www.open-mpi.org/community/help/\""
97152
internal_prrte_libs=
@@ -120,23 +175,22 @@ AC_DEFUN([OMPI_SETUP_PRRTE_INTERNAL], [
120175
internal_prrte_CPPFLAGS="$internal_prrte_CPPFLAGS $opal_pmix_CPPFLAGS"
121176
internal_prrte_libs="$internal_prrte_libs $opal_pmix_LIBS"])
122177
123-
AS_IF([test "$internal_prrte_happy" = "yes"],
124-
[AC_MSG_CHECKING([if PMIx version is 4.0.0 or greater])
125-
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <pmix_version.h>]],
126-
[[
178+
AC_MSG_CHECKING([if PMIx version is 4.0.0 or greater])
179+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <pmix_version.h>]],
180+
[[
127181
#if PMIX_VERSION_MAJOR < 4L
128182
#error "pmix API version is less than 4.0.0"
129183
#endif
130-
]])],
131-
[AC_MSG_RESULT([yes])],
132-
[AC_MSG_RESULT([no])
133-
AC_MSG_WARN([OMPI's internal runtime environment "PRRTE" does not support])
134-
AC_MSG_WARN([PMIx versions less than v4.x as they lack adequate tool])
135-
AC_MSG_WARN([support. You can, if desired, build OMPI against an earlier])
136-
AC_MSG_WARN([version of PMIx for strictly direct-launch purposes - e.g., using)])
137-
AC_MSG_WARN([Slurm's srun to launch the job - by configuring with the])
138-
AC_MSG_WARN([--disable-internal-rte option.])
139-
AC_MSG_ERROR([Cannot continue])])])
184+
]])],
185+
[AC_MSG_RESULT([yes])],
186+
[AC_MSG_RESULT([no])
187+
AC_MSG_WARN([OMPI's internal runtime environment "PRRTE" does not support])
188+
AC_MSG_WARN([PMIx versions less than v4.x as they lack adequate tool])
189+
AC_MSG_WARN([support. You can, if desired, build OMPI against an earlier])
190+
AC_MSG_WARN([version of PMIx for strictly direct-launch purposes - e.g., using])
191+
AC_MSG_WARN([Slurm's srun to launch the job - by configuring with the])
192+
AC_MSG_WARN([--without-prrte option.])
193+
AC_MSG_ERROR([Cannot continue])])
140194
141195
# add the extra libs
142196
internal_prrte_args="$internal_prrte_args --with-prte-extra-lib=\"$internal_prrte_libs\" --with-prte-extra-ltlib=\"$internal_prrte_libs\""
@@ -160,19 +214,76 @@ AC_DEFUN([OMPI_SETUP_PRRTE_INTERNAL], [
160214
[--with-libevent=external], [--with-hwloc=external],
161215
[--with-pmix=internal], [--with-pmix=external],
162216
[--with-platform=[[^ ]]*]],
163-
[], [internal_prrte_happy="no"])
217+
[internal_prrte_happy="yes"], [internal_prrte_happy="no"])
164218
OPAL_SUBDIR_ENV_RESTORE([opal_prrte_configure])
165219
OPAL_3RDPARTY_DIST_SUBDIRS="$OPAL_3RDPARTY_DIST_SUBDIRS prrte"
166220
167221
AS_IF([test "$internal_prrte_happy" = "no" -a "$enable_internal_rte" != "no"],
168222
[AC_MSG_ERROR([PRRTE configuration failed. Cannot continue.])])
169223
170224
AS_IF([test "$internal_prrte_happy" = "yes"],
171-
[OPAL_3RDPARTY_SUBDIRS="$OPAL_3RDPARTY_SUBDIRS prrte"
172-
$1],
173-
[$2])
225+
[$1], [$2])
174226
175-
OPAL_SUMMARY_ADD([[Miscellaneous]], [[PRRTE]], [prrte], [$internal_prrte_happy])
227+
OPAL_VAR_SCOPE_POP
228+
])
229+
230+
231+
dnl _OMPI_SETUP_CONFIG_PRRTE_INTERNAL_POST()
232+
dnl
233+
dnl Expectation is that this is called only if external fails, the
234+
dnl caller configured libprrte configure, and the configure script
235+
dnl succeeded.
236+
AC_DEFUN([_OMPI_SETUP_PRRTE_INTERNAL_POST], [
237+
OPAL_3RDPARTY_SUBDIRS="$OPAL_3RDPARTY_SUBDIRS prrte"
238+
239+
PRTE_PATH="prte"
240+
])
241+
242+
243+
dnl _OMPI_SETUP_PRRTE_EXTERNAL([action if success], [action if not success])
244+
dnl
245+
dnl Try to find an external prrte with sufficient version. Since we
246+
dnl don't link against prrte, only output environment variable is
247+
dnl PRTE_PATH.
248+
AC_DEFUN([_OMPI_SETUP_PRRTE_EXTERNAL], [
249+
OPAL_VAR_SCOPE_PUSH([setup_prrte_external_happy opal_prrte_CPPFLAGS_save])
250+
251+
opal_prrte_CPPFLAGS_save=$CPPFLAGS
252+
253+
_OPAL_CHECK_PACKAGE_HEADER([opal_prrte], [prte.h], [$with_prrte],
254+
[setup_prrte_external_happy=yes],
255+
[setup_prrte_external_happy=no])
256+
257+
CPPFLAGS="$opal_prrte_CPPFLAGS_save $opal_prrte_CPPFLAGS"
258+
259+
AC_MSG_CHECKING([if external PRRTE version is 2.0.0 or greater])
260+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <prte_version.h>]],
261+
[[
262+
#if PRTE_NUMERIC_VERSION < 0x00020000
263+
#error "prrte API version is less than 2.0.0"
264+
#endif
265+
]])],
266+
[AC_MSG_RESULT([yes])
267+
setup_prrte_external_happy=yes],
268+
[AC_MSG_RESULT([no])
269+
setup_prrte_external_happy=no])
270+
271+
CPPFLAGS="$opal_prrte_CPPFLAGS_save"
272+
273+
AS_IF([test "$setup_prrte_external_happy" = "yes"],
274+
[AS_IF([test -n "$with_prrte"],
275+
[PRTE_PATH="${with_prrte}/bin/prte"
276+
AS_IF([test ! -r ${PRTE_PATH}], [AC_MSG_ERROR([Could not find prte binary at $PRTE_PATH])])],
277+
[PRTE_PATH=""
278+
OPAL_WHICH([prte], [PRTE_PATH])
279+
AS_IF([tets -z "$PRTE_PATH"],
280+
[AC_MSG_WARN([Could not find prte in PATH])
281+
setup_prrte_external_happy=no])])])
282+
283+
AS_IF([test "$setup_prrte_external_happy" = "yes"],
284+
[$1], [$2])
176285
177286
OPAL_VAR_SCOPE_POP
178287
])
288+
289+

ompi/tools/mpirun/Makefile.am

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#
22
# Copyright (c) 2019-2020 Intel, Inc. All rights reserved.
33
# Copyright (c) 2020 IBM Corporation. All rights reserved.
4+
# Copyright (c) 2021 Amazon.com, Inc. or its affiliates.
5+
# All Rights reserved.
46
# $COPYRIGHT$
57
#
68
# Additional copyrights may follow
@@ -10,9 +12,9 @@
1012

1113
if OMPI_WANT_PRRTE
1214
install-exec-hook:
13-
(cd $(DESTDIR)$(bindir); rm -f mpirun$(EXEEXT); $(LN_S) prte$(EXEEXT) mpirun$(EXEEXT))
14-
(cd $(DESTDIR)$(bindir); rm -f mpiexec$(EXEEXT); $(LN_S) prte$(EXEEXT) mpiexec$(EXEEXT))
15-
(cd $(DESTDIR)$(bindir); rm -f oshrun$(EXEEXT); $(LN_S) prte$(EXEEXT) oshrun$(EXEEXT))
15+
(cd $(DESTDIR)$(bindir); rm -f mpirun$(EXEEXT); $(LN_S) $(PRTE_PATH)$(EXEEXT) mpirun$(EXEEXT))
16+
(cd $(DESTDIR)$(bindir); rm -f mpiexec$(EXEEXT); $(LN_S) $(PRTE_PATH)$(EXEEXT) mpiexec$(EXEEXT))
17+
(cd $(DESTDIR)$(bindir); rm -f oshrun$(EXEEXT); $(LN_S) $(PRTE_PATH)$(EXEEXT) oshrun$(EXEEXT))
1618

1719
uninstall-local:
1820
rm -f $(DESTDIR)$(bindir)/mpirun$(EXEEXT) \

0 commit comments

Comments
 (0)