there was an #include directive missing
[openmpi-llc.git] / config / ompi_config_threads.m4
blob7c3b7f3865913fd905b07b24ad45141235a68cad
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$
13 dnl 
14 dnl Additional copyrights may follow
15 dnl 
16 dnl $HEADER$
17 dnl
19 AC_DEFUN([OMPI_CONFIG_THREADS],[
21 # Arguments: none
23 # Dependencies: None
25 # Modifies:
26 #  none - see called tests
28 # configure threads
31 # create templates
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
43   AC_MSG_RESULT([yes])
44 else
45   AC_MSG_RESULT([no])
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
52   AC_MSG_RESULT([yes])
53 else
54   AC_MSG_RESULT([no])
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])
62 AC_ARG_WITH(threads, 
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"])
73     fi
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"])
80     fi
81 elif test "$THREAD_TYPE" = "no"; then
82     THREAD_TYPE="none"
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
87     case "$host" in
88         *solaris*)
89             if test "$HAVE_SOLARIS_THREADS" = "1"; then
90                 THREAD_TYPE="solaris"
91             elif test "$HAVE_POSIX_THREADS" = "1"; then
92                 THREAD_TYPE="posix"
93             else
94                 THEAD_TYPE="none found"
95             fi
96             ;;
97         *)
98             if test "$HAVE_POSIX_THREADS" = "1"; then
99                 THREAD_TYPE="posix"
100             else
101                 THREAD_TYPE="none found"
102             fi
103             ;;
104     esac
105 else
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
144 else
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)
149     TRHEAD_CFLAGS=
150     THREAD_FFLAGS=
151     THREAD_CXXFLAGS=
152     THREAD_CPPFLAGS=
153     THREAD_CXXCPPFLAGS=
154     THREAD_LDFLAGS=
155     THREAD_LIBS=
156     if test "$THREAD_TYPE" != "none" ; then
157         cat <<EOF
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
166 problem.
168 ************************************************************************
171     fi
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"
192 dnl    else
193 dnl        OMPI_ENABLE_MPI_THREADS=0
194 dnl        enable_mpi_threads="no"
195 dnl    fi
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
201 else
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"
206     else
207         AC_MSG_ERROR([User requested MPI threads, but no threading model supported])
208     fi
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"
228 else
229     # they want threaded progress
230     if test "$THREAD_TYPE" != "none" ; then
231         OMPI_ENABLE_PROGRESS_THREADS=1
232         enable_progress_threads="yes"
233     else
234         AC_MSG_ERROR([User requested progress threads, but no threading model supported])
235     fi
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])
240 ])dnl