diff --git a/configure.ac b/configure.ac index 836cdaf947c817e54af081a4beced5cef56b6545..31407a7b71a38e49b7c6ec8344b2346961e5f5d3 100644 --- a/configure.ac +++ b/configure.ac @@ -628,6 +628,38 @@ AC_SUBST([FFTW_LIBS]) AC_SUBST([FFTW_INCS]) AM_CONDITIONAL([HAVEFFTW],[test -n "$FFTW_LIBS"]) +# Check for -lprofiler usually part of the gperftools along with tcmalloc. +have_profiler="no" +AC_ARG_WITH([profiler], + [AS_HELP_STRING([--with-profiler], + [use cpu profiler library or specify the directory with lib @<:@yes/no@:>@] + )], + [with_profiler="$withval"], + [with_profiler="no"] +) +if test "x$with_profiler" != "xno"; then + if test "x$with_profiler" != "xyes" -a "x$with_profiler" != "x"; then + proflibs="-L$with_profiler -lprofiler" + else + proflibs="-lprofiler" + fi + AC_CHECK_LIB([profiler],[ProfilerFlush], + [have_profiler="yes" + AC_DEFINE([WITH_PROFILER],1,[Link against the gperftools profiling library.])], + [have_profiler="no"], $proflibs) + + if test "$have_profiler" = "yes"; then + PROFILER_LIBS="$proflibs" + else + PROFILER_LIBS="" + fi +fi +AC_SUBST([PROFILER_LIBS]) +AM_CONDITIONAL([HAVEPROFILER],[test -n "$PROFILER_LIBS"]) + +# Check for special allocators +have_special_allocator="no" + # Check for tcmalloc a fast malloc that is part of the gperftools. have_tcmalloc="no" AC_ARG_WITH([tcmalloc], @@ -637,6 +669,10 @@ AC_ARG_WITH([tcmalloc], [with_tcmalloc="$withval"], [with_tcmalloc="no"] ) +if test "x$with_tcmalloc" != "xno" -a "x$have_special_allocator" != "xno"; then + AC_MSG_ERROR("Cannot activate more than one alternative malloc library") +fi + if test "x$with_tcmalloc" != "xno"; then if test "x$with_tcmalloc" != "xyes" -a "x$with_tcmalloc" != "x"; then tclibs="-L$with_tcmalloc -ltcmalloc" @@ -660,7 +696,9 @@ if test "x$with_tcmalloc" != "xno"; then if test "$have_tcmalloc" = "yes"; then TCMALLOC_LIBS="$tclibs" - # Prevent compilers that replace the calls within built-ins (GNU 99) from doing so. + have_special_allocator="yes" + + # Prevent compilers that replace the calls with built-ins (GNU 99) from doing so. case "$ax_cv_c_compiler_vendor" in intel | gnu | clang) CFLAGS="$CFLAGS -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free" @@ -674,35 +712,6 @@ fi AC_SUBST([TCMALLOC_LIBS]) AM_CONDITIONAL([HAVETCMALLOC],[test -n "$TCMALLOC_LIBS"]) -# Check for -lprofiler usually part of the gperftools along with tcmalloc. -have_profiler="no" -AC_ARG_WITH([profiler], - [AS_HELP_STRING([--with-profiler], - [use cpu profiler library or specify the directory with lib @<:@yes/no@:>@] - )], - [with_profiler="$withval"], - [with_profiler="no"] -) -if test "x$with_profiler" != "xno"; then - if test "x$with_profiler" != "xyes" -a "x$with_profiler" != "x"; then - proflibs="-L$with_profiler -lprofiler" - else - proflibs="-lprofiler" - fi - AC_CHECK_LIB([profiler],[ProfilerFlush], - [have_profiler="yes" - AC_DEFINE([WITH_PROFILER],1,[Link against the gperftools profiling library.])], - [have_profiler="no"], $proflibs) - - if test "$have_profiler" = "yes"; then - PROFILER_LIBS="$proflibs" - else - PROFILER_LIBS="" - fi -fi -AC_SUBST([PROFILER_LIBS]) -AM_CONDITIONAL([HAVEPROFILER],[test -n "$PROFILER_LIBS"]) - # Check for jemalloc another fast malloc that is good with contention. have_jemalloc="no" AC_ARG_WITH([jemalloc], @@ -712,6 +721,10 @@ AC_ARG_WITH([jemalloc], [with_jemalloc="$withval"], [with_jemalloc="no"] ) +if test "x$with_jemalloc" != "xno" -a "x$have_special_allocator" != "xno"; then + AC_MSG_ERROR("Cannot activate more than one alternative malloc library") +fi + if test "x$with_jemalloc" != "xno"; then if test "x$with_jemalloc" != "xyes" -a "x$with_jemalloc" != "x"; then jelibs="-L$with_jemalloc -ljemalloc" @@ -724,7 +737,9 @@ if test "x$with_jemalloc" != "xno"; then if test "$have_jemalloc" = "yes"; then JEMALLOC_LIBS="$jelibs" - # Prevent compilers that replace the regular calls within built-ins (GNU 99) from doing so. + have_special_allocator="yes" + + # Prevent compilers that replace the regular calls with built-ins (GNU 99) from doing so. case "$ax_cv_c_compiler_vendor" in intel | gnu | clang) CFLAGS="$CFLAGS -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free" @@ -738,10 +753,46 @@ fi AC_SUBST([JEMALLOC_LIBS]) AM_CONDITIONAL([HAVEJEMALLOC],[test -n "$JEMALLOC_LIBS"]) -# Don't allow both tcmalloc and jemalloc. -if test "x$have_tcmalloc" != "xno" -a "x$have_jemalloc" != "xno"; then - AC_MSG_ERROR([Cannot use tcmalloc at same time as jemalloc]) +# Check for tbbmalloc, Intel's fast and parallel allocator +have_tbbmalloc="no" +AC_ARG_WITH([tbbmalloc], + [AS_HELP_STRING([--with-tbbmalloc], + [use tbbmalloc library or specify the directory with lib @<:@yes/no@:>@] + )], + [with_tbbmalloc="$withval"], + [with_tbbmalloc="no"] +) +if test "x$with_tbbmalloc" != "xno" -a "x$have_special_allocator" != "xno"; then + AC_MSG_ERROR("Cannot activate more than one alternative malloc library") +fi + +if test "x$with_tbbmalloc" != "xno"; then + if test "x$with_tbbmalloc" != "xyes" -a "x$with_tbbmalloc" != "x"; then + tbblibs="-L$with_tbbmalloc -ltbbmalloc_proxy -ltbbmalloc" + else + tbblibs="-ltbbmalloc_proxy -ltbbmalloc" + fi + AC_CHECK_LIB([tbbmalloc],[scalable_malloc],[have_tbbmalloc="yes"],[have_tbbmalloc="no"], + $tbblibs) + + if test "$have_tbbmalloc" = "yes"; then + TBBMALLOC_LIBS="$tbblibs" + + have_special_allocator="yes" + + # Prevent compilers that replace the calls with built-ins (GNU 99) from doing so. + case "$ax_cv_c_compiler_vendor" in + intel | gnu | clang) + CFLAGS="$CFLAGS -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free" + ;; + esac + + else + TBBMALLOC_LIBS="" + fi fi +AC_SUBST([TBBMALLOC_LIBS]) +AM_CONDITIONAL([HAVETBBMALLOC],[test -n "$TBBMALLOC_LIBS"]) # Check for HDF5. This is required. AX_LIB_HDF5 @@ -1243,6 +1294,7 @@ AC_MSG_RESULT([ GSL enabled : $have_gsl libNUMA enabled : $have_numa GRACKLE enabled : $have_grackle + Using tbbmalloc : $have_tbbmalloc Using tcmalloc : $have_tcmalloc Using jemalloc : $have_jemalloc CPU profiler : $have_profiler diff --git a/examples/Makefile.am b/examples/Makefile.am index 95057c9bee7d3b4cc001d6c19ca39cab5d8544c4..9de393ba6c77f9bd50e1d8aff12c0d83ba8e7ddc 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -24,7 +24,7 @@ AM_CFLAGS = -I$(top_srcdir)/src $(HDF5_CPPFLAGS) $(GSL_INCS) $(FFTW_INCS) AM_LDFLAGS = $(HDF5_LDFLAGS) # Extra libraries. -EXTRA_LIBS = $(HDF5_LIBS) $(FFTW_LIBS) $(PROFILER_LIBS) $(TCMALLOC_LIBS) $(JEMALLOC_LIBS) $(GRACKLE_LIBS) $(GSL_LIBS) +EXTRA_LIBS = $(HDF5_LIBS) $(FFTW_LIBS) $(PROFILER_LIBS) $(TCMALLOC_LIBS) $(JEMALLOC_LIBS) $(TBBMALLOC_LIBS) $(GRACKLE_LIBS) $(GSL_LIBS) # MPI libraries. MPI_LIBS = $(METIS_LIBS) $(MPI_THREAD_LIBS) diff --git a/src/Makefile.am b/src/Makefile.am index 374d2c4569efe0e07ca1b2558b679b33564da432..d89133d3fa2c23b5740b35574f91f3fe6808bfae 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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) $(PROFILER_LIBS) $(TCMALLOC_LIBS) $(JEMALLOC_LIBS) $(GRACKLE_LIB) $(GSL_LIBS) +EXTRA_LIBS = $(HDF5_LIBS) $(FFTW_LIBS) $(PROFILER_LIBS) $(TCMALLOC_LIBS) $(JEMALLOC_LIBS) $(TBBMALLOC_LIBS) $(GRACKLE_LIB) $(GSL_LIBS) # MPI libraries. MPI_LIBS = $(METIS_LIBS) $(MPI_THREAD_LIBS) diff --git a/tests/Makefile.am b/tests/Makefile.am index 891eef3f518f83c17b66623e3dac1832512d31f3..564076ed501409083db017de4c79c17f3b2a7c15 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -17,7 +17,7 @@ # Add the source directory and the non-standard paths to the included library headers to CFLAGS AM_CFLAGS = -I$(top_srcdir)/src $(HDF5_CPPFLAGS) $(GSL_INCS) $(FFTW_INCS) -AM_LDFLAGS = ../src/.libs/libswiftsim.a $(HDF5_LDFLAGS) $(HDF5_LIBS) $(FFTW_LIBS) $(GRACKLE_LIBS) $(GSL_LIBS) $(PROFILER_LIBS) +AM_LDFLAGS = ../src/.libs/libswiftsim.a $(HDF5_LDFLAGS) $(HDF5_LIBS) $(FFTW_LIBS) $(TCMALLOC_LIBS) $(JEMALLOC_LIBS) $(TBBMALLOC_LIBS) $(GRACKLE_LIBS) $(GSL_LIBS) $(PROFILER_LIBS) # List of programs and scripts to run in the test suite TESTS = testGreetings testMaths testReading.sh testSingle testKernel testSymmetry \