Skip to content

Commit af03f55

Browse files
committed
configury: revamp ucx detection
- when --with-ucx=DIR is not set, try the default path and fallback to /opt/ucx - when --with-ucx-libdir is not set, try lib64 and then lib directories - do not handle --with-ucx-libdir (this is a user mistake, no need to over-complicate our logic) Signed-off-by: Gilles Gouaillardet <[email protected]>
1 parent ac348da commit af03f55

File tree

1 file changed

+78
-67
lines changed

1 file changed

+78
-67
lines changed

config/ompi_check_ucx.m4

Lines changed: 78 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -20,86 +20,97 @@
2020
# LDFLAGS, LIBS} as needed and runs action-if-found if there is
2121
# support, otherwise executes action-if-not-found
2222
AC_DEFUN([OMPI_CHECK_UCX],[
23-
if test -z "$ompi_check_ucx_happy" ; then
24-
AC_ARG_WITH([ucx],
25-
[AC_HELP_STRING([--with-ucx(=DIR)],
26-
[Build with Unified Communication X library support])])
27-
OPAL_CHECK_WITHDIR([ucx], [$with_ucx], [include/ucp/api/ucp.h])
28-
AC_ARG_WITH([ucx-libdir],
29-
[AC_HELP_STRING([--with-ucx-libdir=DIR],
30-
[Search for Unified Communication X libraries in DIR])])
31-
OPAL_CHECK_WITHDIR([ucx-libdir], [$with_ucx_libdir], [libucp.*])
23+
OPAL_VAR_SCOPE_PUSH([ompi_check_ucx_dir])
3224

33-
AS_IF([test "$with_ucx" != "no"],
34-
[AS_IF([test ! -z "$with_ucx" && test "$with_ucx" != "yes"],
35-
[_x_ac_ucx_dirs="$with_ucx"],
36-
[
37-
PKG_CHECK_MODULES_STATIC([ucx],[ucx],
38-
[_x_ac_ucx_dirs=`$PKG_CONFIG --variable=prefix ucx`],
39-
[_x_ac_ucx_dirs="/usr /usr/local /opt/ucx"])
40-
])
41-
for ompi_check_ucx_dir in $_x_ac_ucx_dirs; do
42-
AS_IF([test ! -z "$with_ucx_libdir" && test "$with_ucx_libdir" != "yes"],
43-
[
44-
ompi_check_ucx_libdir="$with_ucx_libdir"
45-
ompi_check_ucx_extra_libs="-L$ompi_check_ucx_libdir"
46-
],
47-
[AS_IF([test ! -z "$ompi_check_ucx_dir"],
48-
[
49-
ompi_check_ucx_libdir=$ompi_check_ucx_dir/lib
50-
ompi_check_ucx_extra_libs="-L$ompi_check_ucx_libdir"
51-
])])
25+
AS_IF([test -z "$ompi_check_ucx_happy"],
26+
[AC_ARG_WITH([ucx],
27+
[AC_HELP_STRING([--with-ucx(=DIR)],
28+
[Build with Unified Communication X library support])])
29+
OPAL_CHECK_WITHDIR([ucx], [$with_ucx], [include/ucp/api/ucp.h])
30+
AC_ARG_WITH([ucx-libdir],
31+
[AC_HELP_STRING([--with-ucx-libdir=DIR],
32+
[Search for Unified Communication X libraries in DIR])])
33+
OPAL_CHECK_WITHDIR([ucx-libdir], [$with_ucx_libdir], [libucp.*])
5234

53-
ompi_check_ucx_$1_save_CPPFLAGS="$CPPFLAGS"
54-
ompi_check_ucx_$1_save_LDFLAGS="$LDFLAGS"
55-
ompi_check_ucx_$1_save_LIBS="$LIBS"
35+
AS_IF([test "$with_ucx" != "no"],
36+
[AS_IF([test -n "$with_ucx" && test "$with_ucx" != "yes"],
37+
[ompi_check_ucx_dir="$with_ucx"],
38+
[PKG_CHECK_MODULES_STATIC([ucx],[ucx],
39+
[ompi_check_ucx_dir=`$PKG_CONFIG --variable=prefix ucx`
40+
AS_IF([test "$ompi_check_ucx_dir" = "/usr"],
41+
[ompi_check_ucx_dir=])],
42+
[true])])
43+
ompi_check_ucx_happy="no"
44+
AS_IF([test -z "$ompi_check_ucx_dir"],
45+
[OPAL_CHECK_PACKAGE([ompi_check_ucx],
46+
[ucp/api/ucp.h],
47+
[ucp],
48+
[ucp_cleanup],
49+
[],
50+
[],
51+
[],
52+
[ompi_check_ucx_happy="yes"],
53+
[ompi_check_ucx_happy="no"])
54+
AS_IF([test "$ompi_check_ucx_happy" = yes],
55+
[AC_MSG_CHECKING(for UCX version compatibility)
56+
AC_REQUIRE_CPP
57+
AC_COMPILE_IFELSE(
58+
[AC_LANG_PROGRAM([[#include <uct/api/version.h>]],[[]])],
59+
[ompi_check_ucx_happy="yes"],
60+
[ompi_check_ucx_happy="no"])
5661

57-
OPAL_CHECK_PACKAGE([ompi_check_ucx],
58-
[ucp/api/ucp.h],
59-
[ucp],
60-
[ucp_cleanup],
61-
[$ompi_check_ucx_extra_libs],
62-
[$ompi_check_ucx_dir],
63-
[$ompi_check_ucx_libdir],
64-
[ompi_check_ucx_happy="yes"],
65-
[ompi_check_ucx_happy="no"])
66-
CPPFLAGS="$ompi_check_ucx_$1_save_CPPFLAGS"
67-
LDFLAGS="$ompi_check_ucx_$1_save_LDFLAGS"
68-
LIBS="$ompi_check_ucx_$1_save_LIBS"
62+
AC_MSG_RESULT([$ompi_check_ucx_happy])])
63+
AS_IF([test "$ompi_check_ucx_happy" = "no"],
64+
[ompi_check_ucx_dir=/opt/ucx])])
65+
AS_IF([test "$ompi_check_ucx_happy" != yes],
66+
[AS_IF([test -n "$with_ucx_libdir"],
67+
[ompi_check_ucx_libdir="$with_ucx_libdir"],
68+
[files=`ls $ompi_check_ucx_dir/lib64/libucp.* 2> /dev/null | wc -l`
69+
AS_IF([test "$files" -gt 0],
70+
[ompi_check_ucx_libdir=$ompi_check_ucx_dir/lib64],
71+
[ompi_check_ucx_libdir=$ompi_check_ucx_dir/lib])])
6972

70-
if test "$ompi_check_ucx_happy" = no; then
71-
continue
72-
fi
73+
ompi_check_ucx_$1_save_CPPFLAGS="$CPPFLAGS"
74+
ompi_check_ucx_$1_save_LDFLAGS="$LDFLAGS"
75+
ompi_check_ucx_$1_save_LIBS="$LIBS"
7376

74-
AC_MSG_CHECKING(for UCX version compatibility)
75-
AC_REQUIRE_CPP
76-
old_CPPFLAGS="$CPPFLAGS"
77-
CPPFLAGS="$CPPFLAGS -I$ompi_check_ucx_dir/include"
78-
AC_COMPILE_IFELSE(
79-
[AC_LANG_PROGRAM([[#include <uct/api/version.h>]],[[]])],
80-
[ompi_ucx_version_ok="yes"],
81-
[ompi_ucx_version_ok="no"])
77+
OPAL_CHECK_PACKAGE([ompi_check_ucx],
78+
[ucp/api/ucp.h],
79+
[ucp],
80+
[ucp_cleanup],
81+
[],
82+
[$ompi_check_ucx_dir],
83+
[$ompi_check_ucx_libdir],
84+
[ompi_check_ucx_happy="yes"],
85+
[ompi_check_ucx_happy="no"])
86+
CPPFLAGS="$ompi_check_ucx_$1_save_CPPFLAGS"
87+
LDFLAGS="$ompi_check_ucx_$1_save_LDFLAGS"
88+
LIBS="$ompi_check_ucx_$1_save_LIBS"
8289

83-
AC_MSG_RESULT([$ompi_ucx_version_ok])
84-
CPPFLAGS=$old_CPPFLAGS
90+
AS_IF([test "$ompi_check_ucx_happy" = yes],
91+
[AC_MSG_CHECKING(for UCX version compatibility)
92+
AC_REQUIRE_CPP
93+
old_CPPFLAGS="$CPPFLAGS"
94+
CPPFLAGS="$CPPFLAGS -I$ompi_check_ucx_dir/include"
95+
AC_COMPILE_IFELSE(
96+
[AC_LANG_PROGRAM([[#include <uct/api/version.h>]],[[]])],
97+
[ompi_check_ucx_happy="yes"],
98+
[ompi_check_ucx_happy="no"])
8599

86-
AS_IF([test "$ompi_ucx_version_ok" = "no"], [ompi_check_ucx_happy="no"])
100+
AC_MSG_RESULT([$ompi_check_ucx_happy])
101+
CPPFLAGS=$old_CPPFLAGS])])
87102

88-
if test "$ompi_check_ucx_happy" = yes; then
89-
break
90-
fi
91-
done],
92-
[ompi_check_ucx_happy="no"])
93-
OPAL_SUMMARY_ADD([[Transports]],[[Open UCX]],[$1],[$ompi_check_ucx_happy])
94-
fi
103+
OPAL_SUMMARY_ADD([[Transports]],[[Open UCX]],[$1],[$ompi_check_ucx_happy])])])
95104

96105
AS_IF([test "$ompi_check_ucx_happy" = "yes"],
97106
[$1_CPPFLAGS="[$]$1_CPPFLAGS $ompi_check_ucx_CPPFLAGS"
98-
$1_LDFLAGS="[$]$1_LDFLAGS $ompi_check_ucx_LDFLAGS"
99-
$1_LIBS="[$]$1_LIBS $ompi_check_ucx_LIBS"
100-
$2],
107+
$1_LDFLAGS="[$]$1_LDFLAGS $ompi_check_ucx_LDFLAGS"
108+
$1_LIBS="[$]$1_LIBS $ompi_check_ucx_LIBS"
109+
$2],
101110
[AS_IF([test ! -z "$with_ucx" && test "$with_ucx" != "no"],
102111
[AC_MSG_ERROR([UCX support requested but not found. Aborting])])
103112
$3])
113+
114+
OPAL_VAR_SCOPE_POP
104115
])
105116

0 commit comments

Comments
 (0)