Skip to content

Commit 7972385

Browse files
committed
more fixes based on PR feedback
Signed-off-by: Howard Pritchard <hppritcha@gmail.com>
1 parent 1a9a659 commit 7972385

File tree

3 files changed

+118
-116
lines changed

3 files changed

+118
-116
lines changed

config/opal_check_pthread_pids.m4

Lines changed: 0 additions & 112 deletions
This file was deleted.

opal/mca/threads/pthreads/configure.m4

Lines changed: 112 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- shell-script -*-
22
#
3-
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
3+
# Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
44
# University Research and Technology
55
# Corporation. All rights reserved.
66
# Copyright (c) 2004-2005 The University of Tennessee and The University
@@ -10,7 +10,7 @@
1010
# University of Stuttgart. All rights reserved.
1111
# Copyright (c) 2004-2005 The Regents of the University of California.
1212
# All rights reserved.
13-
# Copyright (c) 2010 Cisco Systems, Inc. All rights reserved.
13+
# Copyright (c) 2008-2013 Cisco Systems, Inc. All rights reserved.
1414
# Copyright (c) 2015 Research Organization for Information Science
1515
# and Technology (RIST). All rights reserved.
1616
# Copyright (c) 2019 Sandia National Laboratories. All rights reserved.
@@ -30,6 +30,100 @@
3030
# ********************************************************************
3131

3232

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+
33127
AC_DEFUN([OPAL_INTL_PTHREAD_TRY_LINK], [
34128
# BEGIN: OPAL_INTL_PTHREAD_TRY_LINK
35129
#
@@ -655,6 +749,16 @@ CXXCPPFLAGS="$orig_CXXCPPFLAGS"
655749
LDFLAGS="$orig_LDFLAGS"
656750
LIBS="$orig_LIBS"
657751
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+
658762
if test "$OMPI_TRY_FORTRAN_BINDINGS" = "$OMPI_FORTRAN_NO_BINDINGS" || \
659763
test $ompi_fortran_happy -ne 1; then
660764
opal_pthread_fortran_success=1
@@ -708,6 +812,12 @@ AC_DEFUN([MCA_opal_threads_pthreads_POST_CONFIG],[
708812
THREAD_CXXCPPFLAGS="$TPKG_CXXCPPFLAGS"
709813
THREAD_LDFLAGS="$TPKG_LDFLAGS"
710814
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)
711821
])
712822
])dnl
713823

test/asm/Makefile.am

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ TESTS = \
3434
$(check_PROGRAMS)
3535

3636
EXTRA_DIST = run_tests
37+
AM_CFLAGS = $(THREAD_CFLAGS)
3738

3839
######################################################################
3940

@@ -47,18 +48,20 @@ atomic_barrier_noinline_CFLAGS = $(AM_CFLAGS) -DOMPI_DISABLE_INLINE_ASM
4748
######################################################################
4849

4950
atomic_spinlock_SOURCES = atomic_spinlock.c
51+
atomic_spinlock_CFLAGS = $(AM_CFLAGS)
5052
atomic_spinlock_LDADD = $(libs)
5153

5254
atomic_spinlock_noinline.c:
5355
ln -s $(top_srcdir)/test/asm/atomic_spinlock.c atomic_spinlock_noinline.c
5456
atomic_spinlock_noinline_SOURCES = atomic_spinlock_noinline.c
5557
atomic_spinlock_noinline_CFLAGS = $(AM_CFLAGS) -DOMPI_DISABLE_INLINE_ASM
56-
atomic_spinlock_noinline_LDADD = $(libs)
58+
atomic_spinlock_noinline_LDADD = $(THREAD_LDFLAGS) $(THREAD_LIBS) $(libs)
5759

5860
######################################################################
5961

6062
atomic_math_SOURCES = atomic_math.c
61-
atomic_math_LDADD = $(libs)
63+
atomic_math_CFLAGS = $(AM_CFLAGS)
64+
atomic_math_LDADD = $(THREAD_LDFLAGS) $(THREAD_LIBS) $(libs)
6265

6366
atomic_math_noinline.c:
6467
ln -s $(top_srcdir)/test/asm/atomic_math.c atomic_math_noinline.c
@@ -69,6 +72,7 @@ atomic_math_noinline_LDADD = $(libs)
6972
######################################################################
7073

7174
atomic_cmpset_SOURCES = atomic_cmpset.c
75+
atomic_cmpset_CFLAGS = $(AM_CFLAGS)
7276
atomic_cmpset_LDADD = $(libs)
7377

7478
atomic_cmpset_noinline.c:

0 commit comments

Comments
 (0)