~ubuntu-branches/ubuntu/precise/code-saturne/precise

« back to all changes in this revision

Viewing changes to config/cs_mpi.m4

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2011-11-01 17:43:32 UTC
  • mto: (6.1.7 sid)
  • mto: This revision was merged to the branch mainline in revision 11.
  • Revision ID: package-import@ubuntu.com-20111101174332-tl4vk45no0x3emc3
Tags: upstream-2.1.0
ImportĀ upstreamĀ versionĀ 2.1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
dnl----------------------------------------------------------------------------
2
 
dnl   This file is part of the Code_Saturne Kernel, element of the
3
 
dnl   Code_Saturne CFD tool.
4
 
dnl
5
 
dnl   Copyright (C) 2009 EDF S.A., France
6
 
dnl
7
 
dnl   The Code_Saturne Kernel is free software; you can redistribute it
8
 
dnl   and/or modify it under the terms of the GNU General Public License
9
 
dnl   as published by the Free Software Foundation; either version 2 of
10
 
dnl   the License, or (at your option) any later version.
11
 
dnl
12
 
dnl   The Code_Saturne Kernel is distributed in the hope that it will be
13
 
dnl   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
14
 
dnl   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
dnl   GNU General Public License for more details.
16
 
dnl
17
 
dnl   You should have received a copy of the GNU General Public Licence
18
 
dnl   along with the Code_Saturne Preprocessor; if not, write to the
19
 
dnl   Free Software Foundation, Inc.,
20
 
dnl   51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21
 
dnl-----------------------------------------------------------------------------
22
 
 
23
 
# CS_AC_TEST_MPI
24
 
#---------------
25
 
# optional MPI support (use CC=mpicc with configure if necessary)
26
 
# modifies or sets cs_have_mpi, MPI_CPPFLAGS, MPI_LDFLAGS, and MPI_LIBS
27
 
# depending on libraries found
28
 
 
29
 
