Skip to content

Topic/thread framework #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions config/opal_config_argobots.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
dnl
dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
dnl University Research and Technology
dnl Corporation. All rights reserved.
dnl Copyright (c) 2004-2005 The University of Tennessee and The University
dnl of Tennessee Research Foundation. All rights
dnl reserved.
dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
dnl University of Stuttgart. All rights reserved.
dnl Copyright (c) 2004-2005 The Regents of the University of California.
dnl All rights reserved.
dnl Copyright (c) 2012 Cisco Systems, Inc. All rights reserved.
dnl Copyright (c) 2014 Intel, Inc. All rights reserved.
dnl Copyright (c) 2014-2016 Research Organization for Information Science
dnl and Technology (RIST). All rights reserved.
dnl $COPYRIGHT$
dnl
dnl Additional copyrights may follow
dnl
dnl $HEADER$
dnl
dnl OPAL_CONFIG_ARGOBOTS_THREADS()
dnl
dnl Configure Argobots threads, setting the following variables (but
dnl not calling AC_SUBST on them).

AC_DEFUN([OPAL_CONFIG_ARGOBOTS_THREADS],[
AC_CHECK_HEADERS([abt.h],
[AC_CHECK_LIB([abt],[ABT_init],
[threads_argobots_happy="yes"],
[threads_argobots_happy="no"])],
[threads_argobots_happy="no"])

AS_IF([test "$threads_argobots_happy" = "yes"],
[$1],
[$2])
])dnl
72 changes: 36 additions & 36 deletions config/opal_config_pthreads.m4
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,11 @@ if test "$opal_pthread_c_success" = "0"; then
opal_pthread_c_success=0)
AC_LANG_POP(C)
if test "$opal_pthread_c_success" = "1"; then
PTHREAD_CFLAGS="$pf"
TPKG_CFLAGS="$pf"
AC_MSG_RESULT([yes])
break
else
PTHREAD_CFLAGS=
TPKG_CFLAGS=
CFLAGS="$orig_CFLAGS"
AC_MSG_RESULT([no])
fi
Expand All @@ -307,11 +307,11 @@ if test "$opal_pthread_cxx_success" = "0"; then
opal_pthread_cxx_success=0)
AC_LANG_POP(C++)
if test "$opal_pthread_cxx_success" = "1"; then
PTHREAD_CXXFLAGS="$pf"
TPKG_CXXFLAGS="$pf"
AC_MSG_RESULT([yes])
break
else
PTHREAD_CXXFLAGS=
TPKG_CXXFLAGS=
CXXFLAGS="$orig_CXXFLAGS"
AC_MSG_RESULT([no])
fi
Expand All @@ -335,11 +335,11 @@ if test "$opal_pthread_fortran_success" = "0" && \
opal_pthread_fortran_success=0)
AC_LANG_POP(C)
if test "$opal_pthread_fortran_success" = "1"; then
PTHREAD_FCFLAGS="$pf"
TPKG_FCFLAGS="$pf"
AC_MSG_RESULT([yes])
break
else
PTHREAD_FCFLAGS=
TPKG_FCFLAGS=
FCFLAGS="$orig_FCFLAGS"
AC_MSG_RESULT([no])
fi
Expand Down Expand Up @@ -406,14 +406,14 @@ if test "$opal_pthread_c_success" = "0"; then
case "${host_cpu}-${host-_os}" in
*-aix* | *-freebsd*)
if test "`echo $CPPFLAGS | $GREP 'D_THREAD_SAFE'`" = ""; then
PTHREAD_CPPFLAGS="-D_THREAD_SAFE"
CPPFLAGS="$CPPFLAGS $PTHREAD_CPPFLAGS"
TPKG_CPPFLAGS="-D_THREAD_SAFE"
CPPFLAGS="$CPPFLAGS $TPKG_CPPFLAGS"
fi
;;
*)
if test "`echo $CPPFLAGS | $GREP 'D_REENTRANT'`" = ""; then
PTHREAD_CPPFLAGS="-D_REENTRANT"
CPPFLAGS="$CPPFLAGS $PTHREAD_CPPFLAGS"
TPKG_CPPFLAGS="-D_REENTRANT"
CPPFLAGS="$CPPFLAGS $TPKG_CPPFLAGS"
fi
;;
esac
Expand All @@ -423,10 +423,10 @@ if test "$opal_pthread_c_success" = "0"; then
opal_pthread_c_success=0)
AC_LANG_POP(C)
if test "$opal_pthread_c_success" = "1"; then
PTHREAD_LIBS="$pl"
TPKG_LIBS="$pl"
AC_MSG_RESULT([yes])
else
PTHREAD_CPPFLAGS=
TPKG_CPPFLAGS=
CPPFLAGS="$orig_CPPFLAGS"
LIBS="$orig_LIBS"
AC_MSG_RESULT([no])
Expand All @@ -441,23 +441,23 @@ AC_DEFUN([OPAL_INTL_POSIX_THREADS_LIBS_CXX],[
# C++ compiler
#
if test "$opal_pthread_cxx_success" = "0"; then
if test ! "$opal_pthread_c_success" = "0" && test ! "$PTHREAD_LIBS" = "" ; then
AC_MSG_CHECKING([if C++ compiler and POSIX threads work with $PTHREAD_LIBS])
if test ! "$opal_pthread_c_success" = "0" && test ! "$TPKG_LIBS" = "" ; then
AC_MSG_CHECKING([if C++ compiler and POSIX threads work with $TPKG_LIBS])
case "${host_cpu}-${host-_os}" in
*-aix* | *-freebsd*)
if test "`echo $CXXCPPFLAGS | $GREP 'D_THREAD_SAFE'`" = ""; then
PTHREAD_CXXCPPFLAGS="-D_THREAD_SAFE"
CXXCPPFLAGS="$CXXCPPFLAGS $PTHREAD_CXXCPPFLAGS"
TPKG_CXXCPPFLAGS="-D_THREAD_SAFE"
CXXCPPFLAGS="$CXXCPPFLAGS $TPKG_CXXCPPFLAGS"
fi
;;
*)
if test "`echo $CXXCPPFLAGS | $GREP 'D_REENTRANT'`" = ""; then
PTHREAD_CXXCPPFLAGS="-D_REENTRANT"
CXXCPPFLAGS="$CXXCPPFLAGS $PTHREAD_CXXCPPFLAGS"
TPKG_CXXCPPFLAGS="-D_REENTRANT"
CXXCPPFLAGS="$CXXCPPFLAGS $TPKG_CXXCPPFLAGS"
fi
;;
esac
LIBS="$orig_LIBS $PTHREAD_LIBS"
LIBS="$orig_LIBS $TPKG_LIBS"
AC_LANG_PUSH(C++)
OPAL_INTL_PTHREAD_TRY_LINK(opal_pthread_cxx_success=1,
opal_pthread_cxx_success=0)
Expand All @@ -476,14 +476,14 @@ if test "$opal_pthread_cxx_success" = "0"; then
case "${host_cpu}-${host-_os}" in
*-aix* | *-freebsd*)
if test "`echo $CXXCPPFLAGS | $GREP 'D_THREAD_SAFE'`" = ""; then
PTHREAD_CXXCPPFLAGS="-D_THREAD_SAFE"
CXXCPPFLAGS="$CXXCPPFLAGS $PTHREAD_CXXCPPFLAGS"
TPKG_CXXCPPFLAGS="-D_THREAD_SAFE"
CXXCPPFLAGS="$CXXCPPFLAGS $TPKG_CXXCPPFLAGS"
fi
;;
*)
if test "`echo $CXXCPPFLAGS | $GREP 'D_REENTRANT'`" = ""; then
PTHREAD_CXXCPPFLAGS="-D_REENTRANT"
CXXCPPFLAGS="$CXXCPPFLAGS $PTHREAD_CXXCPPFLAGS"
TPKG_CXXCPPFLAGS="-D_REENTRANT"
CXXCPPFLAGS="$CXXCPPFLAGS $TPKG_CXXCPPFLAGS"
fi
;;
esac
Expand All @@ -493,10 +493,10 @@ if test "$opal_pthread_cxx_success" = "0"; then
opal_pthread_cxx_success=0)
AC_LANG_POP(C++)
if test "$opal_pthread_cxx_success" = "1"; then
PTHREAD_LIBS="$pl"
TPKG_LIBS="$pl"
AC_MSG_RESULT([yes])
else
PTHREAD_CXXCPPFLAGS=
TPKG_CXXCPPFLAGS=
CXXCPPFLAGS="$orig_CXXCPPFLAGS"
LIBS="$orig_LIBS"
AC_MSG_RESULT([no])
Expand All @@ -514,9 +514,9 @@ AC_DEFUN([OPAL_INTL_POSIX_THREADS_LIBS_FC],[
if test "$opal_pthread_fortran_success" = "0" && \
test "$OMPI_TRY_FORTRAN_BINDINGS" -gt "$OMPI_FORTRAN_NO_BINDINGS" && \
test $ompi_fortran_happy -eq 1; then
if test ! "$opal_pthread_c_success" = "0" && test ! "$PTHREAD_LIBS" = "" ; then
AC_MSG_CHECKING([if Fortran compiler and POSIX threads work with $PTHREAD_LIBS])
LIBS="$orig_LIBS $PTHREAD_LIBS"
if test ! "$opal_pthread_c_success" = "0" && test ! "$TPKG_LIBS" = "" ; then
AC_MSG_CHECKING([if Fortran compiler and POSIX threads work with $TPKG_LIBS])
LIBS="$orig_LIBS $TPKG_LIBS"
AC_LANG_PUSH(C)
OPAL_INTL_PTHREAD_TRY_LINK_FORTRAN(opal_pthread_fortran_success=1,
opal_pthread_fortran_success=0)
Expand All @@ -537,7 +537,7 @@ if test "$opal_pthread_fortran_success" = "0" && \
opal_pthread_fortran_success=0)
AC_LANG_POP(C)
if test "$opal_pthread_fortran_success" = "1"; then
PTHREAD_LIBS="$pl"
TPKG_LIBS="$pl"
AC_MSG_RESULT([yes])
break
else
Expand Down Expand Up @@ -600,13 +600,13 @@ orig_CXXCPPFLAGS="$CXXCPPFLAGS"
orig_LDFLAGS="$LDFLAGS"
orig_LIBS="$LIBS"

PTHREAD_CFLAGS=
PTHREAD_FCFLAGS=
PTHREAD_CXXFLAGS=
PTHREAD_CPPFLAGS=
PTHREAD_CXXCPPFLAGS=
PTHREAD_LDFLAGS=
PTHREAD_LIBS=
TPKG_CFLAGS=
TPKG_FCFLAGS=
TPKG_CXXFLAGS=
TPKG_CPPFLAGS=
TPKG_CXXCPPFLAGS=
TPKG_LDFLAGS=
TPKG_LIBS=

# Try with the basics, mam.
OPAL_INTL_POSIX_THREADS_PLAIN
Expand Down
45 changes: 45 additions & 0 deletions config/opal_config_qthreads.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
dnl
dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
dnl University Research and Technology
dnl Corporation. All rights reserved.
dnl Copyright (c) 2004-2005 The University of Tennessee and The University
dnl of Tennessee Research Foundation. All rights
dnl reserved.
dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
dnl University of Stuttgart. All rights reserved.
dnl Copyright (c) 2004-2005 The Regents of the University of California.
dnl All rights reserved.
dnl Copyright (c) 2012 Cisco Systems, Inc. All rights reserved.
dnl Copyright (c) 2014 Intel, Inc. All rights reserved.
dnl Copyright (c) 2014-2016 Research Organization for Information Science
dnl and Technology (RIST). All rights reserved.
dnl Copyright (c) 2019 Sandia National Laboratories. All rights reserved.
dnl Copyright (c) 2019 Triad National Security, LLC. All rights.
dnl $COPYRIGHT$
dnl
dnl Additional copyrights may follow
dnl
dnl $HEADER$
dnl
dnl OPAL_CONFIG_QTHREADS()
dnl
dnl Configure argobot threads, setting the following variables (but
dnl not calling AC_SUBST on them).

#********************************************************************
#
# TODO: undoubtedly need some better check than this
#
#********************************************************************
AC_DEFUN([OPAL_CONFIG_QTHREADS],[

AC_CHECK_HEADERS([mach/mach_time.h],
[AC_CHECK_FUNC([mach_absolute_time],
[threads_qthreads_happy="yes"],
[threads_qthreads_happy="no"])],
[threads_qthreads_happy="no"])

AS_IF([test "$threads_qthreads_happy" = "yes"],
[$1],
[$2])
])dnl
85 changes: 62 additions & 23 deletions config/opal_config_threads.m4
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ dnl Copyright (c) 2009-2011 Oak Ridge National Labs. All rights reserved.
dnl Copyright (c) 2014 Intel, Inc. All rights reserved
dnl Copyright (c) 2015 Research Organization for Information Science
dnl and Technology (RIST). All rights reserved.
dnl Copyright (c) 2019 Triad National Security, LLC. All rights.
dnl $COPYRIGHT$
dnl
dnl Additional copyrights may follow
Expand All @@ -34,36 +35,74 @@ AC_DEFUN([OPAL_CONFIG_THREADS],[
#

#
# Check we have POSIX threads
# First see what kind of threads we are going to use
#
OPAL_CONFIG_POSIX_THREADS(HAVE_POSIX_THREADS=1, HAVE_POSIX_THREADS=0)
AC_MSG_CHECKING([for working POSIX threads package])
if test "$HAVE_POSIX_THREADS" = "1" ; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
export HAVE_POSIX_THREADS

AC_ARG_WITH([threads],
[AC_HELP_STRING([--with-threads=TYPE],
[Specify thread TYPE to use. default:pthreads. Other options are qthreads and argobots.])])

#
# Check we for the thread package requested, or posix
#

thread_type_found=

#
# check for posix threads
#
AS_IF([test -z "$with_threads" || test "$with_threads" = "pthreads" || test "$with_threads" = "yes"],
[OPAL_CONFIG_POSIX_THREADS(HAVE_THREAD_PKG=1, HAVE_THREAD_PKG=0)
AC_MSG_CHECKING([for working POSIX threads package])
AS_IF([test "$HAVE_THREAD_PKG" = "1"],
[AC_MSG_RESULT([yes])
thread_type_found="pthreads"],
[AC_MSG_RESULT([no])])],
[])

#
# see if argobots is called for
#
AS_IF([test -z "$thread_type_found" && test "$with_threads" = "argobots"],
[OPAL_CONFIG_ARGOBOTS_THREADS(HAVE_THREAD_PKG=1, HAVE_THREAD_PKG=0)
AC_MSG_CHECKING([for working ARGOBOTS threads package])
AS_IF([test "$HAVE_THREAD_PKG" = "1"],
[AC_MSG_RESULT([yes])
thread_type_found="argobots"],
[AC_MSG_RESULT([no])])],
[])

AS_IF([test -z "$thread_type_found" && test "$with_threads" = "qthreads"],
[OPAL_CONFIG_QTHREADS(HAVE_THREAD_PKG=1, HAVE_THREAD_PKG=0)
AC_MSG_CHECKING([for working Qthreads package])
AS_IF([test "$HAVE_THREAD_PKG" = "1"],
[AC_MSG_RESULT([yes])
thread_type_found="qthreads"],
[AC_MSG_RESULT([no])])],
[])

#
# Ask what threading we want (allow posix right now)
# Bail if we didn't find any thread package
#

if test "$HAVE_POSIX_THREADS" = "0"; then
AC_MSG_WARN(["*** POSIX threads are not"])
AC_MSG_WARN(["*** available on your system "])
AC_MSG_ERROR(["*** Can not continue"])
fi
AS_IF([test -z "$thread_type_found"],
[AC_MSG_WARN([*** no thread package $with_threads])
AC_MSG_WARN([*** available on your system])
AC_MSG_ERROR([*** Can not continue])])

THREAD_CFLAGS="$PTHREAD_CFLAGS"
THREAD_FCFLAGS="$PTHREAD_FCFLAGS"
THREAD_CXXFLAGS="$PTHREAD_CXXFLAGS"
THREAD_CPPFLAGS="$PTHREAD_CPPFLAGS"
THREAD_CXXCPPFLAGS="$PTHREAD_CXXCPPFLAGS"
THREAD_LDFLAGS="$PTHREAD_LDFLAGS"
THREAD_LIBS="$PTHREAD_LIBS"
THREAD_CFLAGS="$TPKG_CFLAGS"
THREAD_FCFLAGS="$TPKG_FCFLAGS"
THREAD_CXXFLAGS="$TPKG_CXXFLAGS"
THREAD_CPPFLAGS="$TPKG_CPPFLAGS"
THREAD_CXXCPPFLAGS="$TPKG_CXXCPPFLAGS"
THREAD_LDFLAGS="$TPKG_LDFLAGS"
THREAD_LIBS="$TPKG_LIBS"
HAVE_THREAD_PKG_TYPE="$thread_type_found"
export HAVE_THREAD_PKG_TYPE

OPAL_CHECK_PTHREAD_PIDS
AS_IF([test "$thread_type_found" = "pthreads"],
[OPAL_CHECK_PTHREAD_PIDS],[])

OPAL_SUMMARY_ADD([[Miscellaneous]],[[Threading Package]],[opal_threads], [$thread_type_found])
])dnl

1 change: 0 additions & 1 deletion opal/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ endif
include class/Makefile.am
include memoryhooks/Makefile.am
include runtime/Makefile.am
include threads/Makefile.am
include mca/Makefile.am
include tools/Makefile.am
include dss/Makefile.am
2 changes: 2 additions & 0 deletions opal/mca/event/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ BEGIN_C_DECLS

#define OPAL_TIMEOUT_DEFAULT {1, 0}

OPAL_DECLSPEC void opal_event_use_threads(void);

/**
* Structure for event components.
*/
Expand Down
3 changes: 0 additions & 3 deletions opal/mca/event/external/external.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ OPAL_DECLSPEC int opal_event_finalize(void);

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

/* thread support APIs */
#define opal_event_use_threads() evthread_use_pthreads()

/* Basic event APIs */
#define opal_event_enable_debug_mode() event_enable_debug_mode()

Expand Down
Loading