|
1 | 1 | # -*- shell-script -*- |
2 | 2 | # |
3 | | -# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana |
| 3 | +# Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana |
4 | 4 | # University Research and Technology |
5 | 5 | # Corporation. All rights reserved. |
6 | 6 | # Copyright (c) 2004-2005 The University of Tennessee and The University |
|
10 | 10 | # University of Stuttgart. All rights reserved. |
11 | 11 | # Copyright (c) 2004-2005 The Regents of the University of California. |
12 | 12 | # All rights reserved. |
13 | | -# Copyright (c) 2010 Cisco Systems, Inc. All rights reserved. |
| 13 | +# Copyright (c) 2008-2013 Cisco Systems, Inc. All rights reserved. |
14 | 14 | # Copyright (c) 2015 Research Organization for Information Science |
15 | 15 | # and Technology (RIST). All rights reserved. |
16 | 16 | # Copyright (c) 2019 Sandia National Laboratories. All rights reserved. |
|
30 | 30 | # ******************************************************************** |
31 | 31 |
|
32 | 32 |
|
| 33 | +AC_DEFUN([OPAL_CHECK_PTHREAD_PIDS],[ |
| 34 | +# |
| 35 | +# Arguments: none |
| 36 | +# |
| 37 | +# Dependencies: None |
| 38 | +# |
| 39 | +# Sets: |
| 40 | +# OPAL_THREADS_HAVE_DIFFERENT_PIDS (variable) |
| 41 | +# |
| 42 | +# Test for Linux-like threads in the system. OPAL no longer supports |
| 43 | +# systems with different PIDs for threads in the same process, so error |
| 44 | +# out if we detect that case. |
| 45 | +# |
| 46 | + |
| 47 | +AC_MSG_CHECKING([if threads have different pids (pthreads on linux)]) |
| 48 | + |
| 49 | +OPAL_VAR_SCOPE_PUSH([CFLAGS_save CPPFLAGS_save LDFLAGS_save LIBS_save MSG]) |
| 50 | +CFLAGS_save="$CFLAGS" |
| 51 | +CFLAGS="$CFLAGS $THREAD_CFLAGS" |
| 52 | +CPPFLAGS_save="$CPPFLAGS" |
| 53 | +CPPFLAGS="$CPPFLAGS $THREAD_CPPFLAGS" |
| 54 | +LDFLAGS_save="$LDFLAGS" |
| 55 | +LDFLAGS="$LDFLAGS $THREAD_LDFLAGS" |
| 56 | +LIBS_save="$LIBS" |
| 57 | +LIBS="$LIBS $THREAD_LIBS" |
| 58 | +AC_RUN_IFELSE([AC_LANG_SOURCE([#include <pthread.h> |
| 59 | +#include <sys/types.h> |
| 60 | +#include <unistd.h> |
| 61 | +#include <stdlib.h> |
| 62 | + |
| 63 | +void *checkpid(void *arg); |
| 64 | +int main() { |
| 65 | + pthread_t thr; |
| 66 | + int pid, *retval; |
| 67 | + pid = getpid(); |
| 68 | + pthread_create(&thr, NULL, checkpid, &pid); |
| 69 | + pthread_join(thr, (void **) &retval); |
| 70 | + exit(*retval); |
| 71 | +} |
| 72 | + |
| 73 | +static int ret; |
| 74 | +void *checkpid(void *arg) { |
| 75 | + int ppid = *((int *) arg); |
| 76 | + if (ppid == getpid()) |
| 77 | + ret = 0; |
| 78 | + else |
| 79 | + ret = 1; |
| 80 | + pthread_exit((void *) &ret); |
| 81 | +}])], |
| 82 | +[MSG=no OPAL_THREADS_HAVE_DIFFERENT_PIDS=0], |
| 83 | +[MSG=yes OPAL_THREADS_HAVE_DIFFERENT_PIDS=1], |
| 84 | +[ |
| 85 | + # If we're cross compiling, we can't do another AC_* function here because |
| 86 | + # it we haven't displayed the result from the last one yet. So defer |
| 87 | + # another test until below. |
| 88 | + OPAL_THREADS_HAVE_DIFFERENT_PIDS= |
| 89 | + MSG="cross compiling (need another test)"]) |
| 90 | +
|
| 91 | +CFLAGS="$CFLAGS_save" |
| 92 | +CPPFLAGS="$CPPFLAGS_save" |
| 93 | +LDFLAGS="$LDFLAGS_save" |
| 94 | +LIBS="$LIBS_save" |
| 95 | +
|
| 96 | +AC_MSG_RESULT([$MSG]) |
| 97 | +
|
| 98 | +AS_IF([test "x$OPAL_THREADS_HAVE_DIFFERENT_PIDS" = "x"], |
| 99 | + [ # If we are cross-compiling, look for the symbol |
| 100 | + # __linuxthreads_create_event, which seems to only exist in the |
| 101 | + # Linux Threads-based pthreads implementation (i.e., the one |
| 102 | + # that has different PIDs for each thread). We *could* switch |
| 103 | + # on $host here and only test *linux* hosts, but this test is |
| 104 | + # pretty unique, so why bother? Note that AC_CHECK_FUNC works |
| 105 | + # properly in cross-compiling environments in recent-enough |
| 106 | + # versions of Autoconf (which is one of the reasons we mandate |
| 107 | + # recent versions in autogen!). |
| 108 | + AC_CHECK_FUNC([__linuxthreads_create_event], |
| 109 | + [OPAL_THREADS_HAVE_DIFFERENT_PIDS=1])]) |
| 110 | +
|
| 111 | +AS_IF([test "$OPAL_THREADS_HAVE_DIFFERENT_PIDS" = "1"], |
| 112 | + [AC_MSG_WARN([This version of Open MPI only supports environments where]) |
| 113 | + AC_MSG_WARN([threads have the same PID. Please use an older version of]) |
| 114 | + AC_MSG_WARN([Open MPI if you need support on systems with different]) |
| 115 | + AC_MSG_WARN([PIDs for threads in the same process. Open MPI 1.4.x]) |
| 116 | + AC_MSG_WARN([supports such systems, as does at least some versions the]) |
| 117 | + AC_MSG_WARN([Open MPI 1.5.x series.]) |
| 118 | + AC_MSG_ERROR([Cannot continue]) |
| 119 | + ]) |
| 120 | +
|
| 121 | +# |
| 122 | +# if pthreads is not available, then the system does not have an insane threads |
| 123 | +# model |
| 124 | +# |
| 125 | +OPAL_VAR_SCOPE_POP])dnl |
| 126 | +
|
33 | 127 | AC_DEFUN([OPAL_INTL_PTHREAD_TRY_LINK], [ |
34 | 128 | # BEGIN: OPAL_INTL_PTHREAD_TRY_LINK |
35 | 129 | # |
@@ -655,6 +749,16 @@ CXXCPPFLAGS="$orig_CXXCPPFLAGS" |
655 | 749 | LDFLAGS="$orig_LDFLAGS" |
656 | 750 | LIBS="$orig_LIBS" |
657 | 751 |
|
| 752 | +THREAD_CFLAGS="$TPKG_CFLAGS" |
| 753 | +THREAD_FCFLAGS="$TPKG_FCFLAGS" |
| 754 | +THREAD_CXXFLAGS="$TPKG_CXXFLAGS" |
| 755 | +THREAD_CPPFLAGS="$TPKG_CPPFLAGS" |
| 756 | +THREAD_CXXCPPFLAGS="$TPKG_CXXCPPFLAGS" |
| 757 | +THREAD_LDFLAGS="$TPKG_LDFLAGS" |
| 758 | +THREAD_LIBS="$TPKG_LIBS" |
| 759 | +
|
| 760 | +OPAL_CHECK_PTHREAD_PIDS |
| 761 | +
|
658 | 762 | if test "$OMPI_TRY_FORTRAN_BINDINGS" = "$OMPI_FORTRAN_NO_BINDINGS" || \ |
659 | 763 | test $ompi_fortran_happy -ne 1; then |
660 | 764 | opal_pthread_fortran_success=1 |
@@ -708,6 +812,12 @@ AC_DEFUN([MCA_opal_threads_pthreads_POST_CONFIG],[ |
708 | 812 | THREAD_CXXCPPFLAGS="$TPKG_CXXCPPFLAGS" |
709 | 813 | THREAD_LDFLAGS="$TPKG_LDFLAGS" |
710 | 814 | THREAD_LIBS="$TPKG_LIBS" |
| 815 | + AC_SUBST(THREAD_CFLAGS) |
| 816 | + AC_SUBST(THREAD_FCFLAGS) |
| 817 | + AC_SUBST(THREAD_CXXFLAGS) |
| 818 | + AC_SUBST(THREAD_CPPFLAGS) |
| 819 | + AC_SUBST(THREAD_LDFLAGS) |
| 820 | + AC_SUBST(THREAD_LIBS) |
711 | 821 | ]) |
712 | 822 | ])dnl |
713 | 823 |
|
|
0 commit comments