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
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.
14 dnl Additional copyrights may follow
19 AC_DEFUN([OMPI_CONFIG_THREADS],[
26 # none - see called tests
32 AH_TEMPLATE([OMPI_HAVE_SOLARIS_THREADS],
33 [Do we have native Solaris threads])
34 AH_TEMPLATE([OMPI_HAVE_POSIX_THREADS],
35 [Do we have POSIX threads])
38 # Check for thread types - add your type here...
40 OMPI_CONFIG_POSIX_THREADS(HAVE_POSIX_THREADS=1, HAVE_POSIX_THREADS=0)
41 AC_MSG_CHECKING([for working POSIX threads package])
42 if test "$HAVE_POSIX_THREADS" = "1" ; then
47 export HAVE_POSIX_THREADS
49 OMPI_CONFIG_SOLARIS_THREADS(HAVE_SOLARIS_THREADS=1, HAVE_SOLARIS_THREADS=0)
50 AC_MSG_CHECKING([for working Solaris threads package])
51 if test "$HAVE_SOLARIS_THREADS" = "1" ; then
56 export HAVE_SOLARIS_THREADS
59 # Ask what threading we want (allow solaris / posix right now)
61 AC_MSG_CHECKING([for type of thread support])
63 AC_HELP_STRING([--with-threads],
64 [Set thread type (solaris / posix)]),
65 [THREAD_TYPE=$withval])
67 if test "$THREAD_TYPE" = "solaris"; then
69 if test "$HAVE_SOLARIS_THREADS" = "0"; then
70 AC_MSG_WARN(["*** You have chosen Solaris threads, which are not"])
71 AC_MSG_WARN(["*** available on your system "])
72 AC_MSG_ERROR(["*** Can not continue"])
74 elif test "$THREAD_TYPE" = "posix"; then
76 if test "$HAVE_POSIX_THREADS" = "0"; then
77 AC_MSG_WARN(["*** You have chosen POSIX threads, which are not"])
78 AC_MSG_WARN(["*** available on your system "])
79 AC_MSG_ERROR(["*** Can not continue"])
81 elif test "$THREAD_TYPE" = "no"; then
83 elif test -z "$THREAD_TYPE" -o "$THREAD_TYPE" = "yes"; then
85 # Actual logic here - properly set THREAD_TYPE - we go for system
86 # optimized where ever possible
89 if test "$HAVE_SOLARIS_THREADS" = "1"; then
91 elif test "$HAVE_POSIX_THREADS" = "1"; then
94 THEAD_TYPE="none found"
98 if test "$HAVE_POSIX_THREADS" = "1"; then
101 THREAD_TYPE="none found"
107 AC_MSG_WARN(["*** You have specified a thread type that I do not"])
108 AC_MSG_WARN(["*** understand. Valid options are posix and solaris"])
109 AC_MSG_ERROR(["*** Can not continue."])
111 AC_MSG_RESULT($THREAD_TYPE)
115 # Ok, now run the configuration for that thread package.
117 # Blah - this should be made better, but I don't know how...
119 if test "$THREAD_TYPE" = "solaris"; then
120 AC_DEFINE(OMPI_HAVE_SOLARIS_THREADS, 1)
121 AC_DEFINE(OMPI_HAVE_POSIX_THREADS, 0)
122 AC_DEFINE(OMPI_THREADS_HAVE_DIFFERENT_PIDS, 0)
124 THREAD_CFLAGS="$STHREAD_CFLAGS"
125 THREAD_FFLAGS="$STHREAD_FFLAGS"
126 THREAD_CXXFLAGS="$STHREAD_CXXFLAGS"
127 THREAD_CPPFLAGS="$STHREAD_CPPFLAGS"
128 THREAD_CXXCPPFLAGS="$STHREAD_CXXCPPFLAGS"
129 THREAD_LDFLAGS="$STHREAD_LDFLAGS"
130 THREAD_LIBS="$STHREAD_LIBS"
131 elif test "$THREAD_TYPE" = "posix"; then
132 AC_DEFINE(OMPI_HAVE_SOLARIS_THREADS, 0)
133 AC_DEFINE(OMPI_HAVE_POSIX_THREADS, 1)
135 THREAD_CFLAGS="$PTHREAD_CFLAGS"
136 THREAD_FFLAGS="$PTHREAD_FFLAGS"
137 THREAD_CXXFLAGS="$PTHREAD_CXXFLAGS"
138 THREAD_CPPFLAGS="$PTHREAD_CPPFLAGS"
139 THREAD_CXXCPPFLAGS="$PTHREAD_CXXCPPFLAGS"
140 THREAD_LDFLAGS="$PTHREAD_LDFLAGS"
141 THREAD_LIBS="$PTHREAD_LIBS"
143 OMPI_CHECK_PTHREAD_PIDS
145 AC_DEFINE(OMPI_HAVE_SOLARIS_THREADS, 0)
146 AC_DEFINE(OMPI_HAVE_POSIX_THREADS, 0)
147 AC_DEFINE(OMPI_THREADS_HAVE_DIFFERENT_PIDS, 0)
156 if test "$THREAD_TYPE" != "none" ; then
159 ************************************************************************
161 Open MPI was unable to find threading support on your system. In the
162 near future, the OMPI development team is considering requiring
163 threading support for proper OMPI execution. This is in part because
164 we are not aware of any users that do not have thread support - so we
165 need you to e-mail us at ompi@ompi-mpi.org and let us know about this
168 ************************************************************************
174 AM_CONDITIONAL(OMPI_HAVE_POSIX_THREADS, test "$THREAD_TYPE" = "posix")
175 AM_CONDITIONAL(OMPI_HAVE_SOLARIS_THREADS, test "$THREAD_TYPE" = "solaris")
178 # Now configure the whole MPI and progress thread gorp
180 AC_MSG_CHECKING([if want MPI thread support])
181 AC_ARG_ENABLE([mpi-threads],
182 AC_HELP_STRING([--enable-mpi-threads],
183 [Enable threads for MPI applications (default: disabled)]),
184 [enable_mpi_threads="$enableval"])
186 if test "$enable_mpi_threads" = "" ; then
187 dnl # no argument given either way. Default to whether
188 dnl # we have threads or not
189 dnl if test "$THREAD_TYPE" != "none" ; then
190 dnl OMPI_ENABLE_MPI_THREADS=1
191 dnl enable_mpi_threads="yes"
193 dnl OMPI_ENABLE_MPI_THREADS=0
194 dnl enable_mpi_threads="no"
196 # no argument - default to no
197 OMPI_ENABLE_MPI_THREADS=0
198 enable_mpi_threads="no"
199 elif test "$enable_mpi_threads" = "no" ; then
200 OMPI_ENABLE_MPI_THREADS=0
202 # they want MPI threads. Make sure we have threads
203 if test "$THREAD_TYPE" != "none" ; then
204 OMPI_ENABLE_MPI_THREADS=1
205 enable_mpi_threads="yes"
207 AC_MSG_ERROR([User requested MPI threads, but no threading model supported])
210 AC_DEFINE_UNQUOTED([OMPI_ENABLE_MPI_THREADS], [$OMPI_ENABLE_MPI_THREADS],
211 [Whether we should enable support for multiple user threads])
212 AC_MSG_RESULT([$enable_mpi_threads])
215 AC_MSG_CHECKING([if want asynchronous progress thread support])
216 AC_ARG_ENABLE([progress-threads],
217 AC_HELP_STRING([--enable-progress-threads],
218 [Enable threads asynchronous communication progress (default: disabled)]),
219 [enable_progress_threads="$enableval"])
221 if test "$enable_progress_threads" = "" ; then
222 # no argument given either way. Default to no.
223 OMPI_ENABLE_PROGRESS_THREADS=0
224 enable_progress_threads="no"
225 elif test "$enable_progress_threads" = "no" ; then
226 OMPI_ENABLE_PROGRESS_THREADS=0
227 enable_progress_threads="no"
229 # they want threaded progress
230 if test "$THREAD_TYPE" != "none" ; then
231 OMPI_ENABLE_PROGRESS_THREADS=1
232 enable_progress_threads="yes"
234 AC_MSG_ERROR([User requested progress threads, but no threading model supported])
237 AC_DEFINE_UNQUOTED([OMPI_ENABLE_PROGRESS_THREADS], [$OMPI_ENABLE_PROGRESS_THREADS],
238 [Whether we should use progress threads rather than polling])
239 AC_MSG_RESULT([$enable_progress_threads])