AC_DEFUN([CS_AC_TEST_MPI], [
30
 
 
31
 
saved_CPPFLAGS="$CPPFLAGS"
32
 
saved_LDFLAGS="$LDFLAGS"
33
 
saved_LIBS="$LIBS"
34
 
 
35
 
cs_have_mpi=no
36
 
cs_have_mpi_header=no
37
 
 
38
 
AC_ARG_WITH(mpi,
39
 
            [AS_HELP_STRING([--with-mpi=PATH],
40
 
                            [specify prefix directory for MPI])],
41
 
            [if test "x$withval" = "x"; then
42
 
               with_mpi=yes
43
 
             fi],
44
 
            [with_mpi=check])
45
 
 
46
 
AC_ARG_WITH(mpi-exec,
47
 
            [AS_HELP_STRING([--with-mpi-exec=PATH],
48
 
                            [specify prefix directory for MPI executables])],
49
 
            [if test "x$with_mpi" = "xcheck"; then
50
 
               with_mpi=yes
51
 
             fi
52
 
             mpi_bindir="$with_mpi_exec"],
53
 
            [if test "x$with_mpi" != "xno" -a "x$with_mpi" != "xyes" \
54
 
                  -a "x$with_mpi" != "xcheck"; then
55
 
               mpi_bindir="$with_mpi/bin"
56
 
             fi])
57
 
 
58
 
AC_ARG_WITH(mpi-include,
59
 
            [AS_HELP_STRING([--with-mpi-include=PATH],
60
 
                            [specify directory for MPI include files])],
61
 
            [if test "x$with_mpi" = "xcheck"; then
62
 
               with_mpi=yes
63
 
             fi
64
 
             MPI_CPPFLAGS="-I$with_mpi_include"],
65
 
            [if test "x$with_mpi" != "xno" -a "x$with_mpi" != "xyes" \
66
 
                  -a "x$with_mpi" != "xcheck"; then
67
 
               MPI_CPPFLAGS="-I$with_mpi/include"
68
 
             fi])
69
 
 
70
 
AC_ARG_WITH(mpi-lib,
71
 
            [AS_HELP_STRING([--with-mpi-lib=PATH],
72
 
                            [specify directory for MPI library])],
73
 
            [if test "x$with_mpi" = "xcheck"; then
74
 
               with_mpi=yes
75
 
             fi
76
 
             MPI_LDFLAGS="-L$with_mpi_lib"
77
 
             mpi_libdir="$with_mpi_lib"],
78
 
            [if test "x$with_mpi" != "xno" -a "x$with_mpi" != "xyes" \
79
 
                  -a "x$with_mpi" != "xcheck"; then
80
 
               MPI_LDFLAGS="-L$with_mpi/lib"
81
 
               mpi_libdir="$with_mpi/lib"
82
 
             fi])
83
 
 
84
 
 
85
 
# Just in case, remove excess whitespace from existing flag and libs variables.
86
 
 
87
 
if test "$MPI_CPPFLAGS" != "" ; then
88
 
  MPI_CPPFLAGS=`echo $MPI_CPPFLAGS | sed 's/^[ ]*//;s/[ ]*$//'`
89
 
fi
90
 
if test "$MPI_LDFLAGS" != "" ; then
91
 
  MPI_LDFLAGS=`echo $MPI_LDFLAGS | sed 's/^[ ]*//;s/[ ]*$//'`
92
 
fi
93
 
if test "$MPI_LIBS" != "" ; then
94
 
  MPI_LIBS=`echo $MPI_LIBS | sed 's/^[ ]*//;s/[ ]*$//'`
95
 
fi
96
 
 
97
 
# If we do not use an MPI compiler wrapper, we must add compilation
98
 
# and link flags; we try to detect the correct flags to add.
99
 
 
100
 
if test "x$with_mpi" != "xno" -a "x$cs_have_mpi" = "xno" ; then
101
 
 
102
 
  # try several tests for MPI
103
 
 
104
 
  # MPI Compiler wrapper test
105
 
  AC_MSG_CHECKING([for MPI (MPI compiler wrapper test)])
106
 
  CPPFLAGS="$saved_CPPFLAGS $MPI_CPPFLAGS"
107
 
  LDFLAGS="$saved_LDFLAGS $MPI_LDFLAGS"
108
 
  LIBS="$saved_LIBS $MPI_LIBS"
109
 
  AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <mpi.h>]],
110
 
                 [[ MPI_Init(0, (void *)0); ]])],
111
 
                 [AC_DEFINE([HAVE_MPI], 1, [MPI support])
112
 
                  cs_have_mpi=yes],
113
 
                 [cs_have_mpi=no])
114
 
  AC_MSG_RESULT($cs_have_mpi)
115
 
 
116
 
  # If failed, basic test
117
 
  if test "x$cs_have_mpi" = "xno"; then
118
 
 
119
 
    CPPFLAGS="$saved_CPPFLAGS $MPI_CPPFLAGS"
120
 
 
121
 
    # First, check for mpi.h header
122
 
    AC_CHECK_HEADERS([mpi.h],
123
 
                     [cs_have_mpi_header=yes],
124
 
                     [], 
125
 
                     [])
126
 
 
127
 
    if test $cs_have_mpi_header = no ; then
128
 
      unset ac_cv_header_mpi_h
129
 
      MPI_CPPFLAGS="-I/usr/include/mpi"
130
 
      CPPFLAGS="$saved_CPPFLAGS $MPI_CPPFLAGS"
131
 
      AC_CHECK_HEADERS([mpi.h],
132
 
                       [cs_have_mpi_header=yes],
133
 
                       [], 
134
 
                       [])
135
 
    fi
136
 
 
137
 
    # Basic test
138
 
    AC_MSG_CHECKING([for MPI (basic test)])
139
 
    if test "$MPI_LIBS" = "" ; then
140
 
      MPI_LIBS="-lmpi $PTHREAD_LIBS"
141
 
    fi
142
 
    LDFLAGS="$saved_LDFLAGS $MPI_LDFLAGS"
143
 
    LIBS="$saved_LIBS $MPI_LIBS"
144
 
    AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <mpi.h>]],
145
 
                   [[ MPI_Init(0, (void *)0); ]])],
146
 
                   [AC_DEFINE([HAVE_MPI], 1, [MPI support])
147
 
                    cs_have_mpi=yes],
148
 
                   [cs_have_mpi=no])
149
 
    AC_MSG_RESULT($cs_have_mpi)
150
 
  fi
151
 
 
152
 
  # If failed, test for mpich
153
 
  if test "x$cs_have_mpi" = "xno"; then
154
 
    AC_MSG_CHECKING([for MPI (mpich test)])
155
 
    # First try (simplest)
156
 
    MPI_LIBS="-lmpich $PTHREAD_LIBS"
157
 
    LIBS="$saved_LIBS $MPI_LIBS"
158
 
    AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <mpi.h>]],
159
 
                   [[ MPI_Init(0, (void *)0); ]])],
160
 
                   [AC_DEFINE([HAVE_MPI], 1, [MPI support])
161
 
                    cs_have_mpi=yes],
162
 
                   [cs_have_mpi=no])
163
 
    if test "x$cs_have_mpi" = "xno"; then
164
 
      # Second try (with lpmpich)
165
 
      MPI_LIBS="-Wl,-lpmpich -Wl,-lmpich -Wl,-lpmpich -Wl,-lmpich"
166
 
      LIBS="$saved_LIBS $MPI_LIBS"
167
 
      AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <mpi.h>]],
168
 
                     [[ MPI_Init(0, (void *)0); ]])],
169
 
                     [AC_DEFINE([HAVE_MPI], 1, [MPI support])
170
 
                      cs_have_mpi=yes],
171
 
                     [cs_have_mpi=no])
172
 
    fi
173
 
    AC_MSG_RESULT($cs_have_mpi)
174
 
  fi
175
 
 
176
 
  # If failed, test for lam-mpi
177
 
  if test "x$cs_have_mpi" = "xno"; then
178
 
    AC_MSG_CHECKING([for MPI (lam-mpi test)])
179
 
    # First try (without MPI-IO)
180
 
    case $host_os in
181
 
      freebsd*)
182
 
        MPI_LIBS="-lmpi -llam $PTHREAD_LIBS";;
183
 
      *)
184
 
        MPI_LIBS="-lmpi -llam -lpthread";;
185
 
    esac
186
 
    LIBS="$saved_LIBS $MPI_LIBS"
187
 
    AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <mpi.h>]],
188
 
                   [[ MPI_Init(0, (void *)0); ]])],
189
 
                   [AC_DEFINE([HAVE_MPI], 1, [MPI support])
190
 
                    cs_have_mpi=yes],
191
 
                   [cs_have_mpi=no])
192
 
    if test "x$cs_have_mpi" = "xno"; then
193
 
      # Second try (with MPI-IO)
194
 
      case $host_os in
195
 
        freebsd*)
196
 
          MPI_LIBS="-lmpi -llam -lutil -ldl $PTHREAD_LIBS";;
197
 
        *)
198
 
          MPI_LIBS="-lmpi -llam -lutil -ldl -lpthread";;
199
 
      esac
200
 
      LIBS="$saved_LIBS $MPI_LIBS"
201
 
      AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <mpi.h>]],
202
 
                     [[ MPI_Init(0, (void *)0); ]])],
203
 
                     [AC_DEFINE([HAVE_MPI], 1, [MPI support])
204
 
                      cs_have_mpi=yes],
205
 
                     [cs_have_mpi=no])
206
 
    fi
207
 
    AC_MSG_RESULT($cs_have_mpi)
208
 
  fi
209
 
 
210
 
  if test "x$cs_have_mpi" = "xno"; then
211
 
    if test "x$with_mpi" != "xcheck" ; then
212
 
      AC_MSG_FAILURE([MPI support is requested, but test for MPI failed!])
213
 
    else
214
 
      AC_MSG_WARN([no MPI support])
215
 
    fi
216
 
    MPI_LIBS=""
217
 
  else
218
 
    # Try to detect MPI variants as this may be useful for the run scripts to
219
 
    # determine the correct mpi startup syntax (especially when multiple
220
 
    # librairies are installed on the same machine).
221
 
    CPPFLAGS="$saved_CPPFLAGS $MPI_CPPFLAGS"
222
 
    mpi_type=""
223
 
    if test "x$cs_ibm_bg_type" != "x" ; then
224
 
      if test "x$cs_ibm_bg_type" = "xL" ; then
225
 
        mpi_type=BGL_MPI
226
 
      elif test "x$cs_ibm_bg_type" = "xP" ; then
227
 
        mpi_type=BGP_MPI
228
 
      fi
229
 
    fi
230
 
    if test "x$mpi_type" = "x"; then
231
 
      AC_EGREP_CPP([mpich2],
232
 
                   [
233
 
                    #include <mpi.h>
234
 
                    #ifdef MPICH2
235
 
                    mpich2
236
 
                    #endif
237
 
                    ],
238
 
                    [mpi_type=MPICH2])
239
 
    fi
240
 
    if test "x$mpi_type" = "x"; then
241
 
      AC_EGREP_CPP([ompi],
242
 
                   [
243
 
                    #include <mpi.h>
244
 
                    #ifdef OMPI_MAJOR_VERSION
245
 
                    ompi
246
 
                    #endif
247
 
                    ],
248
 
                    [mpi_type=OpenMPI])
249
 
    fi
250
 
    if test "x$mpi_type" = "x"; then
251
 
      AC_EGREP_CPP([mpibull2],
252
 
                   [
253
 
                    #include <mpi.h>
254
 
                    #ifdef MPIBULL2_NAME
255
 
                    mpibull2
256
 
                    #endif
257
 
                    ],
258
 
                    [mpi_type=MPIBULL2])
259
 
    fi
260
 
    if test "x$mpi_type" = "x"; then
261
 
      AC_EGREP_CPP([lam_mpi],
262
 
                   [
263
 
                    #include <mpi.h>
264
 
                    #ifdef LAM_MPI
265
 
                    lam_mpi
266
 
                    #endif
267
 
                    ],
268
 
                    [mpi_type=LAM_MPI])
269
 
    fi
270
 
    if test "x$mpi_type" = "x"; then
271
 
      AC_EGREP_CPP([hp_mpi],
272
 
                   [
273
 
                    #include <mpi.h>
274
 
                    #ifdef HP_MPI
275
 
                    hp_mpi
276
 
                    #endif
277
 
                    ],
278
 
                    [mpi_type=HP_MPI])
279
 
    fi
280
 
  fi
281
 
 
282
 
  CPPFLAGS="$saved_CPPFLAGS"
283
 
  LDFLAGS="$saved_LDFLAGS"
284
 
  LIBS="$saved_LIBS"
285
 
 
286
 
  unset saved_CPPFLAGS
287
 
  unset saved_LDFLAGS
288
 
  unset saved_LIBS
289
 
 
290
 
fi
291
 
 
292
 
AM_CONDITIONAL(HAVE_MPI, test x$cs_have_mpi = xyes)
293
 
 
294
 
AC_SUBST(MPI_CPPFLAGS)
295
 
AC_SUBST(MPI_LDFLAGS)
296
 
AC_SUBST(MPI_LIBS)
297
 
AC_SUBST(mpi_type)
298
 
AC_SUBST(mpi_bindir)
299
 
AC_SUBST(mpi_libdir)
300
 
 
301
 
])dnl
302