Skip to content

Commit 3b8e99a

Browse files
committed
build/ucx: Use OAC_CHECK_PACKAGE
Convert the UCX check to use OAC_CHECK_PACKAGE and remove the code that becomes dead with that change (including the pkg-config code, which is now part of OAC_CHECK_PACKAGE). Remove the duplication code and properly use Autoconf caching for avoiding running duplicate tests. Signed-off-by: Brian Barrett <bbarrett@amazon.com>
1 parent 7a7967a commit 3b8e99a

File tree

2 files changed

+98
-138
lines changed

2 files changed

+98
-138
lines changed

config/ompi_check_ucx.m4

Lines changed: 96 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -21,154 +21,114 @@
2121
# LDFLAGS, LIBS} as needed and runs action-if-found if there is
2222
# support, otherwise executes action-if-not-found
2323
AC_DEFUN([OMPI_CHECK_UCX],[
24-
OPAL_VAR_SCOPE_PUSH([ompi_check_ucx_dir])
24+
OPAL_VAR_SCOPE_PUSH([ompi_check_ucx_happy ompi_check_ucx_CPPFLAGS_save ompi_check_ucx_LDFLAGS_save ompi_check_ucx_LIBS_save])
2525

26-
AS_IF([test -z "$ompi_check_ucx_happy"],
27-
[AC_ARG_WITH([ucx],
28-
[AS_HELP_STRING([--with-ucx(=DIR)],
29-
[Build with Unified Communication X library support])])
30-
OPAL_CHECK_WITHDIR([ucx], [$with_ucx], [include/ucp/api/ucp.h])
31-
AC_ARG_WITH([ucx-libdir],
32-
[AS_HELP_STRING([--with-ucx-libdir=DIR],
33-
[Search for Unified Communication X libraries in DIR])])
34-
OPAL_CHECK_WITHDIR([ucx-libdir], [$with_ucx_libdir], [libucp.*])
26+
m4_ifblank([$1], [m4_fatal([First argument to OMPI_CHECK_UCX cannot be blank])])
3527

36-
AS_IF([test "$with_ucx" != "no"],
37-
[AS_IF([test -n "$with_ucx" && test "$with_ucx" != "yes"],
38-
[ompi_check_ucx_dir="$with_ucx"],
39-
[PKG_CHECK_MODULES_STATIC([ucx],[ucx],
40-
[ompi_check_ucx_dir=`$PKG_CONFIG --variable=prefix ucx`
41-
AS_IF([test "$ompi_check_ucx_dir" = "/usr"],
42-
[ompi_check_ucx_dir=])],
43-
[true])])
44-
ompi_check_ucx_happy="no"
45-
AS_IF([test -z "$ompi_check_ucx_dir"],
46-
[OPAL_CHECK_PACKAGE([ompi_check_ucx],
47-
[ucp/api/ucp.h],
48-
[ucp],
49-
[ucp_cleanup],
50-
[-luct -lucm -lucs],
51-
[],
52-
[],
53-
[ompi_check_ucx_happy="yes"],
54-
[ompi_check_ucx_happy="no"])
55-
AS_IF([test "$ompi_check_ucx_happy" = yes],
56-
[AC_MSG_CHECKING(for UCX version compatibility)
57-
AC_REQUIRE_CPP
58-
AC_COMPILE_IFELSE(
59-
[AC_LANG_PROGRAM([[#include <uct/api/version.h>]],[[]])],
60-
[ompi_check_ucx_happy="yes"],
61-
[ompi_check_ucx_happy="no"])
28+
AC_ARG_WITH([ucx],
29+
[AS_HELP_STRING([--with-ucx(=DIR)],
30+
[Build with Unified Communication X library support])])
31+
AC_ARG_WITH([ucx-libdir],
32+
[AS_HELP_STRING([--with-ucx-libdir=DIR],
33+
[Search for Unified Communication X libraries in DIR])])
6234

63-
AC_MSG_RESULT([$ompi_check_ucx_happy])])
64-
AS_IF([test "$ompi_check_ucx_happy" = "no"],
65-
[ompi_check_ucx_dir=/opt/ucx])])
66-
AS_IF([test "$ompi_check_ucx_happy" != yes],
67-
[AS_IF([test -n "$with_ucx_libdir"],
68-
[ompi_check_ucx_libdir="$with_ucx_libdir"],
69-
[files=`ls $ompi_check_ucx_dir/lib64/libucp.* 2> /dev/null | wc -l`
70-
AS_IF([test "$files" -gt 0],
71-
[ompi_check_ucx_libdir=$ompi_check_ucx_dir/lib64],
72-
[ompi_check_ucx_libdir=$ompi_check_ucx_dir/lib])])
35+
OAC_CHECK_PACKAGE([ucx],
36+
[$1],
37+
[ucp/api/ucp.h],
38+
[ucp -luct -lucm -lucs],
39+
[ucp_cleanup],
40+
[ompi_check_ucx_happy="yes"],
41+
[ompi_check_ucx_happy="no"])
7342

74-
ompi_check_ucx_$1_save_CPPFLAGS="$CPPFLAGS"
75-
ompi_check_ucx_$1_save_LDFLAGS="$LDFLAGS"
76-
ompi_check_ucx_$1_save_LIBS="$LIBS"
43+
ompi_check_ucx_CPPFLAGS_save=${CPPFLAGS}
44+
ompi_check_ucx_LDLAGS_save=${LDFLAGS}
45+
ompi_check_ucx_LIBS_save=${LIBS}
7746

78-
OPAL_CHECK_PACKAGE([ompi_check_ucx],
79-
[ucp/api/ucp.h],
80-
[ucp],
81-
[ucp_cleanup],
82-
[-luct -lucm -lucs],
83-
[$ompi_check_ucx_dir],
84-
[$ompi_check_ucx_libdir],
85-
[ompi_check_ucx_happy="yes"],
86-
[ompi_check_ucx_happy="no"])
47+
OPAL_FLAGS_APPEND_UNIQ([CPPFLAGS], [${$1_CPPFLAGS}])
48+
OPAL_FLAGS_APPEND_UNIQ([LDFLAGS], [${$1_LDFLAGS}])
49+
OPAL_FLAGS_APPEND_MOVE([LIBS], [${$1_LIBS}])
8750

88-
CPPFLAGS="$ompi_check_ucx_$1_save_CPPFLAGS"
89-
LDFLAGS="$ompi_check_ucx_$1_save_LDFLAGS"
90-
LIBS="$ompi_check_ucx_$1_save_LIBS"
51+
AS_IF([test "$ompi_check_ucx_happy" = yes],
52+
[AC_CACHE_CHECK([for UCX version header],
53+
[ompi_check_ucx_cv_have_version_header],
54+
[AC_REQUIRE_CPP
55+
AC_COMPILE_IFELSE(
56+
[AC_LANG_PROGRAM([[#include <uct/api/version.h>]],[[]])],
57+
[ompi_check_ucx_cv_have_version_header="yes"],
58+
[ompi_check_ucx_cv_have_version_header="no"])])
59+
AS_IF([test "${ompi_check_ucx_cv_have_version_header}" != "yes"],
60+
[ompi_check_ucx_happy=no])])
9161

92-
AS_IF([test "$ompi_check_ucx_happy" = yes],
93-
[AC_MSG_CHECKING(for UCX version compatibility)
94-
AC_REQUIRE_CPP
95-
old_CPPFLAGS="$CPPFLAGS"
96-
CPPFLAGS="$CPPFLAGS -I$ompi_check_ucx_dir/include"
97-
AC_COMPILE_IFELSE(
98-
[AC_LANG_PROGRAM([[#include <uct/api/version.h>]],[[]])],
99-
[ompi_check_ucx_happy="yes"],
100-
[ompi_check_ucx_happy="no"])
62+
AS_IF([test "$ompi_check_ucx_happy" = yes],
63+
[# Turn off UCX version v1.8 due to issue #8321
64+
AC_CACHE_CHECK([UCX version 1.8.x],
65+
[ompi_check_ucx_cv_have_version_1_8],
66+
[AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
67+
#include <ucp/api/ucp_version.h>
68+
]], [[
69+
#if (UCP_API_MAJOR == 1) && (UCP_API_MINOR == 8)
70+
#error "Invalid version"
71+
#endif
72+
]])],
73+
[ompi_check_ucx_cv_have_version_1_8=no],
74+
[ompi_check_ucx_cv_have_version_1_8=yes])])
75+
AS_IF([test "${ompi_check_ucx_cv_have_version_1_8}" = "yes"],
76+
[AC_MSG_WARN([UCX support skipped because version 1.8.x was found, which has a known catastrophic issue.])
77+
AC_MSG_WARN([Please upgrade to UCX version 1.9 or higher.])
78+
ompi_check_ucx_happy=no])])
10179

102-
AC_MSG_RESULT([$ompi_check_ucx_happy])
103-
CPPFLAGS=$old_CPPFLAGS])])
80+
AS_IF([test "$ompi_check_ucx_happy" = yes],
81+
[AC_CHECK_DECLS([ucp_tag_send_nbr],
82+
[AC_DEFINE([HAVE_UCP_TAG_SEND_NBR],[1],
83+
[have ucp_tag_send_nbr()])], [],
84+
[#include <ucp/api/ucp.h>])
85+
AC_CHECK_DECLS([ucp_ep_flush_nb, ucp_worker_flush_nb,
86+
ucp_request_check_status, ucp_put_nb, ucp_get_nb,
87+
ucp_put_nbx, ucp_get_nbx, ucp_atomic_op_nbx,
88+
ucp_ep_flush_nbx],
89+
[], [],
90+
[#include <ucp/api/ucp.h>])
91+
AC_CHECK_DECLS([ucm_test_events,
92+
ucm_test_external_events],
93+
[], [],
94+
[#include <ucm/api/ucm.h>])
95+
AC_CHECK_DECLS([UCP_ATOMIC_POST_OP_AND,
96+
UCP_ATOMIC_POST_OP_OR,
97+
UCP_ATOMIC_POST_OP_XOR,
98+
UCP_ATOMIC_FETCH_OP_FAND,
99+
UCP_ATOMIC_FETCH_OP_FOR,
100+
UCP_ATOMIC_FETCH_OP_FXOR,
101+
UCP_PARAM_FIELD_ESTIMATED_NUM_PPN,
102+
UCP_WORKER_FLAG_IGNORE_REQUEST_LEAK,
103+
UCP_OP_ATTR_FLAG_MULTI_SEND],
104+
[], [],
105+
[#include <ucp/api/ucp.h>])
106+
AC_CHECK_DECLS([UCP_WORKER_ATTR_FIELD_ADDRESS_FLAGS],
107+
[AC_DEFINE([HAVE_UCP_WORKER_ADDRESS_FLAGS], [1],
108+
[have worker address attribute])], [],
109+
[#include <ucp/api/ucp.h>])
110+
AC_CHECK_DECLS([UCP_ATTR_FIELD_MEMORY_TYPES],
111+
[AC_DEFINE([HAVE_UCP_ATTR_MEMORY_TYPES], [1],
112+
[have memory types attribute])], [],
113+
[#include <ucp/api/ucp.h>])
114+
AC_CHECK_DECLS([ucp_tag_send_nbx,
115+
ucp_tag_send_sync_nbx,
116+
ucp_tag_recv_nbx],
117+
[], [],
118+
[#include <ucp/api/ucp.h>])
119+
AC_CHECK_TYPES([ucp_request_param_t],
120+
[], [],
121+
[[#include <ucp/api/ucp.h>]])
122+
])
104123

105-
old_CPPFLAGS="$CPPFLAGS"
106-
AS_IF([test -n "$ompi_check_ucx_dir"],
107-
[CPPFLAGS="$CPPFLAGS -I$ompi_check_ucx_dir/include"])
108-
# Turn off UCX version v1.8 due to issue #8321
109-
AC_MSG_CHECKING([UCX version])
110-
AC_PREPROC_IFELSE([AC_LANG_PROGRAM([#include <ucp/api/ucp_version.h>
111-
#if (UCP_API_MAJOR == 1) && (UCP_API_MINOR == 8)
112-
#error "Invalid version"
113-
#endif], [])],
114-
[AC_MSG_RESULT([ok (not 1.8.x)])],
115-
[AC_MSG_RESULT([bad (1.8.x)])
116-
AC_MSG_WARN([UCX support skipped because version 1.8.x was found, which has a known catastrophic issue.])
117-
AC_MSG_WARN([Please upgrade to UCX version 1.9 or higher.])
118-
ompi_check_ucx_happy=no])
119-
AS_IF([test "$ompi_check_ucx_happy" = yes],
120-
[
121-
AC_CHECK_DECLS([ucp_tag_send_nbr],
122-
[AC_DEFINE([HAVE_UCP_TAG_SEND_NBR],[1],
123-
[have ucp_tag_send_nbr()])], [],
124-
[#include <ucp/api/ucp.h>])
125-
AC_CHECK_DECLS([ucp_ep_flush_nb, ucp_worker_flush_nb,
126-
ucp_request_check_status, ucp_put_nb, ucp_get_nb,
127-
ucp_put_nbx, ucp_get_nbx, ucp_atomic_op_nbx,
128-
ucp_ep_flush_nbx],
129-
[], [],
130-
[#include <ucp/api/ucp.h>])
131-
AC_CHECK_DECLS([ucm_test_events,
132-
ucm_test_external_events],
133-
[], [],
134-
[#include <ucm/api/ucm.h>])
135-
AC_CHECK_DECLS([UCP_ATOMIC_POST_OP_AND,
136-
UCP_ATOMIC_POST_OP_OR,
137-
UCP_ATOMIC_POST_OP_XOR,
138-
UCP_ATOMIC_FETCH_OP_FAND,
139-
UCP_ATOMIC_FETCH_OP_FOR,
140-
UCP_ATOMIC_FETCH_OP_FXOR,
141-
UCP_PARAM_FIELD_ESTIMATED_NUM_PPN,
142-
UCP_WORKER_FLAG_IGNORE_REQUEST_LEAK,
143-
UCP_OP_ATTR_FLAG_MULTI_SEND],
144-
[], [],
145-
[#include <ucp/api/ucp.h>])
146-
AC_CHECK_DECLS([UCP_WORKER_ATTR_FIELD_ADDRESS_FLAGS],
147-
[AC_DEFINE([HAVE_UCP_WORKER_ADDRESS_FLAGS], [1],
148-
[have worker address attribute])], [],
149-
[#include <ucp/api/ucp.h>])
150-
AC_CHECK_DECLS([UCP_ATTR_FIELD_MEMORY_TYPES],
151-
[AC_DEFINE([HAVE_UCP_ATTR_MEMORY_TYPES], [1],
152-
[have memory types attribute])], [],
153-
[#include <ucp/api/ucp.h>])
154-
AC_CHECK_DECLS([ucp_tag_send_nbx,
155-
ucp_tag_send_sync_nbx,
156-
ucp_tag_recv_nbx],
157-
[], [],
158-
[#include <ucp/api/ucp.h>])
159-
AC_CHECK_TYPES([ucp_request_param_t],
160-
[], [],
161-
[[#include <ucp/api/ucp.h>]])
162-
])
163-
CPPFLAGS=$old_CPPFLAGS
124+
CPPFLAGS=${ompi_check_ucx_CPPFLAGS_save}
125+
LDFLAGS=${ompi_check_ucx_LDLAGS_save}
126+
LIBS=${ompi_check_ucx_LIBS_save}
164127

165-
OPAL_SUMMARY_ADD([Transports], [Open UCX], [], [$ompi_check_ucx_happy])])])
128+
OPAL_SUMMARY_ADD([Transports], [Open UCX], [], [$ompi_check_ucx_happy])
166129

167130
AS_IF([test "$ompi_check_ucx_happy" = "yes"],
168-
[$1_CPPFLAGS="[$]$1_CPPFLAGS $ompi_check_ucx_CPPFLAGS"
169-
$1_LDFLAGS="[$]$1_LDFLAGS $ompi_check_ucx_LDFLAGS"
170-
$1_LIBS="[$]$1_LIBS $ompi_check_ucx_LIBS"
171-
$2],
131+
[$2],
172132
[AS_IF([test ! -z "$with_ucx" && test "$with_ucx" != "no"],
173133
[AC_MSG_ERROR([UCX support requested but not found. Aborting])])
174134
$3])

opal/mca/common/ucx/configure.m4

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
# $HEADER$
1010
#
1111

12-
# MCA_opal_common_sm_CONFIG([action-if-can-compile],
12+
# MCA_opal_common_ucx_CONFIG([action-if-can-compile],
1313
# [action-if-cant-compile])
1414
# ------------------------------------------------
1515
AC_DEFUN([MCA_opal_common_ucx_CONFIG],[
1616
AC_CONFIG_FILES([opal/mca/common/ucx/Makefile])
17-
common_ucx_happy="no"
17+
1818
OMPI_CHECK_UCX([common_ucx],
1919
[common_ucx_happy="yes"],
2020
[common_ucx_happy="no"])

0 commit comments

Comments
 (0)