Skip to content

Commit db3421c

Browse files
npe9hppritcha
authored andcommitted
Add threads framework
Add a framework to support different types of threading models including user space thread packages such as Qthreads and argobot: https://github.com/pmodels/argobots https://github.com/Qthreads/qthreads The default threading model is pthreads. Alternate thread models are specificed at configure time using the --with-threads=X option. The framework is static. The theading model to use is selected at Open MPI configure/build time. Signed-off-by: Noah Evans <noah.evans@gmail.com>
1 parent bfff578 commit db3421c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2321
-1083
lines changed

config/opal_config_argobots.m4

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
dnl
2+
dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
3+
dnl University Research and Technology
4+
dnl Corporation. All rights reserved.
5+
dnl Copyright (c) 2004-2005 The University of Tennessee and The University
6+
dnl of Tennessee Research Foundation. All rights
7+
dnl reserved.
8+
dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9+
dnl University of Stuttgart. All rights reserved.
10+
dnl Copyright (c) 2004-2005 The Regents of the University of California.
11+
dnl All rights reserved.
12+
dnl Copyright (c) 2012 Cisco Systems, Inc. All rights reserved.
13+
dnl Copyright (c) 2014 Intel, Inc. All rights reserved.
14+
dnl Copyright (c) 2014-2016 Research Organization for Information Science
15+
dnl and Technology (RIST). All rights reserved.
16+
dnl $COPYRIGHT$
17+
dnl
18+
dnl Additional copyrights may follow
19+
dnl
20+
dnl $HEADER$
21+
dnl
22+
dnl OPAL_CONFIG_ARGOBOT_THREADS()
23+
dnl
24+
dnl Configure argobot threads, setting the following variables (but
25+
dnl not calling AC_SUBST on them).
26+
27+
#********************************************************************
28+
#
29+
# TODO: work in progress
30+
#
31+
#********************************************************************
32+
AC_DEFUN([OPAL_CONFIG_ARGOBOT_THREADS],[
33+
AC_REQUIRE([AC_PROG_GREP])
34+
[$2]
35+
])dnl

config/opal_config_pthreads.m4

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -281,11 +281,11 @@ if test "$opal_pthread_c_success" = "0"; then
281281
opal_pthread_c_success=0)
282282
AC_LANG_POP(C)
283283
if test "$opal_pthread_c_success" = "1"; then
284-
PTHREAD_CFLAGS="$pf"
284+
TPKG_CFLAGS="$pf"
285285
AC_MSG_RESULT([yes])
286286
break
287287
else
288-
PTHREAD_CFLAGS=
288+
TPKG_CFLAGS=
289289
CFLAGS="$orig_CFLAGS"
290290
AC_MSG_RESULT([no])
291291
fi
@@ -307,11 +307,11 @@ if test "$opal_pthread_cxx_success" = "0"; then
307307
opal_pthread_cxx_success=0)
308308
AC_LANG_POP(C++)
309309
if test "$opal_pthread_cxx_success" = "1"; then
310-
PTHREAD_CXXFLAGS="$pf"
310+
TPKG_CXXFLAGS="$pf"
311311
AC_MSG_RESULT([yes])
312312
break
313313
else
314-
PTHREAD_CXXFLAGS=
314+
TPKG_CXXFLAGS=
315315
CXXFLAGS="$orig_CXXFLAGS"
316316
AC_MSG_RESULT([no])
317317
fi
@@ -335,11 +335,11 @@ if test "$opal_pthread_fortran_success" = "0" && \
335335
opal_pthread_fortran_success=0)
336336
AC_LANG_POP(C)
337337
if test "$opal_pthread_fortran_success" = "1"; then
338-
PTHREAD_FCFLAGS="$pf"
338+
TPKG_FCFLAGS="$pf"
339339
AC_MSG_RESULT([yes])
340340
break
341341
else
342-
PTHREAD_FCFLAGS=
342+
TPKG_FCFLAGS=
343343
FCFLAGS="$orig_FCFLAGS"
344344
AC_MSG_RESULT([no])
345345
fi
@@ -406,14 +406,14 @@ if test "$opal_pthread_c_success" = "0"; then
406406
case "${host_cpu}-${host-_os}" in
407407
*-aix* | *-freebsd*)
408408
if test "`echo $CPPFLAGS | $GREP 'D_THREAD_SAFE'`" = ""; then
409-
PTHREAD_CPPFLAGS="-D_THREAD_SAFE"
410-
CPPFLAGS="$CPPFLAGS $PTHREAD_CPPFLAGS"
409+
TPKG_CPPFLAGS="-D_THREAD_SAFE"
410+
CPPFLAGS="$CPPFLAGS $TPKG_CPPFLAGS"
411411
fi
412412
;;
413413
*)
414414
if test "`echo $CPPFLAGS | $GREP 'D_REENTRANT'`" = ""; then
415-
PTHREAD_CPPFLAGS="-D_REENTRANT"
416-
CPPFLAGS="$CPPFLAGS $PTHREAD_CPPFLAGS"
415+
TPKG_CPPFLAGS="-D_REENTRANT"
416+
CPPFLAGS="$CPPFLAGS $TPKG_CPPFLAGS"
417417
fi
418418
;;
419419
esac
@@ -423,10 +423,10 @@ if test "$opal_pthread_c_success" = "0"; then
423423
opal_pthread_c_success=0)
424424
AC_LANG_POP(C)
425425
if test "$opal_pthread_c_success" = "1"; then
426-
PTHREAD_LIBS="$pl"
426+
TPKG_LIBS="$pl"
427427
AC_MSG_RESULT([yes])
428428
else
429-
PTHREAD_CPPFLAGS=
429+
TPKG_CPPFLAGS=
430430
CPPFLAGS="$orig_CPPFLAGS"
431431
LIBS="$orig_LIBS"
432432
AC_MSG_RESULT([no])
@@ -441,23 +441,23 @@ AC_DEFUN([OPAL_INTL_POSIX_THREADS_LIBS_CXX],[
441441
# C++ compiler
442442
#
443443
if test "$opal_pthread_cxx_success" = "0"; then
444-
if test ! "$opal_pthread_c_success" = "0" && test ! "$PTHREAD_LIBS" = "" ; then
445-
AC_MSG_CHECKING([if C++ compiler and POSIX threads work with $PTHREAD_LIBS])
444+
if test ! "$opal_pthread_c_success" = "0" && test ! "$TPKG_LIBS" = "" ; then
445+
AC_MSG_CHECKING([if C++ compiler and POSIX threads work with $TPKG_LIBS])
446446
case "${host_cpu}-${host-_os}" in
447447
*-aix* | *-freebsd*)
448448
if test "`echo $CXXCPPFLAGS | $GREP 'D_THREAD_SAFE'`" = ""; then
449-
PTHREAD_CXXCPPFLAGS="-D_THREAD_SAFE"
450-
CXXCPPFLAGS="$CXXCPPFLAGS $PTHREAD_CXXCPPFLAGS"
449+
TPKG_CXXCPPFLAGS="-D_THREAD_SAFE"
450+
CXXCPPFLAGS="$CXXCPPFLAGS $TPKG_CXXCPPFLAGS"
451451
fi
452452
;;
453453
*)
454454
if test "`echo $CXXCPPFLAGS | $GREP 'D_REENTRANT'`" = ""; then
455-
PTHREAD_CXXCPPFLAGS="-D_REENTRANT"
456-
CXXCPPFLAGS="$CXXCPPFLAGS $PTHREAD_CXXCPPFLAGS"
455+
TPKG_CXXCPPFLAGS="-D_REENTRANT"
456+
CXXCPPFLAGS="$CXXCPPFLAGS $TPKG_CXXCPPFLAGS"
457457
fi
458458
;;
459459
esac
460-
LIBS="$orig_LIBS $PTHREAD_LIBS"
460+
LIBS="$orig_LIBS $TPKG_LIBS"
461461
AC_LANG_PUSH(C++)
462462
OPAL_INTL_PTHREAD_TRY_LINK(opal_pthread_cxx_success=1,
463463
opal_pthread_cxx_success=0)
@@ -476,14 +476,14 @@ if test "$opal_pthread_cxx_success" = "0"; then
476476
case "${host_cpu}-${host-_os}" in
477477
*-aix* | *-freebsd*)
478478
if test "`echo $CXXCPPFLAGS | $GREP 'D_THREAD_SAFE'`" = ""; then
479-
PTHREAD_CXXCPPFLAGS="-D_THREAD_SAFE"
480-
CXXCPPFLAGS="$CXXCPPFLAGS $PTHREAD_CXXCPPFLAGS"
479+
TPKG_CXXCPPFLAGS="-D_THREAD_SAFE"
480+
CXXCPPFLAGS="$CXXCPPFLAGS $TPKG_CXXCPPFLAGS"
481481
fi
482482
;;
483483
*)
484484
if test "`echo $CXXCPPFLAGS | $GREP 'D_REENTRANT'`" = ""; then
485-
PTHREAD_CXXCPPFLAGS="-D_REENTRANT"
486-
CXXCPPFLAGS="$CXXCPPFLAGS $PTHREAD_CXXCPPFLAGS"
485+
TPKG_CXXCPPFLAGS="-D_REENTRANT"
486+
CXXCPPFLAGS="$CXXCPPFLAGS $TPKG_CXXCPPFLAGS"
487487
fi
488488
;;
489489
esac
@@ -493,10 +493,10 @@ if test "$opal_pthread_cxx_success" = "0"; then
493493
opal_pthread_cxx_success=0)
494494
AC_LANG_POP(C++)
495495
if test "$opal_pthread_cxx_success" = "1"; then
496-
PTHREAD_LIBS="$pl"
496+
TPKG_LIBS="$pl"
497497
AC_MSG_RESULT([yes])
498498
else
499-
PTHREAD_CXXCPPFLAGS=
499+
TPKG_CXXCPPFLAGS=
500500
CXXCPPFLAGS="$orig_CXXCPPFLAGS"
501501
LIBS="$orig_LIBS"
502502
AC_MSG_RESULT([no])
@@ -514,9 +514,9 @@ AC_DEFUN([OPAL_INTL_POSIX_THREADS_LIBS_FC],[
514514
if test "$opal_pthread_fortran_success" = "0" && \
515515
test "$OMPI_TRY_FORTRAN_BINDINGS" -gt "$OMPI_FORTRAN_NO_BINDINGS" && \
516516
test $ompi_fortran_happy -eq 1; then
517-
if test ! "$opal_pthread_c_success" = "0" && test ! "$PTHREAD_LIBS" = "" ; then
518-
AC_MSG_CHECKING([if Fortran compiler and POSIX threads work with $PTHREAD_LIBS])
519-
LIBS="$orig_LIBS $PTHREAD_LIBS"
517+
if test ! "$opal_pthread_c_success" = "0" && test ! "$TPKG_LIBS" = "" ; then
518+
AC_MSG_CHECKING([if Fortran compiler and POSIX threads work with $TPKG_LIBS])
519+
LIBS="$orig_LIBS $TPKG_LIBS"
520520
AC_LANG_PUSH(C)
521521
OPAL_INTL_PTHREAD_TRY_LINK_FORTRAN(opal_pthread_fortran_success=1,
522522
opal_pthread_fortran_success=0)
@@ -537,7 +537,7 @@ if test "$opal_pthread_fortran_success" = "0" && \
537537
opal_pthread_fortran_success=0)
538538
AC_LANG_POP(C)
539539
if test "$opal_pthread_fortran_success" = "1"; then
540-
PTHREAD_LIBS="$pl"
540+
TPKG_LIBS="$pl"
541541
AC_MSG_RESULT([yes])
542542
break
543543
else
@@ -600,13 +600,13 @@ orig_CXXCPPFLAGS="$CXXCPPFLAGS"
600600
orig_LDFLAGS="$LDFLAGS"
601601
orig_LIBS="$LIBS"
602602
603-
PTHREAD_CFLAGS=
604-
PTHREAD_FCFLAGS=
605-
PTHREAD_CXXFLAGS=
606-
PTHREAD_CPPFLAGS=
607-
PTHREAD_CXXCPPFLAGS=
608-
PTHREAD_LDFLAGS=
609-
PTHREAD_LIBS=
603+
TPKG_CFLAGS=
604+
TPKG_FCFLAGS=
605+
TPKG_CXXFLAGS=
606+
TPKG_CPPFLAGS=
607+
TPKG_CXXCPPFLAGS=
608+
TPKG_LDFLAGS=
609+
TPKG_LIBS=
610610
611611
# Try with the basics, mam.
612612
OPAL_INTL_POSIX_THREADS_PLAIN

config/opal_config_qthreads.m4

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
dnl
2+
dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
3+
dnl University Research and Technology
4+
dnl Corporation. All rights reserved.
5+
dnl Copyright (c) 2004-2005 The University of Tennessee and The University
6+
dnl of Tennessee Research Foundation. All rights
7+
dnl reserved.
8+
dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9+
dnl University of Stuttgart. All rights reserved.
10+
dnl Copyright (c) 2004-2005 The Regents of the University of California.
11+
dnl All rights reserved.
12+
dnl Copyright (c) 2012 Cisco Systems, Inc. All rights reserved.
13+
dnl Copyright (c) 2014 Intel, Inc. All rights reserved.
14+
dnl Copyright (c) 2014-2016 Research Organization for Information Science
15+
dnl and Technology (RIST). All rights reserved.
16+
dnl Copyright (c) 2019 Sandia National Laboratories. All rights reserved.
17+
dnl Copyright (c) 2019 Triad National Security, LLC. All rights.
18+
dnl $COPYRIGHT$
19+
dnl
20+
dnl Additional copyrights may follow
21+
dnl
22+
dnl $HEADER$
23+
dnl
24+
dnl OPAL_CONFIG_QTHREADS()
25+
dnl
26+
dnl Configure argobot threads, setting the following variables (but
27+
dnl not calling AC_SUBST on them).
28+
29+
#********************************************************************
30+
#
31+
# TODO: undoubtedly need some better check than this
32+
#
33+
#********************************************************************
34+
AC_DEFUN([OPAL_CONFIG_QTHREADS],[
35+
36+
AC_CHECK_HEADERS([mach/mach_time.h],
37+
[AC_CHECK_FUNC([mach_absolute_time],
38+
[threads_qthreads_happy="yes"],
39+
[threads_qthreads_happy="no"])],
40+
[threads_qthreads_happy="no"])
41+
42+
AS_IF([test "$threads_qthreads_happy" = "yes"],
43+
[$1],
44+
[$2])
45+
])dnl

config/opal_config_threads.m4

Lines changed: 62 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ dnl Copyright (c) 2009-2011 Oak Ridge National Labs. All rights reserved.
1414
dnl Copyright (c) 2014 Intel, Inc. All rights reserved
1515
dnl Copyright (c) 2015 Research Organization for Information Science
1616
dnl and Technology (RIST). All rights reserved.
17+
dnl Copyright (c) 2019 Triad National Security, LLC. All rights.
1718
dnl $COPYRIGHT$
1819
dnl
1920
dnl Additional copyrights may follow
@@ -34,36 +35,74 @@ AC_DEFUN([OPAL_CONFIG_THREADS],[
3435
#
3536
3637
#
37-
# Check we have POSIX threads
38+
# First see what kind of threads we are going to use
3839
#
39-
OPAL_CONFIG_POSIX_THREADS(HAVE_POSIX_THREADS=1, HAVE_POSIX_THREADS=0)
40-
AC_MSG_CHECKING([for working POSIX threads package])
41-
if test "$HAVE_POSIX_THREADS" = "1" ; then
42-
AC_MSG_RESULT([yes])
43-
else
44-
AC_MSG_RESULT([no])
45-
fi
46-
export HAVE_POSIX_THREADS
40+
41+
AC_ARG_WITH([threads],
42+
[AC_HELP_STRING([--with-threads=TYPE],
43+
[Specify thread TYPE to use. default:pthreads. Other options are qthreads and argobots.])])
44+
45+
#
46+
# Check we for the thread package requested, or posix
47+
#
48+
49+
thread_type_found=
50+
51+
#
52+
# check for posix threads
53+
#
54+
AS_IF([test -z "$with_threads" || test "$with_threads" = "pthreads" || test "$with_threads" = "yes"],
55+
[OPAL_CONFIG_POSIX_THREADS(HAVE_THREAD_PKG=1, HAVE_THREAD_PKG=0)
56+
AC_MSG_CHECKING([for working POSIX threads package])
57+
AS_IF([test "$HAVE_THREAD_PKG" = "1"],
58+
[AC_MSG_RESULT([yes])
59+
thread_type_found="pthreads"],
60+
[AC_MSG_RESULT([no])])],
61+
[])
62+
63+
#
64+
# see if argobots is called for
65+
#
66+
AS_IF([test -z "$thread_type_found" && test "$with_threads" = argobots"],
67+
[OPAL_CONFIG_ARGOBOT_THREADS(HAVE_THREAD_PKG=1, HAVE_THREAD_PKG=0)
68+
AC_MSG_CHECKING([for working ARGOBOTS threads package])
69+
AS_IF([test "$HAVE_THREAD_PKG" = "1"],
70+
[AC_MSG_RESULT([yes])
71+
thread_type_found="argobots"],
72+
[AC_MSG_RESULT([no])])],
73+
[])
74+
75+
AS_IF([test -z "$thread_type_found" && test "$with_threads" = qthreads"],
76+
[OPAL_CONFIG_QTHREADS(HAVE_THREAD_PKG=1, HAVE_THREAD_PKG=0)
77+
AC_MSG_CHECKING([for working Qthreads package])
78+
AS_IF([test "$HAVE_THREAD_PKG" = "1"],
79+
[AC_MSG_RESULT([yes])
80+
thread_type_found="qthreads"],
81+
[AC_MSG_RESULT([no])])],
82+
[])
4783
4884
#
49-
# Ask what threading we want (allow posix right now)
85+
# Bail if we didn't find any thread package
5086
#
5187
52-
if test "$HAVE_POSIX_THREADS" = "0"; then
53-
AC_MSG_WARN(["*** POSIX threads are not"])
54-
AC_MSG_WARN(["*** available on your system "])
55-
AC_MSG_ERROR(["*** Can not continue"])
56-
fi
88+
AS_IF([test -z "$thread_type_found"],
89+
[AC_MSG_WARN([*** no thread package $with_threads])
90+
AC_MSG_WARN([*** available on your system])
91+
AC_MSG_ERROR([*** Can not continue])])
5792
58-
THREAD_CFLAGS="$PTHREAD_CFLAGS"
59-
THREAD_FCFLAGS="$PTHREAD_FCFLAGS"
60-
THREAD_CXXFLAGS="$PTHREAD_CXXFLAGS"
61-
THREAD_CPPFLAGS="$PTHREAD_CPPFLAGS"
62-
THREAD_CXXCPPFLAGS="$PTHREAD_CXXCPPFLAGS"
63-
THREAD_LDFLAGS="$PTHREAD_LDFLAGS"
64-
THREAD_LIBS="$PTHREAD_LIBS"
93+
THREAD_CFLAGS="$TPKG_CFLAGS"
94+
THREAD_FCFLAGS="$TPKG_FCFLAGS"
95+
THREAD_CXXFLAGS="$TPKG_CXXFLAGS"
96+
THREAD_CPPFLAGS="$TPKG_CPPFLAGS"
97+
THREAD_CXXCPPFLAGS="$TPKG_CXXCPPFLAGS"
98+
THREAD_LDFLAGS="$TPKG_LDFLAGS"
99+
THREAD_LIBS="$TPKG_LIBS"
100+
HAVE_THREAD_PKG_TYPE="$thread_type_found"
101+
export HAVE_THREAD_PKG_TYPE
65102
66-
OPAL_CHECK_PTHREAD_PIDS
103+
AS_IF([test "$thread_type_found" = "pthreads"],
104+
[OPAL_CHECK_PTHREAD_PIDS],[])
67105
106+
OPAL_SUMMARY_ADD([[Miscellaneous]],[[Threading Package]],[opal_threads], [$thread_type_found])
68107
])dnl
69108

opal/Makefile.am

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ endif
7171
include class/Makefile.am
7272
include memoryhooks/Makefile.am
7373
include runtime/Makefile.am
74-
include threads/Makefile.am
7574
include mca/Makefile.am
7675
include tools/Makefile.am
7776
include dss/Makefile.am

opal/mca/event/event.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ BEGIN_C_DECLS
4848

4949
#define OPAL_TIMEOUT_DEFAULT {1, 0}
5050

51+
OPAL_DECLSPEC void opal_event_use_threads(void);
52+
5153
/**
5254
* Structure for event components.
5355
*/

opal/mca/event/external/external.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ OPAL_DECLSPEC int opal_event_finalize(void);
7171

7272
#define opal_event_set_priority(x, n) event_priority_set((x), (n))
7373

74-
/* thread support APIs */
75-
#define opal_event_use_threads() evthread_use_pthreads()
76-
7774
/* Basic event APIs */
7875
#define opal_event_enable_debug_mode() event_enable_debug_mode()
7976

0 commit comments

Comments
 (0)