From 8685a7fa7c5ba30a7467ed486132150f349bd7ab Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 2 Nov 1999 22:16:41 -0500 Subject: [svn-r1811] Purpose: New feature configure.in: When just --enable-parallel is used, will try to test if MPI and MPI-IO library codes are linkable. If not, try -lmpi and -lmpio as the most commonly used library names for them. Also, set default value for RUNPARALLEL if not set. Now, for systems, like SGI Crays where there are the system supported MPI libraries, "./configure --enable-parallel" would configure correctly. Configure: Derived from configure.in via autoconf. Platform tested: SGI O2K. --- configure | 173 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- configure.in | 27 +++++++--- 2 files changed, 188 insertions(+), 12 deletions(-) diff --git a/configure b/configure index c1e1b5b..f1d2a8e 100755 --- a/configure +++ b/configure @@ -6711,9 +6711,149 @@ case "X-$enable_parallel" in X-yes) # We want to compile a parallel library with a compiler that - # already knows how to link with MPI and MPI-IO. + # may already know how to link with MPI and MPI-IO. echo "$ac_t""provided by compiler" 1>&6 PARALLEL=yes + + # Try link a simple MPI program. If fail, try again with -lmpi. + cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then + : +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + echo $ac_n "checking for MPI_Init in -lmpi""... $ac_c" 1>&6 +echo "configure:6735: checking for MPI_Init in -lmpi" >&5 +ac_lib_var=`echo mpi'_'MPI_Init | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lmpi $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_lib=HAVE_LIB`echo mpi | sed -e 's/^a-zA-Z0-9_/_/g' \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` + cat >> confdefs.h <&6 +PARALLEL=no +fi + +fi +rm -f conftest* + + # Then try link a simple MPI-IO program. If fail, try again with + # -lmpio. + if test "yes" = "$PARALLEL"; then + cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then + : +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + echo $ac_n "checking for MPI_File_open in -lmpio""... $ac_c" 1>&6 +echo "configure:6803: checking for MPI_File_open in -lmpio" >&5 +ac_lib_var=`echo mpio'_'MPI_File_open | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lmpio $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_lib=HAVE_LIB`echo mpio | sed -e 's/^a-zA-Z0-9_/_/g' \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` + cat >> confdefs.h <&6 +PARALLEL=no +fi + +fi +rm -f conftest* + fi + + # Set RUNPARALLEL to mpirun if not set yet. + if test "yes" = "$PARALLEL" -a "X-" = "X-$RUNPARALLEL"; then + RUNPARALLEL="mpirun -np \$\${NPROCS:=2}" + fi ;; X-mpich) @@ -6731,7 +6871,7 @@ case "X-$enable_parallel" in # is missing. PARALLEL=mpich echo $ac_n "checking for MPI_Init in -lmpich""... $ac_c" 1>&6 -echo "configure:6735: checking for MPI_Init in -lmpich" >&5 +echo "configure:6875: checking for MPI_Init in -lmpich" >&5 ac_lib_var=`echo mpich'_'MPI_Init | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -6739,7 +6879,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lmpich $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:6894: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -6799,13 +6939,34 @@ EOF # Display what we found about running programs echo $ac_n "checking prefix for running on one processor""... $ac_c" 1>&6 -echo "configure:6803: checking prefix for running on one processor" >&5 +echo "configure:6943: checking prefix for running on one processor" >&5 echo "$ac_t""$RUNSERIAL" 1>&6 echo $ac_n "checking prefix for running in parallel""... $ac_c" 1>&6 -echo "configure:6806: checking prefix for running in parallel" >&5 +echo "configure:6946: checking prefix for running in parallel" >&5 echo "$ac_t""$RUNPARALLEL" 1>&6 # Check that we can link a simple MPI and MPI-IO application + echo $ac_n "checking whether a simple MPI-IO program can be linked""... $ac_c" 1>&6 +echo "configure:6951: checking whether a simple MPI-IO program can be linked" >&5 + cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + echo "$ac_t""yes" 1>&6 +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + echo "$ac_t""no" 1>&6 + { echo "configure: error: 'unable to link a simple MPI-IO application'" 1>&2; exit 1; } +fi +rm -f conftest* # There *must* be some way to run in parallel even if it's just the diff --git a/configure.in b/configure.in index 4fabac4..1c1489e 100644 --- a/configure.in +++ b/configure.in @@ -857,9 +857,24 @@ case "X-$enable_parallel" in X-yes) # We want to compile a parallel library with a compiler that - # already knows how to link with MPI and MPI-IO. + # may already know how to link with MPI and MPI-IO. AC_MSG_RESULT(provided by compiler) PARALLEL=yes + + # Try link a simple MPI program. If fail, try again with -lmpi. + AC_TRY_LINK(,MPI_Init(),,AC_CHECK_LIB(mpi,MPI_Init,,PARALLEL=no)) + + # Then try link a simple MPI-IO program. If fail, try again with + # -lmpio. + if test "yes" = "$PARALLEL"; then + AC_TRY_LINK(,MPI_File_open(),, + AC_CHECK_LIB(mpio,MPI_File_open,,PARALLEL=no)) + fi + + # Set RUNPARALLEL to mpirun if not set yet. + if test "yes" = "$PARALLEL" -a "X-" = "X-$RUNPARALLEL"; then + RUNPARALLEL="mpirun -np \$\${NPROCS:=2}" + fi ;; X-mpich) @@ -906,11 +921,11 @@ if test "X-" != "X-$PARALLEL"; then AC_MSG_RESULT($RUNPARALLEL) # Check that we can link a simple MPI and MPI-IO application -dnl AC_MSG_CHECKING(whether a simple MPI-IO program can be linked) -dnl AC_TRY_LINK(,[MPI_Init();MPI_File_open();], -dnl AC_MSG_RESULT(yes), -dnl AC_MSG_RESULT(no) -dnl AC_MSG_ERROR('unable to link a simple MPI-IO application')) + AC_MSG_CHECKING(whether a simple MPI-IO program can be linked) + AC_TRY_LINK(,[MPI_Init();MPI_File_open();], + AC_MSG_RESULT(yes), + AC_MSG_RESULT(no) + AC_MSG_ERROR('unable to link a simple MPI-IO application')) # There *must* be some way to run in parallel even if it's just the -- cgit v0.12