Skip to content

Commit f5e1a67

Browse files
committed
ofi: revamp OPAL_CHECK_OFI configury
Update the OPAL_CHECK_OFI configury macro: - Make it safe to call the macro multiple times: - The checks only execute the first time it is invoked - Subsequent invocations, it just emits a friendly "checking..." message so that configure output is sensible/logical - With the goal of ultimately removing opal/mca/common/ofi, rename the output variables from OPAL_CHECK_OFI to be opal_ofi_{happy|CPPFLAGS|LDFLAGS|LIBS}. - Update btl/ofi, btl/usnic, and mtl/ofi for these new conventions. - Also, don't use AC_REQUIRE to invoke OPAL_CHECK_OFI because that causes the macro to be invoked at a fairly random time, which makes configure stdout confusing / hard to grok. - Remove a little left-over kruft in OPAL_CHECK_OFI, too (which resulted in an indenting change, making the change to opal_check_ofi.m4 look larger than it really is). Thanks Alastair McKinstry for the report and initial fix. Thanks Rashika Kheria for the reminder. Signed-off-by: Jeff Squyres <jsquyres@cisco.com>
1 parent b556cab commit f5e1a67

File tree

7 files changed

+143
-125
lines changed

7 files changed

+143
-125
lines changed

config/opal_check_ofi.m4

Lines changed: 106 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
dnl -*- shell-script -*-
22
dnl
3-
dnl Copyright (c) 2015-2016 Cisco Systems, Inc. All rights reserved.
3+
dnl Copyright (c) 2015-2019 Cisco Systems, Inc. All rights reserved.
44
dnl Copyright (c) 2016-2017 Los Alamos National Security, LLC. All rights
55
dnl reserved.
66
dnl $COPYRIGHT$
@@ -10,102 +10,116 @@ dnl
1010
dnl $HEADER$
1111
dnl
1212

13-
14-
# OPAL_CHECK_OFI(prefix, [action-if-found], [action-if-not-found]
15-
# --------------------------------------------------------
16-
# Check if libfabric support can be found.
17-
#
18-
# Sets prefix_{CPPFLAGS, LDFLAGs, LIBS} as needed and runs
19-
# action-if-found if there is support; otherwise executes
20-
# action-if-not-found.
21-
#
22-
AC_DEFUN([OPAL_CHECK_OFI],[
23-
if test -z "$opal_check_libfabric_happy" ; then
24-
OPAL_VAR_SCOPE_PUSH([opal_check_libfabric_$1_save_CPPFLAGS opal_check_libfabric_$1_save_LDFLAGS opal_check_libfabric_$1_save_LIBS])
25-
26-
# Add --with options
27-
AC_ARG_WITH([libfabric],
28-
[AC_HELP_STRING([--with-libfabric=DIR],
29-
[Deprecated synonym for --with-ofi])])
30-
AC_ARG_WITH([libfabric-libdir],
31-
[AC_HELP_STRING([--with-libfabric-libdir=DIR],
32-
[Deprecated synonym for --with-ofi-libdir])])
33-
34-
AC_ARG_WITH([ofi],
35-
[AC_HELP_STRING([--with-ofi=DIR],
36-
[Specify location of OFI libfabric installation, adding DIR/include to the default search location for libfabric headers, and DIR/lib or DIR/lib64 to the default search location for libfabric libraries. Error if libfabric support cannot be found.])])
37-
38-
AC_ARG_WITH([ofi-libdir],
39-
[AC_HELP_STRING([--with-ofi-libdir=DIR],
40-
[Search for OFI libfabric libraries in DIR])])
41-
42-
if test "$with_ofi" = ""; then
43-
with_ofi=$with_libfabric
44-
fi
45-
46-
if test "$with_ofi_libdir" = ""; then
47-
with_ofi_libdir=$with_libfabric_libdir
48-
fi
49-
50-
# Sanity check the --with values
51-
OPAL_CHECK_WITHDIR([ofi], [$with_ofi],
52-
[include/rdma/fabric.h])
53-
OPAL_CHECK_WITHDIR([ofi-libdir], [$with_ofi_libdir],
54-
[libfabric.*])
55-
56-
opal_check_ofi_$1_save_CPPFLAGS=$CPPFLAGS
57-
opal_check_ofi_$1_save_LDFLAGS=$LDFLAGS
58-
opal_check_ofi_$1_save_LIBS=$LIBS
59-
60-
opal_check_ofi_happy=yes
61-
AS_IF([test "$with_ofi" = "no"],
62-
[opal_check_ofi_happy=no])
63-
64-
AS_IF([test $opal_check_ofi_happy = yes],
65-
[AC_MSG_CHECKING([looking for OFI libfabric in])
66-
AS_IF([test "$with_ofi" != "yes"],
67-
[opal_ofi_dir=$with_ofi
68-
AC_MSG_RESULT([($opal_ofi_dir)])],
69-
[AC_MSG_RESULT([(default search paths)])])
70-
AS_IF([test ! -z "$with_ofi_libdir" && \
71-
test "$with_ofi_libdir" != "yes"],
72-
[opal_ofi_libdir=$with_ofi_libdir])
73-
])
74-
75-
AS_IF([test $opal_check_ofi_happy = yes],
76-
[OPAL_CHECK_PACKAGE([opal_check_ofi],
77-
[rdma/fabric.h],
78-
[fabric],
79-
[fi_getinfo],
80-
[],
81-
[$opal_ofi_dir],
82-
[$opal_ofi_libdir],
83-
[],
84-
[opal_check_ofi_happy=no])])
85-
86-
CPPFLAGS=$opal_check_ofi_$1_save_CPPFLAGS
87-
LDFLAGS=$opal_check_ofi_$1_save_LDFLAGS
88-
LIBS=$opal_check_ofi_$1_save_LIBS
89-
90-
OPAL_SUMMARY_ADD([[Transports]],[[OpenFabrics Libfabric]],[$1],[$opal_check_ofi_happy])
91-
92-
OPAL_VAR_SCOPE_POP
13+
dnl
14+
dnl _OPAL_CHECK_OFI
15+
dnl --------------------------------------------------------
16+
dnl Do the real work of checking for OFI libfabric.
17+
dnl Upon return:
18+
dnl
19+
dnl - opal_ofi_happy: will be "yes" or "no"
20+
dnl - opal_ofi_{CPPFLAGS|LDFLAGS|LIBS} will be loaded (if relevant)
21+
dnl
22+
AC_DEFUN([_OPAL_CHECK_OFI],[
23+
# Add --with options
24+
AC_ARG_WITH([libfabric],
25+
[AC_HELP_STRING([--with-libfabric=DIR],
26+
[Deprecated synonym for --with-ofi])])
27+
AC_ARG_WITH([libfabric-libdir],
28+
[AC_HELP_STRING([--with-libfabric-libdir=DIR],
29+
[Deprecated synonym for --with-ofi-libdir])])
30+
31+
AC_ARG_WITH([ofi],
32+
[AC_HELP_STRING([--with-ofi=DIR],
33+
[Specify location of OFI libfabric installation, adding DIR/include to the default search location for libfabric headers, and DIR/lib or DIR/lib64 to the default search location for libfabric libraries. Error if libfabric support cannot be found.])])
34+
35+
AC_ARG_WITH([ofi-libdir],
36+
[AC_HELP_STRING([--with-ofi-libdir=DIR],
37+
[Search for OFI libfabric libraries in DIR])])
38+
39+
if test "$with_ofi" = ""; then
40+
with_ofi=$with_libfabric
9341
fi
9442

95-
if test $opal_check_ofi_happy = yes ; then
96-
$1_CPPFLAGS="[$]$1_CPPFLAGS $opal_check_ofi_CPPFLAGS"
97-
$1_LIBS="[$]$1_LIBS $opal_check_ofi_LIBS"
98-
$1_LDFLAGS="[$]$1_LDFLAGS $opal_check_ofi_LDFLAGS"
99-
100-
AC_SUBST($1_CPPFLAGS)
101-
AC_SUBST($1_LDFLAGS)
102-
AC_SUBST($1_LIBS)
43+
if test "$with_ofi_libdir" = ""; then
44+
with_ofi_libdir=$with_libfabric_libdir
10345
fi
10446

105-
AS_IF([test $opal_check_ofi_happy = yes],
106-
[$2],
47+
# Sanity check the --with values
48+
OPAL_CHECK_WITHDIR([ofi], [$with_ofi],
49+
[include/rdma/fabric.h])
50+
OPAL_CHECK_WITHDIR([ofi-libdir], [$with_ofi_libdir],
51+
[libfabric.*])
52+
53+
OPAL_VAR_SCOPE_PUSH([opal_check_ofi_save_CPPFLAGS opal_check_ofi_save_LDFLAGS opal_check_ofi_save_LIBS])
54+
opal_check_ofi_save_CPPFLAGS=$CPPFLAGS
55+
opal_check_ofi_save_LDFLAGS=$LDFLAGS
56+
opal_check_ofi_save_LIBS=$LIBS
57+
58+
opal_ofi_happy=yes
59+
AS_IF([test "$with_ofi" = "no"],
60+
[opal_ofi_happy=no])
61+
62+
AS_IF([test $opal_ofi_happy = yes],
63+
[AC_MSG_CHECKING([looking for OFI libfabric in])
64+
AS_IF([test "$with_ofi" != "yes"],
65+
[opal_ofi_dir=$with_ofi
66+
AC_MSG_RESULT([($opal_ofi_dir)])],
67+
[AC_MSG_RESULT([(default search paths)])])
68+
AS_IF([test ! -z "$with_ofi_libdir" && \
69+
test "$with_ofi_libdir" != "yes"],
70+
[opal_ofi_libdir=$with_ofi_libdir])
71+
])
72+
73+
AS_IF([test $opal_ofi_happy = yes],
74+
[OPAL_CHECK_PACKAGE([opal_ofi],
75+
[rdma/fabric.h],
76+
[fabric],
77+
[fi_getinfo],
78+
[],
79+
[$opal_ofi_dir],
80+
[$opal_ofi_libdir],
81+
[],
82+
[opal_ofi_happy=no])])
83+
84+
CPPFLAGS=$opal_check_ofi_save_CPPFLAGS
85+
LDFLAGS=$opal_check_ofi_save_LDFLAGS
86+
LIBS=$opal_check_ofi_save_LIBS
87+
88+
AC_SUBST([opal_ofi_CPPFLAGS])
89+
AC_SUBST([opal_ofi_LDFLAGS])
90+
AC_SUBST([opal_ofi_LIBS])
91+
92+
OPAL_SUMMARY_ADD([[Transports]],[[OpenFabrics OFI Libfabric]],[],[$opal_ofi_happy])
93+
94+
OPAL_VAR_SCOPE_POP
95+
96+
AS_IF([test $opal_ofi_happy = no],
10797
[AS_IF([test -n "$with_ofi" && test "$with_ofi" != "no"],
10898
[AC_MSG_WARN([OFI libfabric support requested (via --with-ofi or --with-libfabric), but not found.])
10999
AC_MSG_ERROR([Cannot continue.])])
110-
$3])
100+
])
111101
])dnl
102+
103+
104+
dnl
105+
dnl OPAL_CHECK_OFI
106+
dnl --------------------------------------------------------
107+
dnl Check to see if OFI libfabric is available.
108+
dnl
109+
dnl This is a simple wrapper around _OPAL_CHECK_OFI that just
110+
dnl ensures to only run the checks once. We do not use AC_REQUIRE
111+
dnl because that re-orders the texts and makes ordering in stdout
112+
dnl quite confusing / difficult to grok.
113+
dnl
114+
AC_DEFUN([OPAL_CHECK_OFI],[
115+
# Check for OFI libfabric. Note that $opal_ofi_happy is used in
116+
# other configure.m4's to know if OFI/libfabric configured
117+
# successfully. We only need to run the back-end checks once, but
118+
# at least emit a "checking..." statement each subsequent time
119+
# this macro is invoked so that configure's stdout has
120+
# sensible/logical output.
121+
AS_IF([test -z "$opal_ofi_happy"],
122+
[_OPAL_CHECK_OFI],
123+
[AC_MSG_CHECKING([if OFI libfabric is available])
124+
AC_MSG_RESULT([$opal_ofi_happy])])
125+
])

ompi/mca/mtl/ofi/Makefile.am

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#
22
# Copyright (c) 2013-2015 Intel, Inc. All rights reserved
33
#
4-
# Copyright (c) 2014-2015 Cisco Systems, Inc. All rights reserved.
4+
# Copyright (c) 2014-2019 Cisco Systems, Inc. All rights reserved
55
# Copyright (c) 2017 Los Alamos National Security, LLC. All rights
66
# reserved.
77
# Copyright (c) 2017 IBM Corporation. All rights reserved.
8+
# Copyright (c) 2019 Research Organization for Information Science
9+
# and Technology (RIST). All rights reserved.
810
# $COPYRIGHT$
911
#
1012
# Additional copyrights may follow
@@ -18,7 +20,7 @@ EXTRA_DIST = post_configure.sh \
1820
MAINTAINERCLEANFILES = \
1921
$(generated_sources)
2022

21-
AM_CPPFLAGS = $(ompi_mtl_ofi_CPPFLAGS) $(opal_common_ofi_CPPFLAGS)
23+
AM_CPPFLAGS = $(opal_ofi_CPPFLAGS)
2224

2325
dist_ompidata_DATA = help-mtl-ofi.txt
2426

@@ -73,15 +75,14 @@ mcacomponentdir = $(ompilibdir)
7375
mcacomponent_LTLIBRARIES = $(component_install)
7476
mca_mtl_ofi_la_SOURCES = $(mtl_ofi_sources)
7577
mca_mtl_ofi_la_LDFLAGS = \
76-
$(ompi_mtl_ofi_LDFLAGS) \
78+
$(opal_ofi_LDFLAGS) \
7779
-module -avoid-version
7880
mca_mtl_ofi_la_LIBADD = $(top_builddir)/ompi/lib@OMPI_LIBMPI_NAME@.la \
79-
$(ompi_mtl_ofi_LIBS) \
80-
$(OPAL_TOP_BUILDDIR)/opal/mca/common/ofi/lib@OPAL_LIB_PREFIX@mca_common_ofi.la
81+
$(opal_ofi_LIBS)
8182

8283
noinst_LTLIBRARIES = $(component_noinst)
8384
libmca_mtl_ofi_la_SOURCES = $(mtl_ofi_sources)
8485
libmca_mtl_ofi_la_LDFLAGS = \
85-
$(ompi_mtl_ofi_LDFLAGS) \
86+
$(opal_ofi_LDFLAGS) \
8687
-module -avoid-version
87-
libmca_mtl_ofi_la_LIBADD = $(ompi_mtl_ofi_LIBS)
88+
libmca_mtl_ofi_la_LIBADD = $(opal_ofi_LIBS)

ompi/mca/mtl/ofi/configure.m4

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# Copyright (c) 2013-2014 Intel, Inc. All rights reserved
44
#
5-
# Copyright (c) 2014-2015 Cisco Systems, Inc. All rights reserved.
5+
# Copyright (c) 2014-2019 Cisco Systems, Inc. All rights reserved
66
# Copyright (c) 2017 Los Alamos National Security, LLC. All rights
77
# reserved.
88
# $COPYRIGHT$
@@ -25,10 +25,10 @@ AC_DEFUN([MCA_ompi_mtl_ofi_POST_CONFIG], [
2525
AC_DEFUN([MCA_ompi_mtl_ofi_CONFIG],[
2626
AC_CONFIG_FILES([ompi/mca/mtl/ofi/Makefile])
2727

28-
# ensure we already ran the common OFI/libfabric config
29-
AC_REQUIRE([MCA_opal_common_ofi_CONFIG])
28+
# Check for OFI
29+
OPAL_CHECK_OFI
3030

31-
AS_IF([test "$opal_common_ofi_happy" = "yes"],
31+
AS_IF([test "$opal_ofi_happy" = "yes"],
3232
[$1],
3333
[$2])
3434
])dnl

opal/mca/btl/ofi/Makefile.am

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
#dist_opaldata_DATA = help-mpi-btl-ofi.txt
2424

25-
AM_CPPFLAGS = $(opal_common_ofi_CPPFLAGS)
25+
AM_CPPFLAGS = $(opal_ofi_CPPFLAGS)
2626
sources = \
2727
btl_ofi.h \
2828
btl_ofi_component.c \
@@ -56,10 +56,11 @@ mcacomponentdir = $(opallibdir)
5656
mcacomponent_LTLIBRARIES = $(component)
5757
mca_btl_ofi_la_SOURCES = $(component_sources)
5858
mca_btl_ofi_la_LDFLAGS = -module -avoid-version \
59-
$(opal_common_ofi_LDFLAGS)
59+
$(opal_ofi_LDFLAGS)
6060
mca_btl_ofi_la_LIBADD = $(top_builddir)/opal/lib@OPAL_LIB_PREFIX@open-pal.la \
61-
$(OPAL_TOP_BUILDDIR)/opal/mca/common/ofi/lib@OPAL_LIB_PREFIX@mca_common_ofi.la
61+
$(opal_ofi_LIBS)
6262

6363
noinst_LTLIBRARIES = $(lib)
6464
libmca_btl_ofi_la_SOURCES = $(lib_sources)
65-
libmca_btl_ofi_la_LDFLAGS = -module -avoid-version $(opal_common_ofi_LDFLAGS)
65+
libmca_btl_ofi_la_LDFLAGS = -module -avoid-version $(opal_ofi_LDFLAGS)
66+
libmca_btl_ofi_la_LIBS = $(opal_ofi_LIBS)

opal/mca/btl/ofi/configure.m4

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# Copyright (c) 2004-2006 The Regents of the University of California.
1212
# All rights reserved.
1313
# Copyright (c) 2006 QLogic Corp. All rights reserved.
14-
# Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
14+
# Copyright (c) 2009-2019 Cisco Systems, Inc. All rights reserved
1515
# Copyright (c) 2011-2018 Los Alamos National Security, LLC.
1616
# All rights reserved.
1717
# Copyright (c) 2018 Intel, inc. All rights reserved
@@ -34,12 +34,13 @@ AC_DEFUN([MCA_opal_btl_ofi_CONFIG],[
3434

3535
AC_CONFIG_FILES([opal/mca/btl/ofi/Makefile])
3636

37-
AC_REQUIRE([MCA_opal_common_ofi_CONFIG])
37+
# Check for OFI
38+
OPAL_CHECK_OFI
3839

3940
opal_btl_ofi_happy=0
40-
AS_IF([test "$opal_common_ofi_happy" = "yes"],
41+
AS_IF([test "$opal_ofi_happy" = "yes"],
4142
[CPPFLAGS_save=$CPPFLAGS
42-
CPPFLAGS="$opal_common_ofi_CPPFLAGS $CPPFLAGS"
43+
CPPFLAGS="$opal_ofi_CPPFLAGS $CPPFLAGS"
4344
AC_CHECK_DECL([FI_MR_VIRT_ADDR], [opal_btl_ofi_happy=1], [],
4445
[#include <rdma/fabric.h>])
4546
CPPFLAGS=$CPPFLAGS_save])

opal/mca/btl/usnic/Makefile.am

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# All rights reserved.
1212
# Copyright (c) 2006 Sandia National Laboratories. All rights
1313
# reserved.
14-
# Copyright (c) 2010-2015 Cisco Systems, Inc. All rights reserved.
14+
# Copyright (c) 2010-2019 Cisco Systems, Inc. All rights reserved
1515
# Copyright (c) 2015 Intel, Inc. All rights reserved.
1616
# Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
1717
# Copyright (c) 2017 Los Alamos National Security, LLC. All rights
@@ -23,7 +23,7 @@
2323
# $HEADER$
2424
#
2525

26-
AM_CPPFLAGS = -DBTL_IN_OPAL=1 $(opal_common_ofi_CPPFLAGS) -DOMPI_LIBMPI_NAME=\"$(OMPI_LIBMPI_NAME)\"
26+
AM_CPPFLAGS = -DBTL_IN_OPAL=1 $(opal_ofi_CPPFLAGS) -DOMPI_LIBMPI_NAME=\"$(OMPI_LIBMPI_NAME)\"
2727

2828
EXTRA_DIST = README.txt README.test
2929

@@ -88,13 +88,18 @@ mcacomponent_LTLIBRARIES = $(component)
8888
mca_btl_usnic_la_SOURCES = $(component_sources)
8989
mca_btl_usnic_la_LDFLAGS = \
9090
$(opal_btl_usnic_LDFLAGS) \
91+
$(opal_ofi_LDFLAGS) \
9192
-module -avoid-version
9293
mca_btl_usnic_la_LIBADD = $(top_builddir)/opal/lib@OPAL_LIB_PREFIX@open-pal.la \
93-
$(OPAL_TOP_BUILDDIR)/opal/mca/common/ofi/lib@OPAL_LIB_PREFIX@mca_common_ofi.la
94+
$(opal_ofi_LIBS)
9495

9596
noinst_LTLIBRARIES = $(lib)
9697
libmca_btl_usnic_la_SOURCES = $(lib_sources)
97-
libmca_btl_usnic_la_LDFLAGS = -module -avoid-version $(opal_btl_usnic_LDFLAGS)
98+
libmca_btl_usnic_la_LDFLAGS = \
99+
$(opal_btl_usnic_LDFLAGS) \
100+
$(opal_ofi_LDFLAGS) \
101+
-module -avoid-version
102+
libmca_btl_usnic_la_LIBADD = $(opal_ofi_LIBS)
98103

99104
if OPAL_BTL_USNIC_BUILD_UNIT_TESTS
100105
usnic_btl_run_tests_CPPFLAGS = \

0 commit comments

Comments
 (0)