| 1 |
# Checking wether we can produce a parallel version |
| 2 |
# ------------------------------------------------- |
| 3 |
|
| 4 |
dnl m4_include(ax_mpi.m4) |
| 5 |
ff_save_path="$PATH" |
| 6 |
# We need to choose between mpich, openmpi and lam for the Debian package |
| 7 |
AC_ARG_WITH(mpipath,[ --with-mpipath= the path of mpich under windows (no command mpic++, ... )]) |
| 8 |
AC_ARG_WITH(mpilibs,[ --with-mpilibs= the libs to add to c++,fc, ... (to link with c++ - ex: -L/usr/local/lib -lmpi_f90 -lmpi_cxx -lmpi -lopen-rte -lopen-pal -lutil) ]) |
| 9 |
AC_ARG_WITH(mpilibsc,[ --with-mpilibsc= the libs to add to c ... (to link with cc (for pastix lib) ex: -L/usr/local/lib -lmpi -lopen-rte -lopen-pal -lutil) ]) |
| 10 |
AC_ARG_WITH(mpiinc,[ --with-mpiinc= the include directory directive and preprocess directive (no mpicc++, just use the compiler)) ]) |
| 11 |
AC_ARG_WITH(mpi,[ --with-mpi=[yes|no|mpic++|lam|mpich|openmpi|/usr/local/bin/mpic++|... ] or --without-mpi Choose MPI implementation (default is mpic++)]) |
| 12 |
if test "$with_mpi" != no ; then |
| 13 |
#if test "$with_mpi" != no ; then |
| 14 |
#AX_MPI(with_mpi=yes, with_mpi=no) |
| 15 |
#fi |
| 16 |
|
| 17 |
# Default is mpic++ |
| 18 |
ff_mpi_suffix=""; |
| 19 |
if test "$with_mpi" = yes -o -z "$with_mpi" |
| 20 |
then |
| 21 |
ff_mpicxx=mpic++ |
| 22 |
else |
| 23 |
case "$with_mpi" in |
| 24 |
lam|mpich|openmpi) ff_mpi_suffix=.$with_mpi;ff_mpicxx=mpic++.$with_mpi;; |
| 25 |
*) ff_mpicxx="$with_mpi" ;; |
| 26 |
esac |
| 27 |
fi |
| 28 |
|
| 29 |
dnl AC_MSG_NOTICE([ xxxxxxxxxxxxxxxxxxxx --$with_mpilibs--]); |
| 30 |
if test -n "$with_mpiinc" -a "$with_mpiinc" != no ; then |
| 31 |
if test "$with_mpi" = 'no' ; then with_mpi='yes'; fi |
| 32 |
ff_MPI_INCLUDE="$with_mpiinc" |
| 33 |
fi |
| 34 |
if test -n "$with_mpilibs" -a "$with_mpilibs" != no ; then |
| 35 |
ff_MPI_LIB="$with_mpilibs" |
| 36 |
ff_MPI_LIBC="$with_mpilibs" |
| 37 |
ff_MPI_LIBFC="$with_mpilibs" |
| 38 |
MPICXX="$CXX $ff_MPI_INCLUDE" |
| 39 |
MPIFC="$FC $ff_MPI_INCLUDE" |
| 40 |
MPICC="$CC $ff_MPI_INCLUDE" |
| 41 |
AC_MSG_NOTICE([ --- set all MPI compile to compiler: $MPICC, $MPIFC, $MPICC ]) |
| 42 |
fi |
| 43 |
|
| 44 |
if test -n "$with_mpilibsc" -a "$with_mpilibsc" != no ; then |
| 45 |
ff_MPI_LIBC="$with_mpilibsc" |
| 46 |
fi |
| 47 |
|
| 48 |
AC_ARG_VAR(MPIRUN,[MPI run command ]) |
| 49 |
AC_MSG_CHECKING(for MPIRUN) |
| 50 |
|
| 51 |
if test -z "$MPIRUN" ; then |
| 52 |
if test -n "$MSMPI_BIN" -a -x "$MSMPI_BIN/mpiexec.exe" ; then |
| 53 |
MPIRUN="$MSMPI_BIN"\mpiexec.exe |
| 54 |
else |
| 55 |
AC_PATH_PROGS(MPIRUN,mpiexec mpirun mpiexec.exe,no) |
| 56 |
fi |
| 57 |
if test "$MPIRUN" = no |
| 58 |
then |
| 59 |
ff_mpi=no |
| 60 |
fi |
| 61 |
fi |
| 62 |
AC_MSG_RESULT($MPIRUN) |
| 63 |
if test "ff_mpi" != "no" ; then |
| 64 |
AC_MSG_CHECKING(for MPIRUN option: ) |
| 65 |
ff_mpi_option="" |
| 66 |
ff_okkk=`"$MPIRUN" -np 2 --oversubscribe echo ff__okkk 2>/dev/null| grep ff__okkk |wc -l` |
| 67 |
if test "$ff_okkk" -eq 2 ; then ff_mpi_option="--oversubscribe" ; fi |
| 68 |
ff_okkk=`"$MPIRUN" -np 1 --timeout=60 echo ff__okkk 2>/dev/null| grep ff__okkk |wc -l` |
| 69 |
if test "$ff_okkk" -eq 1 ; then ff_mpi_option="$ff_mpi_option --timeout=60" ; fi |
| 70 |
AC_MSG_RESULT($ff_mpi_option) |
| 71 |
fi |
| 72 |
|
| 73 |
AC_MSG_CHECKING(for mpipath ) |
| 74 |
|
| 75 |
if test "$with_mpi" != no -a ! -d "$with_mpipath" -a "$MPIRUN" != no ; then |
| 76 |
# if "$MPIRUN" != no ; tehn |
| 77 |
with_mpipath=`AS_DIRNAME(["$MPIRUN"])` |
| 78 |
with_mpipath=`AS_DIRNAME(["$with_mpipath"])` |
| 79 |
# echo " ***** with_mpipath $with_mpipath \n" |
| 80 |
|
| 81 |
# else |
| 82 |
# for i in '/c/Program Files (x86)/MPICH2' '/c/Program Files/MPICH2' 'c:\Program Files (x86)\MPICH2' 'c:\Program Files\MPICH2' ; do |
| 83 |
# test -d "$i" && with_mpipath="$i" && break |
| 84 |
# done |
| 85 |
# fi |
| 86 |
fi |
| 87 |
#echo "**** with_mpipath '$with_mpipath' $MPIRUN *****" |
| 88 |
dnl if test "$with_mpilibs" != "no" ; then |
| 89 |
dnl fi |
| 90 |
case "$MPIRUN" in |
| 91 |
*/sgi/mpt/*) |
| 92 |
ff_MPI_INCLUDE_DIR= |
| 93 |
ff_MPI_LIB_DIR= |
| 94 |
test -f "$with_mpipath/include/mpif.h" && ff_MPI_INCLUDE_DIR="$with_mpipath/include" |
| 95 |
test -f "$with_mpipath/lib/libmpi.so" && ff_MPI_LIB_DIR="$with_mpipath/lib" |
| 96 |
if test -n "$ff_MPI_INCLUDE_DIR" -a -n "$ff_MPI_LIB_DIR" ; then |
| 97 |
ff_MPI_INCLUDE="-I'$ff_MPI_INCLUDE_DIR' " |
| 98 |
with_mpiinc="$ff_MPI_INCLUDE" |
| 99 |
ff_MPI_LIBC="-L'$ff_MPI_LIB_DIR' -lmpi" |
| 100 |
ff_MPI_LIB="-L'$ff_MPI_LIB_DIR' -lmpi++ -lmpi" |
| 101 |
ff_MPI_LIBFC="-L'$ff_MPI_LIB_DIR' -lmpi" |
| 102 |
ff_mpitype=sgi |
| 103 |
test -z "$MPICXX" && MPICXX="$CXX $ff_MPI_INCLUDE" |
| 104 |
test -z "$MPIFC" && MPIFC="$FC $ff_MPI_INCLUDE" |
| 105 |
test -z "$MPICC" && MPICC="$CC $ff_MPI_INCLUDE" |
| 106 |
# echo " *** MPI sgi ..... " |
| 107 |
fi |
| 108 |
;; |
| 109 |
esac |
| 110 |
|
| 111 |
|
| 112 |
AC_MSG_RESULT($ff_mpi_path) |
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
dnl correct ff_mpi_path august 2010 -- FH ... |
| 118 |
|
| 119 |
|
| 120 |
ff_save_cxx="$CXX" |
| 121 |
ff_save_libs="$LIBS" |
| 122 |
|
| 123 |
|
| 124 |
if test "$with_mpi" != no |
| 125 |
then |
| 126 |
ff_mpi_path=`AS_DIRNAME(["$MPIRUN"])` |
| 127 |
dnl echo "ff_mpi_path '$ff_mpi_path' .............." |
| 128 |
case "$ff_mpi_path" in |
| 129 |
.|"") ff_mpi_path="$PATH";ff_defmpicxx="$ff_mpicxx";; |
| 130 |
*) ff_mpi_path="$ff_mpi_path";ff_defmpicxx=`expr "//$ff_mpicxx" : '.*/\(.*\)'`;; |
| 131 |
dnl if also add $PATH they could be missing some different mpi version... |
| 132 |
esac |
| 133 |
AC_ARG_VAR(MPICXX,[MPI C++ compiler command]) |
| 134 |
if test -z "$MPICXX" ; then |
| 135 |
AC_PATH_PROGS(MPICXX,$ff_defmpicxx mpic++$ff_mpi_suffix mpicxx$ff_mpi_suffix mpiCC$ff_mpi_suffix mpCC hcp mpxlC mpxlC_r cmpic++,no,$ff_mpi_path) |
| 136 |
AC_MSG_CHECKING(for MPICXX) |
| 137 |
fi |
| 138 |
ff_mpicxx="eval $MPICXX" |
| 139 |
CXX=$ff_mpicxx |
| 140 |
LIBS="$LIBS $ff_MPI_LIB" |
| 141 |
test -z "$ff_mpi" && ff_mpi=yes |
| 142 |
AC_LINK_IFELSE( |
| 143 |
[AC_LANG_SOURCE([ |
| 144 |
#include <mpi.h> |
| 145 |
#include <stdio.h> |
| 146 |
int main(int argc,char **argv){ |
| 147 |
char name[[BUFSIZ]]; |
| 148 |
int length; |
| 149 |
|
| 150 |
MPI_Init(&argc, &argv); |
| 151 |
MPI_Get_processor_name(name, &length); |
| 152 |
printf("%s: hello world\n", name); |
| 153 |
MPI_Finalize(); |
| 154 |
return 0; |
| 155 |
}])],ff_mpi=yes,ff_mpi=no) |
| 156 |
AC_MSG_RESULT($ff_mpi) |
| 157 |
|
| 158 |
# Also check that mpirun is there. If it isn't, then MPI is |
| 159 |
# not fully installed. |
| 160 |
|
| 161 |
|
| 162 |
if test "$ff_mpi" = yes; |
| 163 |
then |
| 164 |
|
| 165 |
AC_MSG_CHECKING( MPI_DOUBLE_COMPLEX) |
| 166 |
|
| 167 |
AC_COMPILE_IFELSE( |
| 168 |
[AC_LANG_SOURCE([ |
| 169 |
#include <mpi.h> |
| 170 |
MPI_Datatype xxxx=MPI_DOUBLE_COMPLEX; |
| 171 |
])], |
| 172 |
ff_mpi_double_complex=yes, |
| 173 |
ff_mpi_double_complex=no) |
| 174 |
AC_MSG_RESULT($ff_mpi_double_complex) |
| 175 |
if test "$ff_mpi_double_complex" = yes ; then |
| 176 |
AC_DEFINE(HAVE_MPI_DOUBLE_COMPLEX,1, mpi_double_complex) |
| 177 |
fi |
| 178 |
|
| 179 |
|
| 180 |
echo "MPI CC $ff_mpi" >config_LIB_INFO |
| 181 |
|
| 182 |
# We do not AC_DEFINE any special flag for parallel |
| 183 |
# computation here, because it must only be set when the |
| 184 |
# parallel program is compiled (see src/mpi/Makfile.am) |
| 185 |
ff_mpiprog="FreeFem++-mpi${EXEEXT}" |
| 186 |
AC_SUBST(MPIPROG,"$ff_mpiprog") |
| 187 |
AC_SUBST(MPISCRIPT,"ff-mpirun") |
| 188 |
AC_SUBST(MPIRUN,"$MPIRUN") |
| 189 |
AC_SUBST(MPICXX,$MPICXX) |
| 190 |
else |
| 191 |
AC_SUBST(MPICXX,$ff_save_cxx) |
| 192 |
fi |
| 193 |
|
| 194 |
if test "$ff_mpi" = yes; |
| 195 |
then |
| 196 |
if test "$enable_fortran" != no |
| 197 |
then |
| 198 |
|
| 199 |
AC_ARG_VAR(MPIFC,[MPI Fortran 90 compiler command]) |
| 200 |
if test -z "$MPIFC" ; then |
| 201 |
AC_PATH_PROGS(MPIFC, mpif90$ff_mpi_suffix mpxlf95_r mpxlf90_r mpxlf95 mpxlf90 mpf90 cmpif90c, "",$ff_mpi_path) |
| 202 |
fi |
| 203 |
AC_SUBST(MPIFC) |
| 204 |
fi |
| 205 |
|
| 206 |
# echo " ********************ffmpi= '$ff_mpi' ************* " |
| 207 |
ff_MPI_INCLUDE="$with_mpiinc" |
| 208 |
if test -z "$ff_mpitype" ; then |
| 209 |
test -n "$MPICXX" && ff_mpishow=`$MPICXX -show` 2>/dev/null |
| 210 |
test -n "$MPICC" && ff_mpicshow=`$MPICC -show` 2>/dev/null |
| 211 |
test -n "$MPIFC" && ff_mpifcshow=`$MPIFC -show` 2>/dev/null |
| 212 |
if test "$with_mpiinc" = no -o -z "$with_mpiinc" ; then |
| 213 |
[ff_MPI_INCLUDE=`echo $ff_mpishow|tr ' ' '\n' | sed '1 d'| grep -E '^[-/][^WLlOgpf]|^-Wp,'|tr '\n' ' '`] |
| 214 |
[ff_mpi_idir=`echo $ff_mpishow|tr ' ' '\n'| grep -E '^-I'|sed s/^-I//|tr '\n' ' '`' /usr/include'] |
| 215 |
else |
| 216 |
[ff_mpi_idir=`echo $ff_MPI_INCLUDE|tr ' ' '\n'| grep -E '^-I'|sed s/^-I//|tr '\n' ' '`' /usr/include'] |
| 217 |
fi |
| 218 |
if test "$with_mpilibs" = no -o -z "$with_mpilibs" ; then |
| 219 |
ff_MPI_LIB_DIRS="" |
| 220 |
[ff_MPI_LIB=`echo $ff_mpishow|tr ' ' '\n'| grep -E '^-[Llp]|^-Wl,'|tr '\n' ' '`] |
| 221 |
[ff_MPI_LIBC=`echo $ff_mpicshow|tr ' ' '\n'| grep -E '^-[Llp]|^-Wl,'|tr '\n' ' '`] |
| 222 |
[ff_MPI_LIBFC=`echo $ff_mpifcshow|tr ' ' '\n'| grep -E '^-[Llp]|^-Wl,'|grep -v 'commons,use_dylibs' |tr '\n' ' '`] |
| 223 |
else |
| 224 |
ff_MPI_LIB="$with_mpilibs" |
| 225 |
ff_MPI_LIBC="$with_mpilibs" |
| 226 |
ff_MPI_LIBFC="$with_mpilibs" |
| 227 |
fi |
| 228 |
[ff_mpi_ldir=`echo $ff_MPI_LIB|tr ' ' '\n'| grep -E '^-[Llp]|^-Wl,'|sed -e 's/^-[Llp]//' -e 's/^-Wl,]//' |tr '\n' ' '`' /usr/lib'] |
| 229 |
|
| 230 |
if test -z "$ff_MPI_INCLUDE_DIR" ; then |
| 231 |
for i in $ff_mpi_idir; do |
| 232 |
if test -f "$i/mpi.h" -a -z "$ff_MPI_INCLUDE_DIR" ;then |
| 233 |
ff_MPI_INCLUDE_DIR=$i |
| 234 |
fi |
| 235 |
done |
| 236 |
fi |
| 237 |
for i in $ff_mpi_ldir; do |
| 238 |
if test -d $i ; then |
| 239 |
ff_tmp=`ls $i/libmpi.*|head -1` |
| 240 |
if test -f "$ff_tmp" -a -z "$ff_MPI_LIB_DIRS" ;then |
| 241 |
ff_MPI_LIB_DIRS=$i |
| 242 |
fi |
| 243 |
fi |
| 244 |
done |
| 245 |
fi |
| 246 |
AC_SUBST(MPICXX,$MPICXX) |
| 247 |
AC_ARG_VAR(MPICC,[MPI C compiler command in $ff_mpi_path]) |
| 248 |
if test -z "$MPICC" ; then |
| 249 |
AC_PATH_PROGS(MPICC,mpicc$ff_mpi_suffix hcc mpcc mpcc_r mpxlc cmpicc, "",$ff_mpi_path) |
| 250 |
fi |
| 251 |
AC_SUBST(MPICC,$MPICC) |
| 252 |
|
| 253 |
if test ! -f "$ff_MPI_INCLUDE_DIR/mpif.h" ; then |
| 254 |
AC_MSG_NOTICE([ MPI without fortran no file "$ff_MPI_INCLUDE_DIR/mpif.h" ]) |
| 255 |
else |
| 256 |
if test -n "$MPIFC" ; then |
| 257 |
AC_FF_ADDWHERELIB(mpifc,$ff_MPI_LIBFC,$ff_MPI_INCLUDE) |
| 258 |
AC_FF_ADDWHERELIB(mpif77,$ff_MPI_LIBFC,$ff_MPI_INCLUDE) |
| 259 |
dnl [echo mpifc LD "'$ff_MPI_LIBFC'" >>$ff_where_lib_conf ] |
| 260 |
dnl [echo mpifc INCLUDE "'$ff_MPI_INCLUDE'" >>$ff_where_lib_conf ] |
| 261 |
dnl [echo mpif77 LD "'$ff_MPI_LIBFC'" >>$ff_where_lib_conf ] |
| 262 |
dnl [echo mpif77 INCLUDE "'$ff_MPI_INCLUDE'" >>$ff_where_lib_conf ] |
| 263 |
fi |
| 264 |
fi |
| 265 |
if test -n "$MPICXX" ; then |
| 266 |
AC_FF_ADDWHERELIB(mpi,$ff_MPI_LIB,$ff_MPI_INCLUDE) |
| 267 |
dnl [echo mpi LD "'$ff_MPI_LIB'" >>$ff_where_lib_conf ] |
| 268 |
dnl [echo mpi INCLUDE "'$ff_MPI_INCLUDE'" >>$ff_where_lib_conf ] |
| 269 |
fi |
| 270 |
AC_SUBST(MPI_INC_DIR,$ff_MPI_INCLUDE_DIR) |
| 271 |
AC_SUBST(MPI_INCLUDE,$ff_MPI_INCLUDE) |
| 272 |
AC_SUBST(MPI_LIB_DIRS,$ff_MPI_LIB_DIRS) |
| 273 |
AC_SUBST(MPI_LIB,$ff_MPI_LIB) |
| 274 |
AC_SUBST(MPI_LIBC,$ff_MPI_LIBC) |
| 275 |
AC_SUBST(MPI_LIBFC,$ff_MPI_LIBFC) |
| 276 |
AC_SUBST(MPI_RUN_OPTION,$ff_mpi_option) |
| 277 |
AC_SUBST(SKIP_TESTS_MPI,"no") |
| 278 |
fi |
| 279 |
CXX="$ff_save_cxx" |
| 280 |
LIBS="$ff_save_libs" |
| 281 |
fi |
| 282 |
fi |
| 283 |
## clean on MPI variable if not MPI ... |
| 284 |
if test "$ff_mpi" != yes ; then |
| 285 |
|
| 286 |
AC_SUBST(MPIRUN,"") |
| 287 |
AC_SUBST(MPICC,"") |
| 288 |
AC_SUBST(MPICXX,"") |
| 289 |
AC_SUBST(MPIFC,"") |
| 290 |
AC_SUBST(MPI_INCLUDE,"") |
| 291 |
AC_SUBST(MPI_LIB_DIRS,"") |
| 292 |
AC_SUBST(MPI_LIB,"") |
| 293 |
AC_SUBST(MPI_LIBC,"") |
| 294 |
AC_SUBST(MPI_LIBFC,"") |
| 295 |
AC_SUBST(SKIP_TESTS_MPI,"yes") |
| 296 |
ff_mpi=no |
| 297 |
dnl AC_MSG_ERROR([ Sorry nompi compiler !]) |
| 298 |
fi |
| 299 |
|
| 300 |
# Local Variables: |
| 301 |
# mode:shell-script |
| 302 |
# ispell-local-dictionary:"british" |
| 303 |
# coding:utf-8 |
| 304 |
# End: |