Skip to content

Commit ce2a8fd

Browse files
jsquyreshjelmn
authored andcommitted
opal_check_cma: make consistent with rest of configury
Split the CMA test into two parts so that the back-end test only has to be run once. Fail with --with-cma is specified and cannot be provided. Remove a few useless quotes. Change $ompi_check_cma_need_defs and $ompi_check_cma_happy to be numeric values. Finally, remove a bunch of tabs. Signed-off-by: Jeff Squyres <[email protected]> (cherry picked from commit 9974316) Signed-off-by: Nathan Hjelm <[email protected]>
1 parent 57d15bb commit ce2a8fd

File tree

1 file changed

+56
-42
lines changed

1 file changed

+56
-42
lines changed

config/opal_check_cma.m4

Lines changed: 56 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,45 @@
1818
# --------------------------------------------------------
1919
# check if cma support is wanted.
2020
AC_DEFUN([OPAL_CHECK_CMA],[
21-
if test -z "$ompi_check_cma_happy" ; then
22-
OPAL_VAR_SCOPE_PUSH([ompi_check_cma_need_defs ompi_check_cma_kernel_version ompi_check_cma_CFLAGS])
23-
24-
AC_ARG_WITH([cma],
25-
[AC_HELP_STRING([--with-cma],
26-
[Build Cross Memory Attach support (default: autodetect)])])
27-
28-
# Enable CMA support by default if process_vm_readv is defined in glibc
29-
AC_CHECK_FUNC(process_vm_readv, [ompi_check_cma_need_defs=0],
30-
[ompi_check_cma_need_defs=1])
31-
32-
if test $ompi_check_cma_need_defs = 1 ; then
33-
ompi_check_cma_CFLAGS="$CFLAGS"
34-
# Need some extra include paths to locate the appropriate headers
35-
CFLAGS="$CFLAGS -I${srcdir} -I${srcdir}/opal/include"
36-
AC_MSG_CHECKING([if internal syscall numbers for Linux CMA work])
37-
AC_RUN_IFELSE([AC_LANG_PROGRAM([[
21+
AC_ARG_WITH([cma],
22+
[AC_HELP_STRING([--with-cma],
23+
[Build Cross Memory Attach support (default: autodetect)])])
24+
25+
# We only need to do the back-end test once
26+
if test -z "$opal_check_cma_happy" ; then
27+
OPAL_CHECK_CMA_BACKEND
28+
fi
29+
30+
AS_IF([test $opal_check_cma_happy -eq 1],
31+
[$2],
32+
[if test "$with_cma" = "yes"; then
33+
AC_MSG_WARN([--with-cma support requested, but not available])
34+
AC_MSG_ERROR([Cannot continue])
35+
fi
36+
$3])
37+
])
38+
39+
AC_DEFUN([OPAL_CHECK_CMA_BACKEND],
40+
[
41+
OPAL_VAR_SCOPE_PUSH([opal_check_cma_need_defs opal_check_cma_kernel_version opal_check_cma_CFLAGS opal_check_cma_msg])
42+
43+
# Some systems have process_cm_readv() in libc, which means CMA is
44+
# supported. Other systems do not have process_cm_readv() in
45+
# libc, but have support for it in the kernel if we invoke it
46+
# directly. Check for both.
47+
AC_CHECK_HEADERS([sys/prctl.h])
48+
49+
AC_CHECK_FUNC([process_vm_readv], [opal_check_cma_need_defs=0],
50+
[opal_check_cma_need_defs=1])
51+
AC_DEFINE_UNQUOTED([OPAL_CMA_NEED_SYSCALL_DEFS],
52+
[$opal_check_cma_need_defs],
53+
[Need CMA syscalls defined])
54+
if test $opal_check_cma_need_defs -eq 1 ; then
55+
opal_check_cma_CFLAGS=$CFLAGS
56+
# Need some extra include paths to locate the appropriate headers
57+
CFLAGS="$CFLAGS -I${srcdir} -I${srcdir}/opal/include"
58+
AC_MSG_CHECKING([if internal syscall numbers for Linux CMA work])
59+
AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3860
#include <stdlib.h>
3961
#include <stdint.h>
4062
#include <string.h>
@@ -88,31 +110,23 @@ static void do_check (pid_t pid, int *in, int *out)
88110
/* all good */
89111
return 0;
90112
]])],
91-
[AC_MSG_RESULT([yes])
92-
ompi_check_cma_happy="yes"],
93-
[AC_MSG_RESULT([no])
94-
ompi_check_cma_happy="no"],
95-
[AC_MSG_RESULT([no (cross-compiling)])
96-
ompi_check_cma_happy="no"])
97-
CFLAGS="$ompi_check_cma_CFLAGS"
98-
else
99-
ompi_check_cma_happy="yes"
100-
fi
101-
102-
# If the user specifically requests CMA go ahead and enable it even
103-
# if the glibc version does not support process_vm_readv
104-
if test "x$with_cma" = "xyes" || test "$ompi_check_cma_happy" = "yes" ; then
105-
ompi_check_cma_happy="yes"
106-
AC_DEFINE_UNQUOTED([OPAL_CMA_NEED_SYSCALL_DEFS],
107-
[$ompi_check_cma_need_defs],
108-
[Need CMA syscalls defined])
109-
AC_CHECK_HEADERS([sys/prctl.h])
110-
fi
111-
112-
OPAL_VAR_SCOPE_POP
113-
114-
OPAL_SUMMARY_ADD([[Transports]],[[Shared memory/Linux CMA]],[$1],[$ompi_check_cma_happy])
113+
[AC_MSG_RESULT([yes])
114+
opal_check_cma_happy=1],
115+
[AC_MSG_RESULT([no])
116+
opal_check_cma_happy=0],
117+
[AC_MSG_RESULT([no (cross-compiling)])
118+
opal_check_cma_happy=0])
119+
CFLAGS=$opal_check_cma_CFLAGS
120+
else
121+
# If we didn't need the defs, then we have process_vm_readv(),
122+
# and CMA is happy.
123+
opal_check_cma_happy=1
115124
fi
116125

117-
AS_IF([test "$ompi_check_cma_happy" = "yes"], [$2], [$3])
126+
OPAL_VAR_SCOPE_POP
127+
128+
AS_IF([test $opal_check_cma_happy -eq 1],
129+
[opal_check_cma_msg=yes],
130+
[opal_check_cma_msg=no])
131+
OPAL_SUMMARY_ADD([[Transports]],[[Shared memory/Linux CMA]],[$1],[$opal_check_cma_msg])
118132
])

0 commit comments

Comments
 (0)