diff --git a/INSTALL.swift b/INSTALL.swift index 1782b75e34e2028110717d7873bc2c97365f8240..999a8d3655fa14a8ba1dcbd430b5146cc55ba791 100644 --- a/INSTALL.swift +++ b/INSTALL.swift @@ -96,18 +96,21 @@ SWIFT depends on a number of third party libraries that should be available before you can build it. - - HDF5: a HDF5 library (v. 1.8.x or higher) is required to read and - write particle data. One of the commands "h5cc" or "h5pcc" - should be available. If "h5pcc" is located them a parallel - HDF5 built for the version of MPI located should be - provided. If the command is not available then it can be - located using the "--with-hfd5" configure option. The value - should be the full path to the "h5cc" or "h5pcc" commands. - - - - MPI: to run on more than one node an MPI library that fully - supports MPI_THREAD_MULTIPLE. Before running configure the - "mpirun" command should be available in the shell. If your + - HDF5: + A HDF5 library (v. 1.8.x or higher) is required to read and + write particle data. One of the commands "h5cc" or "h5pcc" + should be available. If "h5pcc" is located then a parallel + HDF5 built for the version of MPI located should be + provided. If the command is not available then it can be + located using the "--with-hdf5" configure option. The value + should be the full path to the "h5cc" or "h5pcc" commands. + SWIFT makes effective use of parallel HDF5 when running on more than + one node, so this option is highly recommended. + + - MPI: + To run on more than one node an MPI library that fully + supports MPI_THREAD_MULTIPLE is required. Before running configure + the "mpirun" command should be available in the shell. If your command isn't called "mpirun" then define the "MPIRUN" environment variable, either in the shell or when running configure. @@ -116,57 +119,69 @@ before you can build it. much like the CC one. Use this when your MPI compiler has a none-standard name. - - GSL: To use cosmological time integration, a version of the GSL - must be available. + - GSL: + To use cosmological time integration, a version of the GSL + must be available. - - libtool: The build system relies on libtool as well as the other autotools. + - FFTW 3.x: + To run with periodic gravity forces, a build of the FFTW 3 + library must be available. Note that SWIFT does not make use + of the parallel capability of FFTW. Calculations are done by + single MPI nodes independently. - - Optional Dependencies - ===================== +- libtool: + The build system relies on libtool as well as the other autotools. - - METIS: a build of the METIS library can be optionally used to - optimize the load between MPI nodes (requires an MPI - library). This should be found in the standard installation - directories, or pointed at using the "--with-metis" - configuration option. In this case the top-level - installation directory of the METIS build should be - given. Note to use METIS you should at least supply - "--with-metis". + Optional Dependencies + ===================== - - libNUMA: a build of the NUMA library can be used to pin the threads - to the physical core of the machine SWIFT is running - on. This is not always necessary as the OS scheduler may - do a good job at distributing the threads among the - different cores on each computing node. + - METIS: + a build of the METIS library can be optionally used to + optimize the load between MPI nodes (requires an MPI + library). This should be found in the standard installation + directories, or pointed at using the "--with-metis" + configuration option. In this case the top-level installation + directory of the METIS build should be given. Note to use + METIS you should supply at least "--with-metis". - - TCMalloc: a build of the TCMalloc library (part of gperftools) can - be used to obtain faster allocations than the standard C - malloc function part of glibc. The option "-with-tcmalloc" - should be passed to the configuration script to use it. +- libNUMA: + a build of the NUMA library can be used to pin the threads to + the physical core of the machine SWIFT is running on. This is + not always necessary as the OS scheduler may do a good job at + distributing the threads among the different cores on each + computing node. + - 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 + scalable allocations than the standard C malloc function part + of glibc. Using one of these is highly recommended on systems + with many cores per node. One of the options + "--with-tcmalloc", "--with-jemalloc" or "--with-tbbmalloc" + should be passed to the configuration script to use it. - - gperftools: a build of gperftools can be used to obtain good - profiling of the code. The option "-with-profiler" - needs to be passed to the configuration script to use - it. + - gperftools: + a build of gperftools can be used to obtain good profiling of + the code. The option "--with-profiler" needs to be passed to + the configuration script to use it. + - DOXYGEN: + the doxygen library is required to create the SWIFT API + documentation. - - DOXYGEN: the doxygen library is required to create the SWIFT API - documentation. + - python: + Examples and solution script use python and rely on the numpy + library version 1.8.2 or higher. - - python: Examples and solution script use python and rely on the - numpy library version 1.8.2 or higher. SWIFT Coding style ================== -The SWIFT source code is using a variation of the 'Google' style. The -script 'format.sh' in the root directory applies the clang-format-3.8 -tool with our style choices to all the SWIFT C source file. Please -apply the formatting script to the files before submitting a merge -request. +The SWIFT source code uses a variation of 'Google' style. The script +'format.sh' in the root directory applies the clang-format-3.8 tool with our +style choices to all the SWIFT C source file. Please apply the formatting +script to the files before submitting a merge request. diff --git a/configure.ac b/configure.ac index 583169d146f8c7e94c45c941e006243badcefe51..316155b4962cb853d4c3bb51e5ffbf6c1c0e038e 100644 --- a/configure.ac +++ b/configure.ac @@ -625,15 +625,51 @@ 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=PATH], + [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], - [AS_HELP_STRING([--with-tcmalloc], + [AS_HELP_STRING([--with-tcmalloc=PATH], [use tcmalloc library or specify the directory with lib @<:@yes/no@:>@] )], [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" @@ -657,10 +693,17 @@ if test "x$with_tcmalloc" != "xno"; then if test "$have_tcmalloc" = "yes"; then TCMALLOC_LIBS="$tclibs" - # These are recommended for GCC. - if test "$ax_cv_c_compiler_vendor" = "gnu"; then - CFLAGS="$CFLAGS -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free" - fi + AC_DEFINE([HAVE_TCMALLOC],1,[The tcmalloc library appears to be present.]) + + have_special_allocator="tcmalloc" + + # 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 TCMALLOC_LIBS="" fi @@ -668,44 +711,19 @@ 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], - [AS_HELP_STRING([--with-jemalloc], + [AS_HELP_STRING([--with-jemalloc=PATH], [use jemalloc library or specify the directory with lib @<:@yes/no@:>@] )], [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" @@ -717,6 +735,18 @@ if test "x$with_jemalloc" != "xno"; then if test "$have_jemalloc" = "yes"; then JEMALLOC_LIBS="$jelibs" + + AC_DEFINE([HAVE_JEMALLOC],1,[The jemalloc library appears to be present.]) + + have_special_allocator="jemalloc" + + # 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" + ;; + esac + else JEMALLOC_LIBS="" fi @@ -724,11 +754,49 @@ 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=PATH], + [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" + + AC_DEFINE([HAVE_TBBMALLOC],1,[The TBBmalloc library appears to be present.]) + + have_special_allocator="TBBmalloc" + + # 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 if test "$with_hdf5" != "yes"; then @@ -750,7 +818,8 @@ if test "$with_hdf5" = "yes"; then if test "$enable_parallel_hdf5" = "yes"; then AC_MSG_CHECKING([for HDF5 parallel support]) -# Check if the library is capable, the header should define H5_HAVE_PARALLEL. + + # Check if the library is capable, the header should define H5_HAVE_PARALLEL. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ #include "hdf5.h" @@ -837,7 +906,6 @@ if test "$enable_warn" != "no"; then ;; esac - # Add a "choke on warning" flag if it exists if test "$enable_warn" = "error"; then case "$ax_cv_c_compiler_vendor" in @@ -1228,22 +1296,21 @@ AC_MSG_RESULT([ $PACKAGE_NAME v.$PACKAGE_VERSION - Compiler : $CC - - vendor : $ax_cv_c_compiler_vendor - - version : $ax_cv_c_compiler_version - - flags : $CFLAGS - MPI enabled : $enable_mpi - HDF5 enabled : $with_hdf5 - - parallel : $have_parallel_hdf5 - Metis enabled : $have_metis - FFTW3 enabled : $have_fftw - GSL enabled : $have_gsl - libNUMA enabled : $have_numa - GRACKLE enabled : $have_grackle - Using tcmalloc : $have_tcmalloc - Using jemalloc : $have_jemalloc - CPU profiler : $have_profiler - Pthread barriers : $have_pthread_barrier + Compiler : $CC + - vendor : $ax_cv_c_compiler_vendor + - version : $ax_cv_c_compiler_version + - flags : $CFLAGS + MPI enabled : $enable_mpi + HDF5 enabled : $with_hdf5 + - parallel : $have_parallel_hdf5 + Metis enabled : $have_metis + FFTW3 enabled : $have_fftw + GSL enabled : $have_gsl + libNUMA enabled : $have_numa + GRACKLE enabled : $have_grackle + Special allocators : $have_special_allocator + CPU profiler : $have_profiler + Pthread barriers : $have_pthread_barrier Hydro scheme : $with_hydro Dimensionality : $with_dimension 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/src/common_io.c b/src/common_io.c index 8b173adb7b5e5a014b0967b4fd04aef5ee6606e9..88374e30cccfa619352aed5c7e401bf163d6db63 100644 --- a/src/common_io.c +++ b/src/common_io.c @@ -340,6 +340,7 @@ void io_write_code_description(hid_t h_file) { io_write_attribute_s(h_grpcode, "CFLAGS", compilation_cflags()); io_write_attribute_s(h_grpcode, "HDF5 library version", hdf5_version()); io_write_attribute_s(h_grpcode, "Thread barriers", thread_barrier_version()); + io_write_attribute_s(h_grpcode, "Allocators", allocator_version()); #ifdef HAVE_FFTW io_write_attribute_s(h_grpcode, "FFTW library version", fftw3_version()); #endif diff --git a/src/version.c b/src/version.c index 54749721de96bde010f56965152c536b08672230..a0a2ae42a5ce1a24ffce43f7ae3f59e1d6ed4168 100644 --- a/src/version.c +++ b/src/version.c @@ -368,6 +368,26 @@ const char *thread_barrier_version(void) { return version; } +/** + * @brief return the allocator library used in SWIFT. + * + * @result description of the allocation library + */ +const char *allocator_version(void) { + + static char version[256] = {0}; +#if defined(HAVE_TBBMALLOC) + sprintf(version, "TBB malloc"); +#elif defined(HAVE_TCMALLOC) + sprintf(version, "tc-malloc"); +#elif defined(HAVE_JEMALLOC) + sprintf(version, "je-malloc"); +#else + sprintf(version, "Compiler version (probably glibc)"); +#endif + return version; +} + /** * @brief Prints a greeting message to the standard output containing code * version and revision number diff --git a/src/version.h b/src/version.h index 3163f242c50e56c64cc709b13dfe926f93672a00..44119b6a3bbdf57c3f0195bae5ff329d05c61fd5 100644 --- a/src/version.h +++ b/src/version.h @@ -36,6 +36,7 @@ const char* hdf5_version(void); const char* fftw3_version(void); const char* libgsl_version(void); const char* thread_barrier_version(void); +const char* allocator_version(void); void greetings(void); #endif /* SWIFT_VERSION_H */ 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 \