[patch] Find & use native C MPI
Nathan (Jasper) Myers
ncm at codesourcery.com
Mon Dec 26 20:05:34 UTC 2005
The attached fixes up config-time MPI library and build/link flag
discovery.
Committed.
Nathan Myers
ncm
Index: ChangeLog
===================================================================
RCS file: /home/cvs/Repository/vpp/ChangeLog,v
retrieving revision 1.354
diff -u -p -r1.354 ChangeLog
--- ChangeLog 23 Dec 2005 20:03:55 -0000 1.354
+++ ChangeLog 26 Dec 2005 19:42:54 -0000
@@ -1,3 +1,8 @@
+2005-12-26 Nathan Myers <ncm at codesourcery.com>
+
+ * configure.ac, src/vsip/impl/par-services-mpi.hpp: find native MPI
+ installations, correctly extract build options using C-only libs.
+
2005-12-23 Stefan Seefeld <stefan at codesourcery.com>
* tests/GNUmakefile.inc.in: Add new check-installed target.
Index: configure.ac
===================================================================
RCS file: /home/cvs/Repository/vpp/configure.ac,v
retrieving revision 1.65
diff -u -p -r1.65 configure.ac
--- configure.ac 23 Dec 2005 19:32:38 -0000 1.65
+++ configure.ac 26 Dec 2005 19:42:54 -0000
@@ -27,9 +27,9 @@ AC_ARG_ENABLE(maintainer-mode,
VSIPL++, but do not plan to modify Sourcery VSIPL++,
you should not use this option.]),
[case x"$enableval" in
- xyes) maintainer_mode=true ;;
- xno) maintainer_mode= ;;
- *) AC_MSG_ERROR([Invalid argument to --enable-maintainer-mode.])
+ (xyes) maintainer_mode=true ;;
+ (xno) maintainer_mode= ;;
+ (*) AC_MSG_ERROR([Invalid argument to --enable-maintainer-mode.])
esac],
[maintainer_mode=])
AC_SUBST(maintainer_mode)
@@ -54,7 +54,7 @@ AC_ARG_ENABLE([exceptions],
AC_ARG_ENABLE([mpi],
AS_HELP_STRING([--disable-mpi],
[don't use MPI (default is to use it if found)]),,
- [enable_mpi=no])
+ [enable_mpi=yes])
AC_ARG_WITH(mpi_prefix,
AS_HELP_STRING([--with-mpi-prefix=PATH],
[Specify the installation prefix of the MPI library. Headers
@@ -447,8 +447,8 @@ if test "$enable_fftw3" != "no" ; then
AC_MSG_CHECKING([for external FFTW3 library])
LIBS="$LIBS $libs"
AC_LINK_IFELSE(
- [AC_LANG_PROGRAM([[#include <fftw3.h>]],
- [[$syms]])],
+ [AC_LANG_PROGRAM([#include <fftw3.h>],
+ [$syms])],
[AC_MSG_RESULT([enabled.])
keep_LIBS="$LIBS"
keep_CPPFLAGS="$CPPFLAGS"
@@ -656,6 +656,7 @@ fi
if test "$enable_mpi" != "no"; then
vsipl_par_service=1
+ MPI_CPPFLAGS=
if test -n "$with_mpi_prefix"; then
MPI_CPPFLAGS="-I$with_mpi_prefix/include"
fi
@@ -663,12 +664,39 @@ if test "$enable_mpi" != "no"; then
CPPFLAGS="$CPPFLAGS $MPI_CPPFLAGS"
# Find mpi.h.
+ vsipl_lib_style=unknown
vsipl_mpi_h_name="not found"
- AC_CHECK_HEADER([mpi.h], [vsipl_mpi_h_name='<mpi.h>'],, [// no prerequisites])
+ vsipl_mpi_config_h_name="not found"
+ if test "$vsipl_mpi_config_h_name" = "not found"; then
+ AC_CHECK_HEADER([lam_config.h],
+ [vsipl_mpi_config_h_name='<lam_config.h>'
+ vsipl_mpi_h_name='<mpi.h>'
+ vsipl_lib_style=lam
+ AC_DEFINE_UNQUOTED(VSIP_IMPL_HAVE_MPI_CONFIG_H,<lam_config.h>,
+ [A header to include before getting mpi.h.])],,
+ [ // no prerequisites ])
+ fi
+ if test "$vsipl_mpi_h_config" = "not found"; then
+ AC_CHECK_HEADER([mpi/lam_config.h],
+ [vsipl_mpi_config_h_name='<mpi/lam_config.h>'
+ vsipl_mpi_h_name='<mpi/mpi.h>'
+ vsipl_lib_style=lam
+ AC_DEFINE_UNQUOTED(VSIP_IMPL_HAVE_MPI_CONFIG_H,<mpi/lam_config.h>,
+ [A header to include before getting mpi.h.])],,
+ [ // no prerequisites ])
+ fi
if test "$vsipl_mpi_h_name" = "not found"; then
- AC_CHECK_HEADER([mpi/mpi.h], [vsipl_mpi_h_name='<mpi/mpi.h>'],, [// no prerequisites])
+ AC_CHECK_HEADER([mpi.h],
+ [vsipl_mpi_h_name='<mpi.h>'],,
+ [#define MPICH_SKIP_MPICXX 1])
+ fi
+ if test "$vsipl_mpi_h_name" = "not found"; then
+ AC_CHECK_HEADER([mpi/mpi.h],
+ [vsipl_mpi_h_name='<mpi/mpi.h>'],,
+ [#define MPICH_SKIP_MPICXX 1])
fi
dnl Add further possibilities here.
+
if test "$vsipl_mpi_h_name" = "not found"; then
if test "$enable_mpi" != "probe"; then
AC_MSG_ERROR([MPI enabled, but no mpi.h detected])
@@ -677,69 +705,90 @@ if test "$enable_mpi" != "no"; then
CPPFLAGS="$save_CPPFLAGS"
fi
else
- AC_DEFINE_UNQUOTED(VSIP_IMPL_MPI_H, $vsipl_mpi_h_name,
+ AC_DEFINE_UNQUOTED([VSIP_IMPL_MPI_H], $vsipl_mpi_h_name,
[The name of the header to include for the MPI interface, with <> quotes.])
# Find the library.
- vsipl_lib_style=unknown
- # Both MPICH 1 and 2 define MPICH_NAME.
- AC_CHECK_DECL([MPICH_NAME], [vsipl_lib_style=mpich],,
- [#include VSIP_IMPL_MPI_H])
+ # if it's lam, we already identified it.
if test $vsipl_lib_style = unknown; then
- AC_CHECK_DECL([LAM_MPI], [vsipl_lib_style=lam],,
- [#include VSIP_IMPL_MPI_H])
+ # Both MPICH 1 and 2 define MPICH_NAME.
+ AC_CHECK_DECL([MPICH_NAME], [vsipl_lib_style=mpich],,
+ [[#include VSIP_IMPL_MPI_H]])
fi
- case $vsipl_lib_style in
- unknown)
+ AC_MSG_NOTICE([Discovering MPI compile and link flags])
+ if test -n "$with_mpi_prefix"; then
+ MPICC="$with_mpi_prefix/bin/mpicc"
+ else
+ MPICC="mpicc"
+ fi
+ MPI_CPPFLAGS=
+ MPI_LIBS=
+ case "$vsipl_lib_style" in
+ (unknown)
+ AC_MSG_RESULT([failed])
AC_MSG_ERROR([unrecognized MPI implementation])
;;
- mpich)
- if test -n "$with_mpi_prefix"; then
- MPICXX="$with_mpi_prefix/bin/mpicxx -show"
- else
- MPICXX="mpicxx -show"
- fi
- ;;
+ (mpich)
+ [MPI_CPPFLAGS="`$MPICC -show -compile_info -cc= -c conftest.c | \
+ sed -e \"s| *-c conftest.c||\"`"]
+ [MPI_LIBS="`$MPICC -show -link_info -cc= conftest.o | \
+ sed -e \"s| *conftest.o||\"`"]
+ AC_MSG_RESULT([ok])
+ ;;
- lam)
- if test -n "$with_mpi_prefix"; then
- MPICXX="$with_mpi_prefix/bin/mpiCC -showme"
- else
- MPICXX="mpiCC -showme"
- fi
+ (lam)
+ # lam 7 could use "-showme:compile" and "-showme:link" and avoid sed.
+ [MPI_CPPFLAGS="`$MPICC -showme -c conftest.c | \
+ sed -e \"s|^[^ ]* ||\" -e \"s| *-c conftest.c||\"`"]
+ [MPI_LIBS="`$MPICC -showme conftest.o | \
+ sed -e \"s|^[^ ]* ||\" -e \"s| *conftest.o||\"`"]
+ AC_MSG_RESULT([ok])
vsip_impl_avoid_posix_memalign=yes
- ;;
+ ;;
esac
-changequote(<<, >>)dnl
- MPI_CPPFLAGS="`$MPICXX -c conftest.cc | sed -e \"s|^[^ \t]*||\"\
- -e \"s|-DHAVE_MPI_CXX||\"\
- -e \"s|-c conftest.cc[ \t]*$||\"`"
- MPI_LIBS="`$MPICXX | sed -e \"s|^[^ \t]*||\"\
- -e \"s|-DHAVE_MPI_CXX||\"`"
-changequote([, ])dnl
+ AC_MSG_NOTICE([MPI_CPPFLAGS=$MPI_CPPFLAGS])
+ AC_MSG_NOTICE([MPI_LIBS=$MPI_LIBS])
- AC_MSG_CHECKING([for MPI build instructions])
+ AC_MSG_CHECKING([MPI build instructions])
save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $MPI_CPPFLAGS"
save_LIBS="$LIBS"
LIBS="$LIBS $MPI_LIBS"
- AC_LINK_IFELSE(
- [AC_LANG_PROGRAM([[#include VSIP_IMPL_MPI_H]],
- [[MPI_Init(0, 0);]])],
- [],
- [AC_MSG_ERROR([Unable to compile / link test MPI application.])])
-
- AC_MSG_RESULT(found)
+ case "$vsipl_lib_style" in
+ (mpich)
+ AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM([#include VSIP_IMPL_MPI_H
+ #define MPICH_SKIP_MPICXX 1],
+ [MPI_Init(0, 0)])],
+ [AC_MSG_RESULT([worked])],
+ [AC_MSG_RESULT([failed])
+ AC_MSG_ERROR([Unable to compile / link test MPICH program.])])
+ ;;
+ (lam)
+ AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM([
+ #include VSIP_IMPL_HAVE_MPI_CONFIG_H
+ #ifdef LAM_WANT_MPI2CPP
+ #undef LAM_WANT_MPI2CPP
+ #endif
+ #include VSIP_IMPL_MPI_H ],
+ [MPI_Init(0, 0)])],
+ [AC_MSG_RESULT([worked])],
+ [AC_MSG_RESULT([failed])
+ AC_MSG_ERROR([Unable to compile / link test LAM MPI program.])])
+ ;;
+ esac
if test -n "$vsip_impl_avoid_posix_memalign"; then
AC_DEFINE_UNQUOTED(VSIP_IMPL_AVOID_POSIX_MEMALIGN, 1,
[Set to 1 to avoid using posix_memalign (LAM defines its own malloc,
including memalign but not posix_memalign).])
- AC_MSG_NOTICE([Avoiding posix_memalign, may not be compatible with LAM-MPI malloc])
+ AC_MSG_NOTICE(
+ [Avoiding posix_memalign, may not be compatible with LAM-MPI malloc])
fi
fi
Index: src/vsip/impl/par-services-mpi.hpp
===================================================================
RCS file: /home/cvs/Repository/vpp/src/vsip/impl/par-services-mpi.hpp,v
retrieving revision 1.14
diff -u -p -r1.14 par-services-mpi.hpp
--- src/vsip/impl/par-services-mpi.hpp 16 Sep 2005 22:03:20 -0000 1.14
+++ src/vsip/impl/par-services-mpi.hpp 26 Dec 2005 19:42:54 -0000
@@ -26,8 +26,24 @@
#include <complex>
#include <vsip/impl/config.hpp>
+
+// work around, er, unfortunate MPICH implementation choice
+#ifndef MPICH_SKIP_MPICXX
+#define MPICH_SKIP_MPICXX 1 /* turn off #include <mpi++.h> in mpi.h */
+#endif
+
+// work around, er, unfortunate LAM 6.x,7 implementation choice
+#ifdef VSIP_IMPL_HAVE_MPI_CONFIG_H
+#include VSIP_IMPL_HAVE_MPI_CONFIG_H /* typically <lam_config.h> */
+#ifdef WANT_MPI2CPP
+#undef WANT_MPI2CPP /* turn off "#include <mpi.h++>" in mpi.h */
+#endif
+#endif
+
#include VSIP_IMPL_MPI_H
+#undef MPICH_SKIP_MPICXX /* clean up */
+
#include <vsip/support.hpp>
More information about the vsipl++
mailing list