Skip to content
Snippets Groups Projects
Commit 83b6cbbf authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Merge branch 'numa-autoconf' into 'master'

NUMA: make the check look for an external library

Closes #498

See merge request !692
parents 511013e6 5ad9e28a
No related branches found
No related tags found
1 merge request!692NUMA: make the check look for an external library
......@@ -154,6 +154,12 @@ before you can build it.
distributing the threads among the different cores on each
computing node.
Note that if you have libNUMA outside of the system include
directories it may fail to compile as the headers do not pass
the -Wstrict-prototype check of GCC. In that case you will need
to use --enable-compiler-warnings=yes configure option to stop
this being an error.
- tcmalloc / jemalloc / TBBmalloc:
a build of the tcmalloc library (part of gperftools), jemalloc
or TBBmalloc can be used be used to obtain faster and more
......
......@@ -19,6 +19,22 @@
AC_INIT([SWIFT],[0.8.0],[https://gitlab.cosma.dur.ac.uk/swift/swiftsim])
swift_config_flags="$*"
# We want to stop when given unrecognised options. No subdirs so this is safe.
enable_option_checking=${enable_option_checking:-fatal}
if test -n "$ac_unrecognized_opts"; then
case $enable_option_checking in
no)
;;
fatal)
{ $as_echo "$as_me: error: unrecognized options: $ac_unrecognized_opts" >&2
{ (exit 1); exit 1; }; }
;;
*)
$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2
;;
esac
fi
AC_COPYRIGHT
AC_CONFIG_SRCDIR([src/space.c])
AC_CONFIG_AUX_DIR([.])
......@@ -335,7 +351,7 @@ AC_ARG_ENABLE([vec],
[enable_vec="yes"]
)
# Disable hand written vectorisation. Slightly odd implementation as want
# Disable hand written vectorisation. Slightly odd implementation as want
# to describe as --disable-hand-vec, but macro is enable (there is no enable action).
AC_ARG_ENABLE([hand-vec],
[AS_HELP_STRING([--disable-hand-vec],
......@@ -986,16 +1002,55 @@ AC_CHECK_FUNC(pthread_setaffinity_np, AC_DEFINE([HAVE_SETAFFINITY],[1],
AM_CONDITIONAL(HAVESETAFFINITY,
[test "$ac_cv_func_pthread_setaffinity_np" = "yes"])
# If available check for NUMA as well. There is a problem with the headers of
# this library, mainly that they do not pass the strict prototypes check when
# installed outside of the system directories. So we actually do this check
# in two phases. The basic ones first (before strict-prototypes is added to CFLAGS).
have_numa="no"
if test "$ac_cv_func_pthread_setaffinity_np" = "yes"; then
# Check for libnuma.
AC_CHECK_HEADER([numa.h])
if test "$ac_cv_header_numa_h" = "yes"; then
AC_CHECK_LIB([numa], [numa_available])
have_numa="yes"
fi
fi
AC_ARG_WITH([numa],
[AS_HELP_STRING([--with-numa=PATH],
[Directory where the NUMA library exists @<:@yes/no@:>@]
)],
[with_numa="$withval"],
[with_numa="yes"]
)
if test "$ac_cv_func_pthread_setaffinity_np" = "yes" -a "x$with_numa" != "xno"; then
if test "x$with_numa" != "xyes" -a "x$with_numa" != "x"; then
NUMA_LIBS="-L$with_numa/lib -lnuma"
NUMA_INCS="-I$with_numa/include"
else
NUMA_LIBS="-lnuma"
NUMA_INCS=""
fi
# Test for header file.
old_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $NUMA_INCS"
AC_CHECK_HEADER([numa.h])
CPPFLAGS="$old_CPPFLAGS"
if test "$ac_cv_header_numa_h" = "yes"; then
# If NUMA location is specified check if we have it.
if test "x$with_numa" != "xyes" -a "x$with_numa" != "x"; then
AC_CHECK_LIB([numa],[numa_available],
AC_DEFINE([HAVE_LIBNUMA],1,[The NUMA library appears to be present.]),
AC_MSG_ERROR(something is wrong with the NUMA library!), $NUMA_LIBS)
have_numa="yes"
else
AC_CHECK_LIB([numa],[numa_available],[have_numa="yes"],[have_numa="no"],$NUMA_LIBS)
if test "x$have_numa" != "xno"; then
AC_DEFINE([HAVE_LIBNUMA],1,[The NUMA library appears to be present.])
fi
fi
fi
# We can live without this.
if test "$have_numa" = "no"; then
NUMA_LIBS=""
fi
fi
AC_SUBST([NUMA_LIBS])
# Check for Intel and PowerPC intrinsics header optionally used by vector.h.
AC_CHECK_HEADERS([immintrin.h])
......@@ -1082,6 +1137,35 @@ if test "$enable_warn" != "no"; then
[CFLAGS="$CFLAGS"],[$CFLAGS],[AC_LANG_SOURCE([int main(void){return 0;}])])
fi
# Second part of the NUMA library checks. We now decide if we need to use
# -isystem to get around the strict-prototypes problem. Assumes isystem
# is available when strict-prototypes is.
if test "$have_numa" != "no"; then
if test "x$with_numa" != "xyes" -a "x$with_numa" != "x"; then
case "$CFLAGS" in
*strict-prototypes*)
NUMA_INCS="-isystem$with_numa/include"
# This may still fail if CPATH is used, so we check if the
# headers are usable.
AS_UNSET(ac_cv_header_numa_h)
old_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $NUMA_INCS"
numa_failed="no"
AC_CHECK_HEADER([numa.h],[numa_failed="no"],
[numa_failed="yes"])
if test "$numa_failed" = "yes"; then
AC_MSG_ERROR([Failed to compile the numa.h header file: you may need to set --enable-compiler-warnings to yes or no])
fi
CPPFLAGS="$old_CPPFLAGS"
;;
*)
NUMA_INCS="-I$with_numa/include"
;;
esac
fi
fi
AC_SUBST([NUMA_INCS])
# Various package configuration options.
# Master subgrid options
......
......@@ -38,7 +38,7 @@ METIS is used for domain decomposition and load balancing.
libNUMA
~~~~~~~
libNUMA is used to pin threads.
libNUMA is used to pin threads (but see INSTALL.swift).
GSL
~~~
......
......@@ -20,13 +20,13 @@ MYFLAGS =
# Add the source directory and the non-standard paths to the included library headers to CFLAGS
AM_CFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/argparse $(HDF5_CPPFLAGS) \
$(GSL_INCS) $(FFTW_INCS) $(GRACKLE_INCS)
$(GSL_INCS) $(FFTW_INCS) $(NUMA_INCS) $(GRACKLE_INCS)
AM_LDFLAGS = $(HDF5_LDFLAGS)
# Extra libraries.
EXTRA_LIBS = $(HDF5_LIBS) $(FFTW_LIBS) $(PROFILER_LIBS) $(TCMALLOC_LIBS) \
$(JEMALLOC_LIBS) $(TBBMALLOC_LIBS) $(GRACKLE_LIBS) \
EXTRA_LIBS = $(HDF5_LIBS) $(FFTW_LIBS) $(NUMA_LIBS) $(PROFILER_LIBS) \
$(TCMALLOC_LIBS) $(JEMALLOC_LIBS) $(TBBMALLOC_LIBS) $(GRACKLE_LIBS) \
$(VELOCIRAPTOR_LIBS) $(GSL_LIBS)
# MPI libraries.
......
......@@ -16,7 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Add the non-standard paths to the included library headers
AM_CFLAGS = $(HDF5_CPPFLAGS) $(GSL_INCS) $(FFTW_INCS) $(GRACKLE_INCS)
AM_CFLAGS = $(HDF5_CPPFLAGS) $(GSL_INCS) $(FFTW_INCS) $(NUMA_INCS) $(GRACKLE_INCS)
# Assign a "safe" version number
AM_LDFLAGS = $(HDF5_LDFLAGS) $(FFTW_LIBS) -version-info 0:0:0
......@@ -25,7 +25,7 @@ AM_LDFLAGS = $(HDF5_LDFLAGS) $(FFTW_LIBS) -version-info 0:0:0
GIT_CMD = @GIT_CMD@
# Additional dependencies for shared libraries.
EXTRA_LIBS = $(HDF5_LIBS) $(FFTW_LIBS) $(PROFILER_LIBS) $(TCMALLOC_LIBS) $(JEMALLOC_LIBS) $(TBBMALLOC_LIBS) $(GRACKLE_LIBS) $(GSL_LIBS)
EXTRA_LIBS = $(HDF5_LIBS) $(FFTW_LIBS) $(NUMA_LIBS) $(PROFILER_LIBS) $(TCMALLOC_LIBS) $(JEMALLOC_LIBS) $(TBBMALLOC_LIBS) $(GRACKLE_LIBS) $(GSL_LIBS)
# MPI libraries.
MPI_LIBS = $(PARMETIS_LIBS) $(METIS_LIBS) $(MPI_THREAD_LIBS)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment