Skip to content
Snippets Groups Projects
Commit 19ab0a87 authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Add support for linking against MPI libraries with threads.

Note that PLATFORM doesn't really work as it outputs the message:

  MPI_File_open is not yet thread safe

so cannot be used with a parallel HDF.

Improve configuration for the METIS library.

Only apply the sanitizer flags for a real GCC, not those who
support GNU extensions.

Tidy up examples Makefile.am to remove compiler specific flags.


Former-commit-id: 8cac59db8fc27033c9f83c13e9d037b757ae64d2
parent 20b0488c
No related branches found
No related tags found
No related merge requests found
......@@ -53,13 +53,48 @@ AX_COMPILER_VERSION
# http://lists.gnu.org/archive/html/autoconf-archive-maintainers/2011-05/msg00004.html.
AC_ARG_ENABLE([mpi],
[AS_HELP_STRING([--enable-mpi],
[Compile with functionality for distributed-memory parallelim using MPI @<:@default=yes@:>@]
[Compile with functionality for distributed-memory parallelism using MPI @<:@default=yes@:>@]
)],
[enable_mpi="$enableval"],
[enable_mpi="yes"]
)
if test "$enable_mpi" = "yes"; then
AX_MPI([CC="$MPICC" AC_DEFINE(HAVE_MPI, 1, [Define if you have the MPI library.]) ])
# Various MPI implementations require additional libraries when also using
# threads. Use mpirun (on PATH) as that seems to be only command with
# version flag.
AC_PATH_PROG([MPIRUN],[mpirun],[notfound])
if test "$MPIRUN" = "notfound"; then
AC_MSG_WARN([Cannot find mpirun command on PATH, thread support may not be correct])
else
# Special options we know about.
# Intel: -mt_mpi
# PLATFORM: -lmtmpi
# OpenMPI: nothing, but library should be built correctly.
# Set MPI_THREAD_LIBS and add to linker commands as necessary.
AC_MSG_CHECKING([MPI threads options])
version=`$MPIRUN -version 2>&1`
case "$version" in
*Intel*MPI*)
MPI_THREAD_LIBS="-mt_mpi"
AC_MSG_RESULT([Intel MPI])
;;
*Platform*)
MPI_THREAD_LIBS="-lmtmpi"
AC_MSG_RESULT([PLATFORM MPI])
;;
*"Open MPI"*)
MPI_THREAD_LIBS=""
AC_MSG_RESULT([Open MPI])
;;
*)
MPI_THREAD_LIBS=""
AC_MSG_RESULT([unknown])
;;
esac
AC_SUBST([MPI_THREAD_LIBS])
fi
fi
AM_CONDITIONAL([HAVEMPI],[test -n "$MPICC"])
......@@ -73,11 +108,11 @@ AX_FUNC_POSIX_MEMALIGN
# Only optimize if allowed, otherwise assume user will set CFLAGS as
# appropriate.
AC_ARG_ENABLE([optimization],
[AS_HELP_STRING([--enable-optimization],
[Enable compile time optimization flags for host @<:@default=yes@:>@]
)],
[enable_opt="$enableval"],
[enable_opt="yes"]
[AS_HELP_STRING([--enable-optimization],
[Enable compile time optimization flags for host @<:@default=yes@:>@]
)],
[enable_opt="$enableval"],
[enable_opt="yes"]
)
if test "$enable_opt" = "yes" ; then
......@@ -101,18 +136,22 @@ fi
# Add address sanitizer options to flags, if requested. Only useful for GCC
# version 4.8 and later.
AC_ARG_ENABLE([sanitizer],
[AS_HELP_STRING([--enable-sanitizer],
[Enable memory error detection using address sanitizer @<:@default=no@:>@]
)],
[enable_san="$enableval"],
[enable_san="no"]
[AS_HELP_STRING([--enable-sanitizer],
[Enable memory error detection using address sanitizer @<:@default=no@:>@]
)],
[enable_san="$enableval"],
[enable_san="no"]
)
if test "$enable_san" = "yes" -a "$GCC" = yes; then
AX_COMPARE_VERSION( $ax_cv_c_compiler_version, [ge], [4.8.0],
[enable_san="yes"], [enable_san="no"] )
if test "$enable_san" = "yes"; then
CFLAGS="$CFLAGS -fsanitize=address -fno-omit-frame-pointer"
if test "$enable_san" = "yes"; then
if test "$ax_cv_c_compiler_vendor" = "gnu"; then
AX_COMPARE_VERSION( $ax_cv_c_compiler_version, [ge], [4.8.0],
[enable_san="yes"], [enable_san="no"] )
if test "$enable_san" = "yes"; then
CFLAGS="$CFLAGS -fsanitize=address -fno-omit-frame-pointer"
fi
else
AC_MSG_WARN([Compiler does not support address sanitizer option])
fi
fi
......@@ -132,7 +171,6 @@ AX_PTHREAD([LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
or use CPPFLAGS and LDFLAGS if the library is installed in a
non-standard location.]))
# Check for OpenMP.
AC_OPENMP
AC_SUBST(OPENMP_CFLAGS)
......@@ -157,16 +195,16 @@ AC_ARG_WITH([metis],
)
if test "x$with_metis" != "xno"; then
if test "x$with_metis" != "xyes" -a "x$with_metis" != "x"; then
METIS_LDFLAGS="-L$with_metis -lmetis"
METIS_LIBS="-L$with_metis -lmetis"
else
METIS_LDFLAGS="-lmetis"
METIS_LIBS="-lmetis"
fi
AC_CHECK_LIB([metis],[METIS_PartGraphKway],
AC_DEFINE([HAVE_METIS],1,[The metis library appears to be present.]),
AC_MSG_ERROR(something is wrong with the metis library!),$METIS_LDFLAGS)
AC_MSG_ERROR(something is wrong with the metis library!),$METIS_LIBS)
fi
AC_SUBST([METIS_LDFLAGS])
AM_CONDITIONAL([HAVEMETIS],[test -n "$METIS_LDFLAGS"])
AC_SUBST([METIS_LIBS])
AM_CONDITIONAL([HAVEMETIS],[test -n "$METIS_LIBS"])
# Check for zlib.
AC_CHECK_LIB([z],[gzopen],[
......
......@@ -2,17 +2,17 @@
# This file is part of SWIFT.
# Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
# Matthieu Schaller (matthieu.schaller@durham.ac.uk).
#
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
......@@ -20,9 +20,13 @@
MYFLAGS = -DTIMER
# Add the source directory and debug to CFLAGS
AM_CFLAGS = -g -std=gnu99 -Wall -Werror -I../src $(OPENMP_CFLAGS) -DCPU_TPS=2.67e9
AM_CFLAGS = -Wall -Werror -I../src -DCPU_TPS=2.67e9
AM_LDFLAGS = @METIS_LDFLAGS@
AM_LDFLAGS =
METIS_LIBS = @METIS_LIBS@
MPI_THREAD_LIBS = @MPI_THREAD_LIBS@
MPI_LIBS = $(METIS_LIBS) $(MPI_THREAD_LIBS)
# Set-up the library
bin_PROGRAMS = test test_fixdt test_mindt test_single
......@@ -50,17 +54,17 @@ test_mindt_LDADD = ../src/.libs/libswiftsim.a $(HDF5_LDFLAGS) $(HDF5_LIBS)
# Sources for test_mpi
test_mpi_SOURCES = test.c
test_mpi_CFLAGS = $(MYFLAGS) $(AM_CFLAGS) -DWITH_MPI -DENGINE_POLICY="engine_policy_multistep | engine_policy_keep"
test_mpi_LDADD = ../src/.libs/libswiftsim_mpi.a $(HDF5_LDFLAGS) $(HDF5_LIBS)
test_mpi_LDADD = ../src/.libs/libswiftsim_mpi.a $(HDF5_LDFLAGS) $(HDF5_LIBS) $(MPI_LIBS)
# Sources for test_fixdt_mpi
test_fixdt_mpi_SOURCES = test.c
test_fixdt_mpi_CFLAGS = $(MYFLAGS) $(AM_CFLAGS) -DWITH_MPI -DENGINE_POLICY="engine_policy_fixdt | engine_policy_keep"
test_fixdt_mpi_LDADD = ../src/.libs/libswiftsim_mpi.a $(HDF5_LDFLAGS) $(HDF5_LIBS)
test_fixdt_mpi_LDADD = ../src/.libs/libswiftsim_mpi.a $(HDF5_LDFLAGS) $(HDF5_LIBS) $(MPI_LIBS)
# Sources for test_mindt_mpi
test_mindt_mpi_SOURCES = test.c
test_mindt_mpi_CFLAGS = $(MYFLAGS) $(AM_CFLAGS) -DWITH_MPI -DENGINE_POLICY="engine_policy_keep"
test_mindt_mpi_LDADD = ../src/.libs/libswiftsim_mpi.a $(HDF5_LDFLAGS) $(HDF5_LIBS)
test_mindt_mpi_LDADD = ../src/.libs/libswiftsim_mpi.a $(HDF5_LDFLAGS) $(HDF5_LIBS) $(MPI_LIBS)
# Sources for test_single
test_single_SOURCES = test_single.c
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment