|
18 | 18 | # -------------------------------------------------------- |
19 | 19 | # check if cma support is wanted. |
20 | 20 | 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([[ |
38 | 60 | #include <stdlib.h> |
39 | 61 | #include <stdint.h> |
40 | 62 | #include <string.h> |
@@ -88,31 +110,23 @@ static void do_check (pid_t pid, int *in, int *out) |
88 | 110 | /* all good */ |
89 | 111 | return 0; |
90 | 112 | ]])], |
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 |
115 | 124 | fi |
116 | 125 |
|
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]) |
118 | 132 | ]) |
0 commit comments