1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476
|
dnl--------------------------------------------------------------------------------
dnl
dnl This file is part of Code_Saturne, a general-purpose CFD tool.
dnl
dnl Copyright (C) 1998-2019 EDF S.A.
dnl
dnl This program is free software; you can redistribute it and/or modify it under
dnl the terms of the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any later
dnl version.
dnl
dnl This program is distributed in the hope that it will be useful, but WITHOUT
dnl ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
dnl FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
dnl details.
dnl
dnl You should have received a copy of the GNU General Public License along with
dnl this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
dnl Street, Fifth Floor, Boston, MA 02110-1301, USA.
dnl
dnl--------------------------------------------------------------------------------
# CS_AC_TEST_MPI
#---------------
# optional MPI support (use CC=mpicc with configure if necessary)
# modifies or sets cs_have_mpi, MPI_CPPFLAGS, MPI_LDFLAGS, and MPI_LIBS
# depending on libraries found
AC_DEFUN([CS_AC_TEST_MPI], [
cs_have_mpi=no
cs_have_mpi_header=no
cs_have_mpi_io=no
cs_have_mpi_one_sided=no
cs_have_mpi_neighbor_coll=no
cs_have_mpi_ibarrier=no
mpi_prefix=""
AC_ARG_ENABLE(mpi-io,
[AS_HELP_STRING([--disable-mpi-io], [do not use MPI I/O when available])],
[
case "${enableval}" in
yes) mpi_io=true ;;
no) mpi_io=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-mpi-io]) ;;
esac
],
[ mpi_io=true ]
)
AC_ARG_WITH(mpi,
[AS_HELP_STRING([--with-mpi=PATH],
[specify prefix directory for MPI])],
[if test "x$withval" = "x"; then
with_mpi=yes
fi],
[with_mpi=check])
AC_ARG_WITH(mpi-exec,
[AS_HELP_STRING([--with-mpi-exec=PATH],
[specify prefix directory for MPI executables])],
[if test "x$with_mpi" = "xcheck"; then
with_mpi=yes
fi
mpi_bindir="$with_mpi_exec"],
[if test "x$with_mpi" != "xno" -a "x$with_mpi" != "xyes" \
-a "x$with_mpi" != "xcheck"; then
mpi_bindir="$with_mpi/bin"
fi])
AC_ARG_WITH(mpi-include,
[AS_HELP_STRING([--with-mpi-include=PATH],
[specify directory for MPI include files])],
[if test "x$with_mpi" = "xcheck"; then
with_mpi=yes
fi
MPI_CPPFLAGS="-I$with_mpi_include"],
mpi_includedir="$with_mpi_include"
[if test "x$with_mpi" != "xno" -a "x$with_mpi" != "xyes" \
-a "x$with_mpi" != "xcheck"; then
MPI_CPPFLAGS="-I$with_mpi/include"
mpi_includedir="$with_mpi/include"
fi])
AC_ARG_WITH(mpi-lib,
[AS_HELP_STRING([--with-mpi-lib=PATH],
[specify directory for MPI library])],
[if test "x$with_mpi" = "xcheck"; then
with_mpi=yes
fi
MPI_LDFLAGS="-L$with_mpi_lib"
mpi_libdir="$with_mpi_lib"],
[if test "x$with_mpi" != "xno" -a "x$with_mpi" != "xyes" \
-a "x$with_mpi" != "xcheck"; then
MPI_LDFLAGS="-L$with_mpi/lib"
mpi_libdir="$with_mpi/lib"
fi])
# Just in case, remove excess whitespace from existing flag and libs variables.
if test "$MPI_CPPFLAGS" != "" ; then
MPI_CPPFLAGS=`echo $MPI_CPPFLAGS | sed 's/^[ ]*//;s/[ ]*$//'`
fi
if test "$MPI_LDFLAGS" != "" ; then
MPI_LDFLAGS=`echo $MPI_LDFLAGS | sed 's/^[ ]*//;s/[ ]*$//'`
fi
if test "$MPI_LIBS" != "" ; then
MPI_LIBS=`echo $MPI_LIBS | sed 's/^[ ]*//;s/[ ]*$//'`
fi
# If we do not use an MPI compiler wrapper, we must add compilation
# and link flags; we will try to detect the correct flags to add.
# In any case, we will try to determine the type of MPI library
# using mpi.h before running link tests.
if test "x$with_mpi" != "xno" ; then
saved_CPPFLAGS="$CPPFLAGS"
saved_LDFLAGS="$LDFLAGS"
saved_LIBS="$LIBS"
# MPI Compiler wrapper test
AC_MSG_CHECKING([for MPI (MPI compiler wrapper test)])
CPPFLAGS="$saved_CPPFLAGS $MPI_CPPFLAGS"
LDFLAGS="$saved_LDFLAGS $MPI_LDFLAGS"
LIBS="$MPI_LIBS $saved_LIBS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <mpi.h>]],
[[ MPI_Init(0, (void *)0); ]])],
[AC_DEFINE([HAVE_MPI], 1, [MPI support])
cs_have_mpi=yes
cs_have_mpi_header=yes],
[cs_have_mpi=no])
AC_MSG_RESULT($cs_have_mpi)
# If a wrapper was used, try to determine associated install path
# (used to test for variants)
if test "x$cs_have_mpi" = "xyes"; then
if test "x$mpi_includedir" = "x" -o "x$mpi_libdir" = "x" ; then
for arg in `$CC -show`; do
case ${arg} in
-I*)
if test "x$mpi_includedir" = "x";
then
mpi_includedir=`echo ${arg} | sed -e 's/^-I//'`
fi
;;
-L*)
if test "x$mpi_libdir" = "x";
then
mpi_libdir=`echo ${arg} | sed -e 's/^-L//'`
fi
;;
*)
;;
esac
done
fi
# If no wrapper was used, check for mpi.h header
elif test "x$cs_have_mpi" = "xno"; then
CPPFLAGS="$saved_CPPFLAGS $MPI_CPPFLAGS"
AC_CHECK_HEADERS([mpi.h],
[cs_have_mpi_header=yes],
[],
[])
fi
# If no MPI options were given, guess.
if test "x$cs_have_mpi_header" = "xno" ; then
unset ac_cv_header_mpi_h
if test ! -z "$MPI_INCLUDE" ; then
MPI_CPPFLAGS="-I$MPI_INCLUDE"
# Also assume that a similar variable is defined for libraries
MPI_LDFLAGS="-L$MPI_LIB"
else
MPI_CPPFLAGS="-I/usr/include/mpi"
fi
CPPFLAGS="$saved_CPPFLAGS $MPI_CPPFLAGS"
AC_CHECK_HEADERS([mpi.h],
[cs_have_mpi_header=yes],
[],
[])
fi
CPPFLAGS="$saved_CPPFLAGS"
LDFLAGS="$saved_LDFLAGS"
LIBS="$saved_LIBS"
fi
# If no MPI headers are available, no use in pursuing MPI tests.
if test "x$cs_have_mpi_header" = "xyes" ; then
# Now try to determine MPI variants, as this may be useful for the
# run scripts to determine the correct mpi startup syntax
# (especially when multiple librairies are installed on the same machine).
CPPFLAGS="$saved_CPPFLAGS $MPI_CPPFLAGS"
mpi_type=""
if test "x$cs_ibm_bg_type" = "xQ" ; then
mpi_type=BGQ_MPI
fi
if test "x$mpi_type" = "x"; then
AC_EGREP_CPP([cs_msmpi],
[
#include <mpi.h>
#ifdef MSMPI_VER
cs_msmpi
#endif
],
[mpi_type=MSMPI])
fi
if test "x$mpi_type" = "x"; then
AC_EGREP_CPP([cs_mpich],
[
#include <mpi.h>
#ifdef MPICH_NAME
#if (MPICH_NAME >= 3)
cs_mpich
#endif
#endif
],
[mpi_type=MPICH])
fi
if test "x$mpi_type" = "x"; then
AC_EGREP_CPP([cs_mpich2],
[
#include <mpi.h>
#ifdef MPICH2
cs_mpich2
#endif
],
[mpi_type=MPICH2])
fi
if test "x$mpi_type" = "x"; then
AC_EGREP_CPP([cs_ompi],
[
#include <mpi.h>
#ifdef OMPI_MAJOR_VERSION
cs_ompi
#endif
],
[mpi_type=OpenMPI])
fi
if test "x$mpi_type" = "x"; then
AC_EGREP_CPP([cs_mpibull2],
[
#include <mpi.h>
#ifdef MPIBULL2_NAME
cs_mpibull2
#endif
],
[mpi_type=MPIBULL2])
fi
if test "x$mpi_type" = "x"; then
AC_EGREP_CPP([cs_platform_mpi],
[
#include <mpi.h>
#ifdef PLATFORM_MPI
cs_platform_mpi
#endif
],
[mpi_type=Platform_MPI])
fi
# Add a specific preprocessor directive to skip the MPI C++ bindings
case $mpi_type in
OpenMPI) MPI_CPPFLAGS="$MPI_CPPFLAGS -DOMPI_SKIP_MPICXX" ;;
MPICH | MPICH2) MPI_CPPFLAGS="$MPI_CPPFLAGS -DMPICH_SKIP_MPICXX" ;;
esac
# Now try to determine if we are in fact using a variant MPI,
# which does not define its own version macros in mpi.h but still uses its
# own numbering (very ugly, but Intel and Bull do it).
case $mpi_type in
OpenMPI) if test -d "${mpi_libdir}/bullxmpi" ; then
mpi_type=BullxMPI
AC_DEFINE([MPI_VENDOR_NAME], "BullxMPI", [MPI vendor name])
fi
;;
MPICH | MPICH2) cs_mpisupport=""
if test -f "${mpi_libdir}/../mpisupport.txt" ; then
# mpi_libdir may point to lib sudirectory
cs_mpisupport="${mpi_libdir}/../mpisupport.txt"
elif test -f "${mpi_libdir}/../../mpisupport.txt" ; then
# mpi_libdir may point to intel64/lib sudirectory
cs_mpisupport="${mpi_libdir}/../../mpisupport.txt"
fi
if test "x$cs_mpisupport" != "x" ; then
grep "Intel(R) MPI" "$cs_mpisupport" > /dev/null 2>&1
if test $? = 0 ; then
mpi_type=Intel_MPI
AC_DEFINE([MPI_VENDOR_NAME], "Intel MPI", [MPI vendor name])
fi
fi
unset cs_mpisupport
;;
esac
# If only MPI headers have been detected so far (i.e. we are
# not using an MPI compiler wrapper), try to detect MPI libraries.
if test "x$cs_have_mpi" = "xno" ; then
LDFLAGS="$saved_LDFLAGS $MPI_LDFLAGS"
case $mpi_type in
MPICH | MPICH2)
AC_MSG_CHECKING([for MPICH-3 or MPICH2])
# First try (with ROMIO)
case $host_os in
mingw32)
MPI_LIBS="-lmpi";;
freebsd*)
MPI_LIBS="-lmpich -lopa -lmpl -lrt $PTHREAD_LIBS";;
*)
MPI_LIBS="-lmpich -lopa -lmpl -lrt -lpthread";;
esac
LIBS="$MPI_LIBS $saved_LIBS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <mpi.h>]],
[[ MPI_Init(0, (void *)0); ]])],
[AC_DEFINE([HAVE_MPI], 1, [MPI support])
cs_have_mpi=yes],
[cs_have_mpi=no])
if test "x$cs_have_mpi" = "xno"; then
# Second try (without ROMIO)
case $host_os in
freebsd*)
MPI_LIBS="-lmpich -lopa -lmpl $PTHREAD_LIBS";;
*)
MPI_LIBS="-lmpich -lopa -lmpl -lpthread";;
esac
LIBS="$MPI_LIBS $saved_LIBS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <mpi.h>]],
[[ MPI_Init(0, (void *)0); ]])],
[AC_DEFINE([HAVE_MPI], 1, [MPI support])
cs_have_mpi=yes],
[cs_have_mpi=no])
fi
AC_MSG_RESULT($cs_have_mpi)
;;
MSMPI)
AC_MSG_CHECKING([for MSMPI])
case $host_os in
mingw32)
MPI_LIBS="-lmsmpi";;
esac
LIBS="$MPI_LIBS $saved_LIBS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <mpi.h>]],
[[ MPI_Init(0, (void *)0); ]])],
[AC_DEFINE([HAVE_MPI], 1, [MPI support])
cs_have_mpi=yes],
[cs_have_mpi=no])
AC_MSG_RESULT($cs_have_mpi)
;;
*) # General case includes OpenMPI, whose dynamic libraries
# usually make it easy to detect.
AC_MSG_CHECKING([for MPI (basic test)])
if test "$MPI_LIBS" = "" ; then
MPI_LIBS="-lmpi $PTHREAD_LIBS"
fi
LDFLAGS="$saved_LDFLAGS $MPI_LDFLAGS"
LIBS="$MPI_LIBS $saved_LIBS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <mpi.h>]],
[[ MPI_Init(0, (void *)0); ]])],
[AC_DEFINE([HAVE_MPI], 1, [MPI support])
cs_have_mpi=yes],
[cs_have_mpi=no])
AC_MSG_RESULT($cs_have_mpi)
;;
esac
fi
# MPI libraries should now have been detected
if test "x$cs_have_mpi" != "xno"; then
# Try to detect some MPI 2 features
if test "x$mpi_io" = "xtrue"; then
AC_MSG_CHECKING([for MPI I/O])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <mpi.h>]],
[[ MPI_File_close((void *)0); ]])],
[AC_DEFINE([HAVE_MPI_IO], 1, [MPI-IO support])
cs_have_mpi_io=yes],
[cs_have_mpi_io=no])
AC_MSG_RESULT($cs_have_mpi_io)
fi
AC_MSG_CHECKING([for MPI2 one-sided communication])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <mpi.h>]],
[[ MPI_Win_free((void *)0); ]])],
[AC_DEFINE([HAVE_MPI_ONE_SIDED], 1, [MPI one-sided communication])
cs_have_mpi_one_sided=yes],
[cs_have_mpi_one_sided=no])
AC_MSG_RESULT($cs_have_mpi_one_sided)
AC_MSG_CHECKING([for MPI in place])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <mpi.h>]],
[[ MPI_Allreduce(MPI_IN_PLACE, (void *)0, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD); ]])],
[AC_DEFINE([HAVE_MPI_IN_PLACE], 1, [MPI_IN_PLACE support])
have_mpi_in_place=yes],
[have_mpi_in_place=no])
AC_MSG_RESULT($have_mpi_in_place)
# Try to detect some MPI 3 features
AC_MSG_CHECKING([for MPI Neighborhood collectives])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <mpi.h>]],
[[ void *sbuf, *rbuf;
int *scounts, *sdispls, *rcounts, *rdispls;
MPI_Comm comm;
MPI_Neighbor_alltoallv(sbuf, scounts, sdispls, MPI_INT,
rbuf, rcounts, rdispls, MPI_INT,
comm); ]])],
[AC_DEFINE([HAVE_MPI_NEIGHBOR_COLL], 1, [MPI neighborhood collectives])
cs_have_mpi_neighbor_coll=yes],
[cs_have_mpi_neighbor_coll=no])
AC_MSG_RESULT($cs_have_mpi_neighbor_coll)
AC_MSG_CHECKING([for MPI nonblocking barrier])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <mpi.h>]],
[[ MPI_Request r;
MPI_Comm comm;
MPI_Ibarrier(comm, &r); ]])],
[AC_DEFINE([HAVE_MPI_IBARRIER], 1, [MPI nonblocking barrier])
cs_have_mpi_ibarrier=yes],
[cs_have_mpi_ibarrier=no])
AC_MSG_RESULT($cs_have_mpi_ibarrier)
fi
CPPFLAGS="$saved_CPPFLAGS"
LDFLAGS="$saved_LDFLAGS"
LIBS="$saved_LIBS"
unset saved_CPPFLAGS
unset saved_LDFLAGS
unset saved_LIBS
case $host_os in
mingw32)
mpi_prefix=`cygpath --path --windows "$with_mpi"`;;
*)
;;
esac
fi
if test "x$cs_have_mpi" = "xno" -a "x$with_mpi" != "xno"; then
if test "x$with_mpi" != "xcheck" ; then
AC_MSG_FAILURE([MPI support is requested, but test for MPI failed!])
else
AC_MSG_WARN([no MPI support])
fi
MPI_LIBS=""
fi
unset mpi_includedir
AC_SUBST(cs_have_mpi)
AC_SUBST(mpi_prefix, [${mpi_prefix}])
AC_SUBST(MPI_CPPFLAGS)
AC_SUBST(MPI_LDFLAGS)
AC_SUBST(MPI_LIBS)
AC_SUBST(mpi_type)
AC_SUBST(mpi_bindir)
AC_SUBST(mpi_libdir)
])dnl
|