Skip to content
Snippets Groups Projects
Commit dfd0504d authored by Christian Engwer's avatar Christian Engwer
Browse files

mpi-config and dune_mpi.m4 now share the MPI identification code (mpi-config.m4)

[[Imported from SVN: r4623]]
parent dc90148e
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,7 @@ Options:
[--mpiversion]
[--libs]
[--cflags]
EOF
exit $1
}
......@@ -65,213 +66,48 @@ if test x$MPICC == x ; then
MPICC=mpicc
fi
mpi_trybuild () {
$MPICC ${1} > /dev/null 2>&1 || return 1
return 0
}
mpi_preprocess () {
$MPICC -E -c ${1} 2> /dev/null
}
#
# LIB
#
# load mpi-config.m4
#
mpi_getflags () {
# -- call mpiCC, remove compiler name
# compiler-name is first word in line _if_ it doesn't start with a dash!
# needed because mpiCC sometimes does not include compiler (newer LAM)
# Read the modules find part
INCDIR=$(dirname $(readlink --canonicalize $0))
# the additional brackets keep m4 from interpreting the brackets
# in the sed-command...
retval=`$MPICC ${1} ${2} 2>/dev/null | head -1 | sed -e 's/^[^-][^ ]\+ //'`
# remove dummy-parameter (if existing)
if test ${#} = 2 ; then
retval=`echo $retval | sed -e "s/${2}//"`
fi
}
# removes regexp $2 from string $1
mpi_remove () {
retval=`echo ${1} | sed -e "s/${2}//"`
}
msg_checking() {
eval "$(
m4 -I$INCDIR/../m4/ <<EOF
changequote([, ])
define([AC_DEFUN],[define([\$1],[\$2])])
define([AC_MSG_CHECKING],[
if test $verbose -gt 0; then
echo -n "checking $@..."
echo -n "checking \$@..."
fi
}
msg_result() {
])
define([AC_MSG_RESULT],[
if test $verbose -gt 0; then
echo " $@"
fi
}
msg_error() {
echo Error: $@
exit 1
}
test_lam () {
msg_checking for lam
cat >conftest.c <<_EOF
#include <mpi.h>
#include <stdio.h>
#include <lam_config.h>
int main() {
printf ("%i%i\n", LAM_MAJOR_VERSION, LAM_MINOR_VERSION);
return 0;
}
_EOF
if mpi_trybuild "-c conftest.c"; then
# try new -showme:xxx function
mpi_getflags "-showme:compile"
if test x"$retval" != x ; then
# seems like LAM >= 7.1 which supports extraction of parameters without
# dummy files
MPI_VERSION="LAM >= 7.1"
MPI_CPPFLAGS="$retval"
mpi_getflags "-showme:link"
MPI_LDFLAGS="$retval"
else
MPI_VERSION="LAM < 7.1"
# use -showme and dummy parameters to extract flags
mpi_getflags "-showme" "-c $MPISOURCE"
MPI_CPPFLAGS="$retval"
mpi_getflags "-showme" "dummy.o -o dummy"
MPI_LDFLAGS="$retval"
fi
# hack in option to disable LAM-C++-bindings...
# we fake to have mpicxx.h read already
MPI_NOCXXFLAGS="-DMPIPP_H"
msg_result yes
rm -f conftest*
return 0
echo " \$@"
fi
rm -f conftest*
msg_result no
return 1
}
test_mpich () {
msg_checking for mpich
cat >conftest.c <<_EOF
#include <mpi.h>
int main() { return 0; }
_EOF
if (mpi_preprocess conftest.c \
| grep -q MPICHX_PARALLELSOCKETS_PARAMETERS); then
MPI_VERSION="MPICH"
# use special commands to extract options
mpi_getflags "-compile_info"
MPI_CPPFLAGS="$retval"
# remove implicitly set -c
mpi_remove "$MPI_CPPFLAGS" '-c'
MPI_CPPFLAGS="$retval"
mpi_getflags "-link_info"
MPI_LDFLAGS="$retval"
# hack in option to disable MPICH-C++-bindings...
MPI_NOCXXFLAGS="-DMPICH_SKIP_MPICXX"
msg_result yes
rm -f conftest*
return 0
fi
rm -f conftest*
msg_result no
return 1
}
test_openmpi () {
msg_checking for OpenMPI
cat >conftest.c <<_EOF
#include <mpi.h>
int main() { return 0; }
_EOF
if (mpi_preprocess conftest.c | grep -q ompi_communicator_t); then
MPI_VERSION="OpenMPI"
MPI_NOCXXFLAGS="-DMPIPP_H"
msg_result yes
rm -f conftest*
return 0
])
define([AC_MSG_NOTICE],[
if test $verbose -gt 0; then
echo "\$@"
fi
rm -f conftest*
msg_result no
return 1
}
test_ibmmpi() {
msg_checking for IBM MPI
if $MPICC -v -c conftest.c > /dev/null 2>&1; then
mpi_getflags "-v" "-c dummy.c"
if (echo $retval | grep '^xl[cC]'); then
MPI_VERSION="IBM MPI"
# mpCC passes on it's own parameter...
retval=`echo $retval | sed -e "s/-v//"`
# remove compiler name
retval=`echo $retval | sed -e 's/^xl[cC] //'`
# remove stuff we passed
retval=`echo $retval | sed -e "s/-c dummy.c//"`
# get compilation script
# AC_LANG_CASE([C],[
# MPICOMP="$MPICC"
# dune_mpi_isgnu="$GCC"
# ],
# [C++],[
# MPICOMP="$MPICXX"
# dune_mpi_isgnu="$GXX"
# ])
# mpCC assumes xlc is used...
# if test x$dune_mpi_isgnu = xyes ; then
# # change commandline if GNU compiler is used
# retval=`echo $retval | sed -e 's/\(-b[[^ ]]*\)/-Xlinker \1/g'`
# fi
MPI_CPPFLAGS="$retval"
mpi_getflags "-v" "dummy.o -o dummy"
# mpCC passes on it's own parameter...
retval=`echo $retval | sed -e "s/-v//"`
# remove compiler name
retval=`echo $retval | sed -e 's/^xl[cC] //'`
# remove stuff we passed
retval=`echo $retval | sed -e "s/dummy.o -o dummy//"`
# if test x$dune_mpi_isgnu = xyes ; then
# # change commandline if GNU compiler is used
# retval=`echo $retval | sed -e 's/\(-b[[^ ]]*\)/-Xlinker \1/g'`
# fi
MPI_LDFLAGS="$retval"
msg_result yes
rm -f conftest*
return 0
fi
])
define([AC_MSG_ERROR],[
if test $verbose -gt 0; then
echo "Error: \$@"
exit 1
fi
}
get_mpiparameters() {
if test x"$MPI_VERSION" != x; then
return
fi
])
include([mpi-config.m4])
MPI_CONFIG_HELPER
EOF
)"
test_lam && return
test_mpich && return
test_openmpi && return
test_ibmmpi && return
MPI_VERSION="unknown"
msg_error "Could not identify MPI-package! Please send a bugreport and tell us what MPI-package you're using."
}
#
# output methods
#
print_mpiversion() {
get_mpiparameters
......@@ -280,11 +116,10 @@ print_mpiversion() {
print_cflags() {
get_mpiparameters
local CFLAGS="$MPI_CPPFLAGS"
if test x$disablecxx == xyes; then
CFLAGS="$MPI_CPPFLAGS $MPI_NOCXXFLAGS"
MPI_CPPFLAGS="$MPI_CPPFLAGS $MPI_NOCXXFLAGS"
fi
echo $CFLAGS
echo $MPI_CPPFLAGS
}
print_libs() {
......
......@@ -75,29 +75,6 @@ AC_DEFUN([DUNE_MPI],[
with_mpi="no"
# //
# helper shell functions
# somehow variables like $1, $2 seem to disappear after m4... Quote them...
dune_mpi_getflags () {
# -- call mpiCC, remove compiler name
# compiler-name is first word in line _if_ it doesn't start with a dash!
# needed because mpiCC sometimes does not include compiler (newer LAM)
# the additional brackets keep m4 from interpreting the brackets
# in the sed-command...
retval=[`$MPICOMP ${1} ${2} 2>/dev/null | head -1 | sed -e 's/^[^-][^ ]\+ //'`]
# remove dummy-parameter (if existing)
if test ${#} = 2 ; then
retval=`echo $retval | sed -e "s/${2}//"`
fi
}
# removes regexp $2 from string $1
dune_mpi_remove () {
retval=`echo ${1} | sed -e "s/${2}//"`
}
# //
# 1) no paramter : ''
# => use ACX_MPI to find the mpi Compiler
# 2) --with-mpi=/opt/special-mpi/bin/mpicc : '/opt/special-mpi/bin/mpicc'
......@@ -139,98 +116,11 @@ AC_DEFUN([DUNE_MPI],[
# taken from acx_mpi: test succeeded if MPILIBS is not empty
if test x != x"$MPICOMP" ; then
MPICC="$MPICOMP"
MPI_CONFIG()
MPI_CPPFLAGS="$MPI_CPPFLAGS $MPI_NOCXXFLAGS"
AC_MSG_CHECKING([for a known MPI package])
# the LAM mpiCC knows a -showme parameter
dune_mpi_getflags "-showme"
if test x"$retval" != x ; then
with_mpi="LAM"
# try new -showme:xxx function
dune_mpi_getflags "-showme:compile"
if test x"$retval" != x ; then
# seems like LAM >= 7.1 which supports extraction of parameters without
# dummy files
AC_MSG_RESULT([LAM >= 7.1])
MPI_CPPFLAGS="$retval"
dune_mpi_getflags "-showme:link"
MPI_LDFLAGS="$retval"
else
AC_MSG_RESULT([LAM <= 7.0])
# use -showme and dummy parameters to extract flags
AC_LANG_CASE([C], [MPISOURCE="dummy.c"],
[C++], [MPISOURCE="dummy.cc"])
dune_mpi_getflags "-showme" "-c $MPISOURCE"
MPI_CPPFLAGS="$retval"
dune_mpi_getflags "-showme" "dummy.o -o dummy"
MPI_LDFLAGS="$retval"
fi
# hack in option to disable MPICH-C++-bindings...
# we fake to have mpicxx.h read already
MPI_CPPFLAGS="$MPI_CPPFLAGS -DMPIPP_H"
else
# the MPICH mpiCC knows a -show parameter
dune_mpi_getflags "-show"
if test x"$retval" != x ; then
with_mpi="MPICH"
# use special commands to extract options
dune_mpi_getflags "-compile_info"
MPI_CPPFLAGS="$retval"
# hack in option to disable MPICH-C++-bindings...
MPI_CPPFLAGS="$MPI_CPPFLAGS -DMPICH_SKIP_MPICXX"
# remove implicitly set -c
dune_mpi_remove "$MPI_CPPFLAGS" '-c'
MPI_CPPFLAGS="$retval"
dune_mpi_getflags "-link_info"
MPI_LDFLAGS="$retval"
AC_MSG_RESULT([MPICH])
else
# check exitcode of -v
if $MPICOMP -v -c $MPISOURCE > /dev/null 2>&1 ; then
AC_MSG_RESULT([IBM MPI])
with_mpi="IBM MPI"
dune_mpi_getflags "-v" "-c dummy.c"
# mpCC passes on it's own parameter...
retval=`echo $retval | sed -e "s/-v//"`
# remove compiler name (double bracket to quote for m4)
retval=`echo $retval | sed -e 's/^xl[[cC]] //'`
# remove stuff we passed
retval=`echo $retval | sed -e "s/-c dummy.c//"`
# mpCC assumes xlc is used...
if test x$dune_mpi_isgnu = xyes ; then
# change commandline if GNU compiler is used
retval=`echo $retval | sed -e 's/\(-b[[^ ]]*\)/-Xlinker \1/g'`
fi
MPI_CPPFLAGS="$retval"
dune_mpi_getflags "-v" "dummy.o -o dummy"
# mpCC passes on it's own parameter...
retval=`echo $retval | sed -e "s/-v//"`
# remove compiler name
retval=`echo $retval | sed -e 's/^xl[[cC]] //'`
# remove stuff we passed
retval=`echo $retval | sed -e "s/dummy.o -o dummy//"`
if test x$dune_mpi_isgnu = xyes ; then
# change commandline if GNU compiler is used
retval=`echo $retval | sed -e 's/\(-b[[^ ]]*\)/-Xlinker \1/g'`
fi
MPI_LDFLAGS="$retval"
else
# don't know MPI....
AC_MSG_RESULT([unknown])
fi
fi
fi
# fallback... can't extract flags :(
if test x"$with_mpi" = xno ; then
AC_MSG_WARN([Could not identify MPI-package! Please send a bugreport and tell us what MPI-package you're using])
fi
with_mpi="yes ($MPI_VERSION)"
else
# ACX_MPI didn't find anything
with_mpi="no"
......
AC_DEFUN([MPI_CONFIG_HELPER],[
mpi_trybuild () {
$MPICC ${1} > /dev/null 2>&1 || return 1
return 0
}
mpi_preprocess () {
$MPICC -E -c ${1} 2> /dev/null
}
mpi_getflags () {
# -- call mpiCC, remove compiler name
# compiler-name is first word in line _if_ it doesn't start with a dash!
# needed because mpiCC sometimes does not include compiler (newer LAM)
# the additional brackets keep m4 from interpreting the brackets
# in the sed-command...
retval=`$MPICC ${1} ${2} 2>/dev/null | head -1`
# remove compiler name
retval=`echo $retval | sed -e 's/^[[^-]][[^ ]]\+ //'`
# remove dummy-parameter (if existing)
retval=`echo $retval | sed -e "s/${1}//"`
if test ${#} = 2 ; then
retval=`echo $retval | sed -e "s/${2}//"`
fi
}
# removes regexp $2 from string $1
mpi_remove () {
retval=`echo ${1} | sed -e "s/${2}//"`
}
test_lam () {
AC_MSG_CHECKING([for lam])
cat >conftest.c <<_EOF
#include <mpi.h>
#include <stdio.h>
#include <lam_config.h>
int main() {
printf ("%i%i\n", LAM_MAJOR_VERSION, LAM_MINOR_VERSION);
return 0;
}
_EOF
if mpi_trybuild "-c conftest.c"; then
# try new -showme:xxx function
mpi_getflags "-showme:compile"
if test x"$retval" != x ; then
# seems like LAM >= 7.1 which supports extraction of parameters without
# dummy files
MPI_VERSION="LAM >= 7.1"
MPI_CPPFLAGS="$retval"
mpi_getflags "-showme:link"
MPI_LDFLAGS="$retval"
else
MPI_VERSION="LAM < 7.1"
# use -showme and dummy parameters to extract flags
mpi_getflags "-showme" "-c $MPISOURCE"
MPI_CPPFLAGS="$retval"
mpi_getflags "-showme" "dummy.o -o dummy"
MPI_LDFLAGS="$retval"
fi
# hack in option to disable LAM-C++-bindings...
# we fake to have mpicxx.h read already
MPI_NOCXXFLAGS="-DMPIPP_H"
AC_MSG_RESULT([yes])
rm -f conftest*
return 0
fi
rm -f conftest*
AC_MSG_RESULT([no])
return 1
}
test_mpich () {
AC_MSG_CHECKING([for mpich])
cat >conftest.c <<_EOF
#include <mpi.h>
int main() { return 0; }
_EOF
if (mpi_preprocess conftest.c \
| grep -q MPICHX_PARALLELSOCKETS_PARAMETERS); then
MPI_VERSION="MPICH"
# use special commands to extract options
mpi_getflags "-compile_info"
MPI_CPPFLAGS="$retval"
# remove implicitly set -c
mpi_remove "$MPI_CPPFLAGS" '-c'
MPI_CPPFLAGS="$retval"
mpi_getflags "-link_info"
MPI_LDFLAGS="$retval"
# hack in option to disable MPICH-C++-bindings...
MPI_NOCXXFLAGS="-DMPICH_SKIP_MPICXX"
AC_MSG_RESULT([yes])
rm -f conftest*
return 0
fi
rm -f conftest*
AC_MSG_RESULT([no])
return 1
}
test_openmpi () {
AC_MSG_CHECKING([for OpenMPI])
cat >conftest.c <<_EOF
#include <mpi.h>
int main() { return 0; }
_EOF
if (mpi_preprocess conftest.c | grep -q ompi_communicator_t); then
MPI_VERSION="OpenMPI"
MPI_NOCXXFLAGS="-DMPIPP_H"
AC_MSG_RESULT([yes])
rm -f conftest*
return 0
fi
rm -f conftest*
AC_MSG_RESULT([no])
return 1
}
test_ibmmpi() {
AC_MSG_CHECKING([for IBM MPI])
if $MPICC -v -c conftest.c > /dev/null 2>&1; then
mpi_getflags "-v" "-c dummy.c"
if (echo $retval | grep '^xl[[cC]]'); then
MPI_VERSION="IBM MPI"
# get compilation script
# AC_LANG_CASE([C],[
# MPICOMP="$MPICC"
# dune_mpi_isgnu="$GCC"
# ],
# [C++],[
# MPICOMP="$MPICXX"
# dune_mpi_isgnu="$GXX"
# ])
# mpCC assumes xlc is used...
# if test x$dune_mpi_isgnu = xyes ; then
# # change commandline if GNU compiler is used
# retval=`echo $retval | sed -e 's/\(-b[[^ ]]*\)/-Xlinker \1/g'`
# fi
MPI_CPPFLAGS="$retval"
mpi_getflags "-v" "dummy.o -o dummy"
# if test x$dune_mpi_isgnu = xyes ; then
# # change commandline if GNU compiler is used
# retval=`echo $retval | sed -e 's/\(-b[[^ ]]*\)/-Xlinker \1/g'`
# fi
MPI_LDFLAGS="$retval"
AC_MSG_RESULT([yes])
rm -f conftest*
return 0
fi
fi
}
get_mpiparameters() {
AC_MSG_NOTICE([Trying to identify the version of $MPICC])
if test x"$MPI_VERSION" != x; then
return
fi
test_lam && return
test_mpich && return
test_openmpi && return
test_ibmmpi && return
MPI_VERSION="unknown"
AC_MSG_ERROR([Could not identify MPI-package! Please send a bugreport and tell us what MPI-package you're using.])
}
])
AC_DEFUN([MPI_CONFIG],[
AC_REQUIRE([MPI_CONFIG_HELPER])
get_mpiparameters;
])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment