Merge "Merge branch origin/release-5-0"
authorTeemu Murtola <teemu.murtola@gmail.com>
Mon, 18 May 2015 14:42:35 +0000 (16:42 +0200)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Mon, 18 May 2015 14:42:35 +0000 (16:42 +0200)
19 files changed:
CMakeLists.txt
cmake/FindFFTW.cmake
cmake/gmxManageFFTLibraries.cmake
cmake/gmxManageSharedLibraries.cmake
docs/install-guide/index.rst
docs/manual/forcefield.tex
docs/user-guide/mdp-options.rst
src/contrib/fftw/CMakeLists.txt
src/external/boost/README
src/external/boost/boost/smart_ptr/detail/shared_count.hpp
src/external/boost/boost/smart_ptr/scoped_ptr.hpp
src/external/boost/boost/smart_ptr/shared_ptr.hpp
src/external/gmock-1.7.0/CMakeLists.txt
src/gromacs/gmxana/gmx_covar.c
src/gromacs/gmxlib/typedefs.c
src/gromacs/gmxpreprocess/grompp.c
src/gromacs/mdlib/nbnxn_cuda/nbnxn_cuda.cu
src/testutils/TestMacros.cmake
tests/CMakeLists.txt

index 79e7f1ef2fa0c4f11af6ac40d0c554c2e100cf24..3c1be02f87223bdb5ba26aadce70911996d3ed7b 100644 (file)
@@ -244,6 +244,11 @@ option(GMX_DEVELOPER_BUILD
     OFF)
 mark_as_advanced(GMX_DEVELOPER_BUILD)
 
+option(GMX_BUILD_SHARED_EXE
+    "Build exectuables as shared binaries. If not set, this disables rpath and dynamic linker flags in an attempt to build a static binary, but this may require setting up the toolchain properly and making appropriate libraries available."
+    ON)
+mark_as_advanced(GMX_BUILD_SHARED_EXE)
+
 ######################################################################
 # Detect OpenMP support
 ######################################################################
@@ -771,7 +776,13 @@ include(gmxManageSuffixes)
 # CMake supports RPATH on OS X only from 2.8.12 upwards.
 # CMAKE_SYSTEM_VERSION > 8.0 matches OS X 10.5 and above, where RPATH support
 # was added.
-if((NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin") OR
+
+if(NOT GMX_BUILD_SHARED_EXE)
+    # No rpath
+    set(CMAKE_SKIP_RPATH TRUE)
+    set(CMAKE_EXE_LINK_DYNAMIC_C_FLAGS) # remove -Wl,-Bdynamic
+    set(CMAKE_EXE_LINK_DYNAMIC_CXX_FLAGS)
+elseif((NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin") OR
    ((CMAKE_SYSTEM_VERSION VERSION_GREATER 8.0) AND (NOT CMAKE_VERSION VERSION_LESS 2.8.12)))
     # The build folder always has bin/ and lib/; if we are also going to
     # install to lib/, then the installation RPATH works also in the build
index 326805a163df244547184e715a4f0e03ff61b9d0..dbe8f92c4bcc731bb6ef25f3f43432c375a1cb56 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
+# Copyright (c) 2012,2013,2014,2015, by the GROMACS development team, led by
 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
 # and including many others, as listed in the AUTHORS file in the
 # top-level source directory and at http://www.gromacs.org.
@@ -100,14 +100,50 @@ if (${FFTW}_FOUND)
     message(FATAL_ERROR "Could not find ${${FFTW}_FUNCTION_PREFIX}_plan_r2r_1d in ${${FFTW}_LIBRARY}, take a look at the error message in ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log to find out what went wrong. If you are using a static lib (.a) make sure you have specified all dependencies of ${${FFTW}_PKG} in ${FFTW}_LIBRARY by hand (e.g. -D${FFTW}_LIBRARY='/path/to/lib${${FFTW}_PKG}.so;/path/to/libm.so') !")
   endif()
 
-  # Check for FFTW3 compiled with --enable-avx, which is slower for GROMACS than --enable-sse or --enable-sse2
-  foreach(AVX_FUNCTION ${${FFTW}_FUNCTION_PREFIX}_have_simd_avx)
+  # Check for FFTW3 compiled with --enable-sse
+  foreach(SSE_FUNCTION ${${FFTW}_FUNCTION_PREFIX}_have_simd_sse)
     if (FFTW_LIBRARY_CHANGED)
-      unset(${FFTW}_HAVE_${AVX_FUNCTION} CACHE)
+      unset(${FFTW}_HAVE_${SSE_FUNCTION} CACHE)
     endif()
-    check_library_exists("${${FFTW}_LIBRARIES}" "${AVX_FUNCTION}" "" ${FFTW}_HAVE_${AVX_FUNCTION})
-    if(${FFTW}_HAVE_${AVX_FUNCTION})
-      set(${FFTW}_HAVE_AVX TRUE)
+    check_library_exists("${${FFTW}_LIBRARIES}" "${SSE_FUNCTION}" "" ${FFTW}_HAVE_${SSE_FUNCTION})
+    if(${FFTW}_HAVE_${SSE_FUNCTION})
+      set(${FFTW}_HAVE_SSE TRUE)
+      break()
+    endif()
+  endforeach()
+
+  # Check for FFTW3 compiled with --enable-sse2
+  foreach(SSE2_FUNCTION ${${FFTW}_FUNCTION_PREFIX}_have_simd_sse2)
+    if (FFTW_LIBRARY_CHANGED)
+      unset(${FFTW}_HAVE_${SSE2_FUNCTION} CACHE)
+    endif()
+    check_library_exists("${${FFTW}_LIBRARIES}" "${SSE2_FUNCTION}" "" ${FFTW}_HAVE_${SSE2_FUNCTION})
+    if(${FFTW}_HAVE_${SSE2_FUNCTION})
+      set(${FFTW}_HAVE_SSE2 TRUE)
+      break()
+    endif()
+  endforeach()
+
+  # Check for FFTW3 with 128-bit AVX compiled with --enable-avx
+  foreach(AVX_128_FUNCTION ${${FFTW}_FUNCTION_PREFIX}_have_simd_avx_128)
+    if (FFTW_LIBRARY_CHANGED)
+      unset(${FFTW}_HAVE_${AVX_128_FUNCTION} CACHE)
+    endif()
+    check_library_exists("${${FFTW}_LIBRARIES}" "${AVX_128_FUNCTION}" "" ${FFTW}_HAVE_${AVX_128_FUNCTION})
+    if(${FFTW}_HAVE_${AVX_128_FUNCTION})
+      set(${FFTW}_HAVE_AVX_128 TRUE)
+      break()
+    endif()
+  endforeach()
+
+  # Check for FFTW3 with 128-bit AVX2 compiled with --enable-avx2
+  foreach(AVX2_128_FUNCTION ${${FFTW}_FUNCTION_PREFIX}_have_simd_avx2_128)
+    if (FFTW_LIBRARY_CHANGED)
+      unset(${FFTW}_HAVE_${AVX2_128_FUNCTION} CACHE)
+    endif()
+    check_library_exists("${${FFTW}_LIBRARIES}" "${AVX2_128_FUNCTION}" "" ${FFTW}_HAVE_${AVX2_128_FUNCTION})
+    if(${FFTW}_HAVE_${AVX2_128_FUNCTION})
+      set(${FFTW}_HAVE_AVX2_128 TRUE)
       break()
     endif()
   endforeach()
index 104576d4b3a6c3932f1df3e88ee62a6e2eaa33a0..f8fcc47b16660e8e3ef380ae99211fcda1e11a63 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
+# Copyright (c) 2012,2013,2014,2015, by the GROMACS development team, led by
 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
 # and including many others, as listed in the AUTHORS file in the
 # top-level source directory and at http://www.gromacs.org.
@@ -65,6 +65,12 @@ if(${GMX_FFT_LIBRARY} STREQUAL "FFTW3")
         set(FFTW fftwf)
     endif()
 
+    # Note that these calls are expected to function the same way,
+    # particularly with respect to setting CMake variables that
+    # record the presence of particular FFTW SIMD support.
+    # TODO There is no need for this requirement, all the remaining
+    # code here can be refactored to have just one check of
+    # GMX_BUILD_OWN_FFTW, which simplifies both code paths.
     if(GMX_BUILD_OWN_FFTW)
       add_subdirectory(src/contrib/fftw)
     else()
@@ -87,11 +93,11 @@ if(${GMX_FFT_LIBRARY} STREQUAL "FFTW3")
 
     if ((${GMX_SIMD} MATCHES "SSE" OR ${GMX_SIMD} MATCHES "AVX") AND NOT ${FFTW}_HAVE_SIMD)
       message(WARNING "The fftw library found is compiled without SIMD support, which makes it slow. Consider recompiling it or contact your admin")
-    endif()
-
-    if((${GMX_SIMD} MATCHES "SSE" OR ${GMX_SIMD} MATCHES "AVX") AND ${FFTW}_HAVE_AVX)
-        # If we're not using SIMD instructions, we don't care about FFTW performance on x86 either
-        message(WARNING "The FFTW library was compiled with --enable-avx to enable AVX SIMD instructions. That might sound like a good idea for your processor, but for FFTW versions up to 3.3.3, these are slower than the SSE/SSE2 SIMD instructions for the way GROMACS uses FFTs. Limitations in the way FFTW allows GROMACS to measure performance make it awkward for either GROMACS or FFTW to make the decision for you based on runtime performance. You should compile a different FFTW library with --enable-sse or --enable-sse2. If you have a more recent FFTW, you may like to compare the performance of GROMACS with FFTW libraries compiled with and without --enable-avx. However, the GROMACS developers do not really expect the FFTW AVX optimization to help, because the performance is limited by memory access, not computation.")
+    else()
+      if(${GMX_SIMD} MATCHES "AVX" AND NOT (${FFTW}_HAVE_SSE OR ${FFTW}_HAVE_SSE2 OR ${FFTW}_HAVE_AVX_128 OR ${FFTW}_HAVE_AVX2_128))
+        # If we end up here we have an AVX Gromacs build, and FFTW with SIMD, but no 128-bit SIMD, this means AVX is enabled for FFTW.
+        message(WARNING "The FFTW library was compiled with neither --enable-sse nor --enable-sse2; those would have enabled SSE(2) SIMD instructions. This will give suboptimal performance. You should (re)compile the FFTW library with both SSE2 and AVX instruction support (use both --enable-sse2 and --enable-avx). The FFTW library will determine at runtime which SIMD instruction set is fastest for different parts of the FFTs.")
+        endif()
     endif()
 
     set(FFT_STATUS_MESSAGE "Using external FFT library - FFTW3")
index 75bb7c80802c2a3b5f53f2b290e9dbf078beb8e2..aef18bd15dff486fde7cc39f1ca05705b93646d4 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
+# Copyright (c) 2012,2013,2014,2015, by the GROMACS development team, led by
 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
 # and including many others, as listed in the AUTHORS file in the
 # top-level source directory and at http://www.gromacs.org.
@@ -63,6 +63,10 @@ set(GMX_PREFER_STATIC_LIBS_DEFAULT OFF)
 if (WIN32 AND NOT BUILD_SHARED_LIBS)
     set(GMX_PREFER_STATIC_LIBS_DEFAULT ON)
 endif()
+if (NOT GMX_BUILD_SHARED_EXE)
+    set(GMX_PREFER_STATIC_LIBS_DEFAULT ON)
+    set(SHARED_LIBS_DEFAULT OFF)
+endif()
 
 # Declare the user-visible options
 option(BUILD_SHARED_LIBS "Enable shared libraries (can be problematic e.g. with MPI, or on some HPC systems)" ${SHARED_LIBS_DEFAULT})
index ab66e6170757706cac02f50573f74d08174cf7d0..3eb21f5afa0dc39d27b79eb4f86515964836db25 100644 (file)
@@ -587,6 +587,13 @@ simulation using MPI libraries (e.g. BlueGene, Cray).
   where that is the default. To use static system libraries,
   additional compiler/linker flags are necessary, e.g. ``-static-libgcc
   -static-libstdc++``.
+* To attempt to link a fully static binary set
+  ``-DGMX_BUILD_SHARED_EXE=OFF``. This will prevent CMake from explicitly
+  setting any dynamic linking flags. This option also sets
+  ``-DBUILD_SHARED_LIBS=OFF`` and ``-DGMX_PREFER_STATIC_LIBS=ON`` by
+  default, but the above caveats apply. For compilers which don't
+  default to static linking, the required flags have to be specified. On
+  Linux, this is usually ``CFLAGS=-static CXXFLAGS=-static``.
 
 Portability aspects
 ^^^^^^^^^^^^^^^^^^^
@@ -949,13 +956,10 @@ Building on Cray
 ----------------
 |Gromacs| builds mostly out of the box on modern Cray machines, but
 
-* you may need to specify the use of static or dynamic libraries
-  (depending on the machine) with ``-DBUILD_SHARED_LIBS=off``,
+* you may need to specify the use of static binaries
+  with ``-DGMX_BUILD_SHARED_EXE=off``,
 * you may need to set the F77 environmental variable to ``ftn`` when
   compiling FFTW,
-* you may need to use ``-DCMAKE_SKIP_RPATH=YES``, and
-* you may need to modify the CMakeLists.txt files to specify the
-  ``BUILD_SEARCH_END_STATIC`` target property.
 
 Building on BlueGene
 --------------------
index 7e835ae7fb3c15b492697991ea5ac6afa4b7f7f1..7cffdd3b288ce3e6caa5accf890fbe688a274589 100644 (file)
@@ -1898,14 +1898,17 @@ and close to 0 and/or 1 with $p=2$. Lowering {\tt\mbox{sc-sigma}} will decrease
 this effect, but it will also increase the interactions with hydrogens
 relative to the other interactions in the soft-core state.
 
-When soft core potentials are selected (by setting {\tt sc-alpha} \textgreater
+When soft-core potentials are selected (by setting {\tt sc-alpha} \textgreater
 0), and the Coulomb and Lennard-Jones potentials are turned on or off
 sequentially, then the Coulombic interaction is turned off linearly,
-rather than using soft core interactions, which should be less
-statistically noisy in most cases.  This behavior can be overwritten
-by using the mdp option {\tt sc-coul} to {\tt yes}. Additionally, the
-soft-core interaction potential is only applied when either the A or B
-state has zero interaction potential.  If both A and B states have
+rather than using soft-core interactions, which should be less
+statistically noisy in most cases. This behavior can be overwritten
+by using the mdp option {\tt sc-coul} to {\tt yes}. Note that the {\tt sc-coul}
+is only taken into account when lambda states are used, not with
+{\tt couple-lambda0/couple-lambda1}, and you can still turn off soft-core
+interactions by setting {\tt sc-alpha=0}. Additionally, the soft-core
+interaction potential is only applied when either the A or B
+state has zero interaction potential. If both A and B states have
 nonzero interaction potential, default linear scaling described above
 is used. When both Coulombic and Lennard-Jones interactions are turned
 off simultaneously, a soft-core potential is used, and a hydrogen is
index 758de39b487964a63dfa89037af64343ef16093d..5767bd4f9966c9405716e61103c595bdffdbce84 100644 (file)
@@ -2104,11 +2104,14 @@ Free energy calculations
 .. mdp:: sc-coul
 
    (no)
-   Whether to apply the soft core free energy interaction
+   Whether to apply the soft-core free energy interaction
    transformation to the Columbic interaction of a molecule. Default
    is no, as it is generally more efficient to turn off the Coulomic
    interactions linearly before turning off the van der Waals
-   interactions.
+   interactions. Note that it is only taken into account when lambda
+   states are used, not with :mdp:`couple-lambda0` /
+   :mdp:`couple-lambda1`, and you can still turn off soft-core
+   interactions by setting :mdp:`sc-alpha` to 0.
 
 .. mdp:: sc-power
 
index c7d72989521fdc46130dbb3ae5e06bd1521b933f..2ad1501c685bbdcc71c10e9145d2be93ce39b0b7 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
+# Copyright (c) 2012,2013,2014,2015, by the GROMACS development team, led by
 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
 # and including many others, as listed in the AUTHORS file in the
 # top-level source directory and at http://www.gromacs.org.
@@ -40,6 +40,9 @@
 # Input: FFTW variable contains the FFTW component to build,
 #        either fftw or fftwf for double or single precision
 
+string(TOUPPER "${FFTW}" UPPERFFTW)
+string(TOLOWER "${FFTW}" LOWERFFTW)
+
 set(GMX_BUILD_OWN_FFTW_OPTIMIZATION_CONFIGURATION "" CACHE INTERNAL "Optimization flags for FFTW compilation")
 if(${CMAKE_CURRENT_BINARY_DIR} MATCHES ".*[[:space:]].*")
     message(FATAL_ERROR "An internal limitation of FFTW means GROMACS cannot build FFTW in a directory with whitespace in its name. Either use a system FFTW, build it yourself, or build GROMACS in a different location.")
@@ -58,6 +61,9 @@ endif()
 # Testing shows FFTW configured with --enable-avx is never better than --enable-sse2, so we do the latter always.
 if(${GMX_SIMD} MATCHES "^(SSE|AVX)")
     set(GMX_BUILD_OWN_FFTW_OPTIMIZATION_CONFIGURATION --enable-sse2 CACHE INTERNAL "Optimization flags for FFTW compilation")
+    # Fake the result of the SIMD test, so the checks for x86 SIMD
+    # suport are silent
+    set(${UPPERFFTW}_HAVE_SSE2 TRUE PARENT_SCOPE)
 endif()
 
 # Allow cross-compiles
@@ -117,12 +123,11 @@ endif()
 
 ExternalProject_get_property(${EXTERNAL_FFTW_BUILD_TARGET} INSTALL_DIR)
 
-string(TOUPPER "${FFTW}" UPPERFFTW)
-string(TOLOWER "${FFTW}" LOWERFFTW)
 string(REGEX REPLACE "fftw" "fftw3" FFTW_LIBNAME ${LOWERFFTW})
 set(${UPPERFFTW}_LIBRARIES ${INSTALL_DIR}/lib/lib${FFTW_LIBNAME}${CMAKE_STATIC_LIBRARY_SUFFIX})
 set(${UPPERFFTW}_INCLUDE_DIRS ${INSTALL_DIR}/include PARENT_SCOPE)
 set(${UPPERFFTW}_FOUND TRUE PARENT_SCOPE)
+# TODO This is only true on x86, but does not actually cause a problem
 set(${UPPERFFTW}_HAVE_SIMD TRUE PARENT_SCOPE)
 
 add_library(gmxfftw STATIC IMPORTED GLOBAL)
index 2f193803f39bd25aa642a2b46a85392174853706..d1d21d83fa5981b776672450d995fbdd1d0c162d 100644 (file)
@@ -1,7 +1,8 @@
 Steps to produce minimal version of BOOST:
 1) Download Boost (current minimal version is derived from 1.55.0)
 2) Extract
-3) Edit Boost files to uncomment unnessary includes (search for GMX in minimal version and copy all changes)
+3) Edit Boost files to uncomment unnessary includes and insert warning-suppression pragmas
+   (search for GMX in minimal version and copy all changes)
    Alternative make a patch by diffing against unmodified version and applying patch. Such as
    diff /path/to/boost_1_55_0 . -rwu |grep -v ^"Only in" > patch && patch -p? < patch
 4) Make sure our subset works even with compilers not listed
index 8e1dd4810a797aef92ec2dd0352d22db385537f8..b342d2d27fe1c277425a7d9f35eaa796c2a4137d 100644 (file)
 # include <boost/utility/addressof.hpp>
 #endif
 
+//GMX_INSERTED
+#if (__GNUC__ >= 5)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
+
 namespace boost
 {
 
@@ -596,6 +602,11 @@ inline shared_count::shared_count( weak_count const & r, sp_nothrow_tag ): pi_(
 
 } // namespace boost
 
+//GMX_INSERTED
+#if (__GNUC__ >= 5)
+#pragma GCC diagnostic pop
+#endif
+
 #ifdef __BORLANDC__
 # pragma warn .8027     // Functions containing try are not expanded inline
 #endif
index be6722d5f52e5f1a6f84498bc5461b58b1883e5b..7da1d32a94660417d76eda0ecd383af1cf57cfe0 100644 (file)
 # include <memory>          // for std::auto_ptr
 #endif
 
+//GMX_INSERTED
+#if (__GNUC__ >= 5)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
+
 namespace boost
 {
 
@@ -154,4 +160,9 @@ template<class T> inline T * get_pointer(scoped_ptr<T> const & p) BOOST_NOEXCEPT
 
 } // namespace boost
 
+//GMX_INSERTED
+#if (__GNUC__ >= 5)
+#pragma GCC diagnostic pop
+#endif
+
 #endif // #ifndef BOOST_SMART_PTR_SCOPED_PTR_HPP_INCLUDED
index 9259ca0f06d59647603c2ade590ddff8624fd697..953092ba3a1ec9e6eb08862d3a502d84bb03473f 100644 (file)
 #endif
 #endif
 
+//GMX_INSERTED
+#if (__GNUC__ >= 5)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
+
 namespace boost
 {
 
@@ -1030,6 +1036,11 @@ template< class T > std::size_t hash_value( boost::shared_ptr<T> const & p ) BOO
 
 } // namespace boost
 
+//GMX_INSERTED
+#if (__GNUC__ >= 5)
+#pragma GCC diagnostic pop
+#endif
+
 #endif  // #if defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(BOOST_MSVC6_MEMBER_TEMPLATES)
 
 #endif  // #ifndef BOOST_SMART_PTR_SHARED_PTR_HPP_INCLUDED
index b9a0f2aada7b4c3182a86679eea043c33d261234..3a9b8af5b971525618806fcba19b6155ba831c01 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2011,2012,2013,2014, by the GROMACS development team, led by
+# Copyright (c) 2011,2012,2013,2014,2015, by the GROMACS development team, led by
 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
 # and including many others, as listed in the AUTHORS file in the
 # top-level source directory and at http://www.gromacs.org.
 # As stated in README.Gromacs, this file is not part of GMock, but is written
 # specifically for the GROMACS build system from scratch.
 
+include(CheckCXXCompilerFlag)
+check_cxx_compiler_flag("-Wno-unused-variable" HAS_NO_UNUSED_VARIABLE)
+
+# Avoid compiler warnings with GCC 5, which doesn't like the way
+# Google Test makes int variables that hold the results of
+# value-parameterized test registration calls, and then doesn't use
+# them. Because these definitions are created by the
+# test-instantiation macros, there's no good way to suppress them;
+# we'd prefer to avoid modifying Google Test source, and don't wish to
+# embed compiler-specific suppressions in all our test-code source
+# files.
+#
+# TODO When updating the embedded Google Test version in future, check
+# if this is still needed
+#
+# TODO If other compilers start complaining similarly, consider a
+# unilateral suppression, like we use for the Google Mock source code
+# itself.
+if(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5")
+    if(HAS_NO_UNUSED_VARIABLE)
+        set(GMOCK_COMPILE_FLAGS "-Wno-unused-variable")
+    endif()
+endif()
+
 include(gmxGetGmockTupleWorkaround)
 get_gmock_tuple_workaround(GMOCK_COMPILE_DEFINITIONS)
 
@@ -59,8 +83,6 @@ include_directories(BEFORE ${GTEST_DIR})
 include_directories(BEFORE ${GMOCK_INCLUDE_DIRS})
 include_directories(BEFORE ${GMOCK_DIR})
 
-include(CheckCXXCompilerFlag)
-check_cxx_compiler_flag(-Wno-unused-variable HAS_NO_UNUSED_VARIABLE)
 if (HAS_NO_UNUSED_VARIABLE)
     set_source_files_properties(${GTEST_SOURCES} PROPERTIES COMPILE_FLAGS "-Wno-unused-variable")
 endif()
@@ -68,9 +90,11 @@ endif()
 add_library(gmock STATIC ${UNITTEST_TARGET_OPTIONS} ${GMOCK_SOURCES} ${GTEST_SOURCES})
 set_property(TARGET gmock APPEND PROPERTY COMPILE_DEFINITIONS
              "_GNU_SOURCE=1;${GMOCK_COMPILE_DEFINITIONS};GTEST_CAN_STREAM_RESULTS=0")
+set_property(TARGET gmock APPEND PROPERTY COMPILE_FLAGS "${GMOCK_COMPILE_FLAGS}")
 
 set(GMOCK_LIBRARIES gmock ${PTHREADS_LIBRARIES} PARENT_SCOPE)
 set(GTEST_LIBRARIES ${GMOCK_LIBRARIES} PARENT_SCOPE)
 set(GMOCK_INCLUDE_DIRS ${GMOCK_INCLUDE_DIRS} PARENT_SCOPE)
 set(GTEST_INCLUDE_DIRS ${GTEST_INCLUDE_DIRS} PARENT_SCOPE)
 set(GMOCK_COMPILE_DEFINITIONS ${GMOCK_COMPILE_DEFINITIONS} PARENT_SCOPE)
+set(GMOCK_COMPILE_FLAGS "${GMOCK_COMPILE_FLAGS}" PARENT_SCOPE)
index 1cebf83afb961b41c8776bb2292fdd63f57256bd..bad3518ababad410abcb8c924d8ff9d719c8dfcd 100644 (file)
@@ -544,9 +544,9 @@ int gmx_covar(int argc, char *argv[])
         if (nframes-1 < ndim)
         {
             end = nframes-1;
-            fprintf(out, "WARNING: there are fewer frames in your trajectory than there are\n");
-            fprintf(out, "degrees of freedom in your system. Only generating the first\n");
-            fprintf(out, "%d out of %d eigenvectors and eigenvalues.\n", end, (int)ndim);
+            fprintf(stderr, "\nWARNING: there are fewer frames in your trajectory than there are\n");
+            fprintf(stderr, "degrees of freedom in your system. Only generating the first\n");
+            fprintf(stderr, "%d out of %d eigenvectors and eigenvalues.\n", end, (int)ndim);
         }
         else
         {
index 134f8c0ca55a3d1e4829d4f7c7550360d5e762f5..ca19c6c39ca02cef6b8aba0695d3750e036763c1 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -307,9 +307,10 @@ void init_state(t_state *state, int natoms, int ngtc, int nnhpres, int nhchainle
 {
     int i;
 
-    state->natoms = natoms;
-    state->flags  = 0;
-    state->lambda = 0;
+    state->natoms    = natoms;
+    state->flags     = 0;
+    state->fep_state = 0;
+    state->lambda    = 0;
     snew(state->lambda, efptNR);
     for (i = 0; i < efptNR; i++)
     {
index 83b4638ae40149e89c309b6667e686016d995bfc..345822e4127be4639c7182f9d1086de23fc880cf 100644 (file)
@@ -1515,7 +1515,7 @@ int gmx_grompp(int argc, char *argv[])
     t_inputrec        *ir;
     int                natoms, nvsite, comb, mt;
     t_params          *plist;
-    t_state            state;
+    t_state           *state;
     matrix             box;
     real               max_spacing, fudgeQQ;
     double             reppow;
@@ -1634,8 +1634,9 @@ int gmx_grompp(int argc, char *argv[])
     {
         gmx_fatal(FARGS, "%s does not exist", fn);
     }
+    snew(state, 1);
     new_status(fn, opt2fn_null("-pp", NFILE, fnm), opt2fn("-c", NFILE, fnm),
-               opts, ir, bZero, bGenVel, bVerbose, &state,
+               opts, ir, bZero, bGenVel, bVerbose, state,
                atype, sys, &nmi, &mi, plist, &comb, &reppow, &fudgeQQ,
                opts->bMorse,
                wi);
@@ -1824,7 +1825,7 @@ int gmx_grompp(int argc, char *argv[])
     /* Check velocity for virtual sites and shells */
     if (bGenVel)
     {
-        check_vel(sys, state.v);
+        check_vel(sys, state->v);
     }
 
     /* check for shells and inpurecs */
@@ -1856,7 +1857,7 @@ int gmx_grompp(int argc, char *argv[])
     }
     do_index(mdparin, ftp2fn_null(efNDX, NFILE, fnm),
              sys, bVerbose, ir,
-             bGenVel ? state.v : NULL,
+             bGenVel ? state->v : NULL,
              wi);
 
     if (ir->cutoff_scheme == ecutsVERLET && ir->verletbuf_tol > 0 &&
@@ -1874,7 +1875,7 @@ int gmx_grompp(int argc, char *argv[])
                 }
                 else
                 {
-                    buffer_temp = calc_temp(sys, ir, state.v);
+                    buffer_temp = calc_temp(sys, ir, state->v);
                 }
                 if (buffer_temp > 0)
                 {
@@ -1925,13 +1926,13 @@ int gmx_grompp(int argc, char *argv[])
                     warning_note(wi, warn_buf);
                 }
 
-                set_verlet_buffer(sys, ir, buffer_temp, state.box, wi);
+                set_verlet_buffer(sys, ir, buffer_temp, state->box, wi);
             }
         }
     }
 
     /* Init the temperature coupling state */
-    init_gtc_state(&state, ir->opts.ngtc, 0, ir->opts.nhchainlength); /* need to add nnhpres here? */
+    init_gtc_state(state, ir->opts.ngtc, 0, ir->opts.nhchainlength); /* need to add nnhpres here? */
 
     if (bVerbose)
     {
@@ -1971,24 +1972,24 @@ int gmx_grompp(int argc, char *argv[])
             fprintf(stderr, "getting data from old trajectory ...\n");
         }
         cont_status(ftp2fn(efTRN, NFILE, fnm), ftp2fn_null(efEDR, NFILE, fnm),
-                    bNeedVel, bGenVel, fr_time, ir, &state, sys, oenv);
+                    bNeedVel, bGenVel, fr_time, ir, state, sys, oenv);
     }
 
     if (ir->ePBC == epbcXY && ir->nwall != 2)
     {
-        clear_rvec(state.box[ZZ]);
+        clear_rvec(state->box[ZZ]);
     }
 
     if (ir->cutoff_scheme != ecutsVERLET && ir->rlist > 0)
     {
         set_warning_line(wi, mdparin, -1);
-        check_chargegroup_radii(sys, ir, state.x, wi);
+        check_chargegroup_radii(sys, ir, state->x, wi);
     }
 
     if (EEL_FULL(ir->coulombtype) || EVDW_PME(ir->vdwtype))
     {
         /* Calculate the optimal grid dimensions */
-        copy_mat(state.box, box);
+        copy_mat(state->box, box);
         if (ir->ePBC == epbcXY && ir->nwall == 2)
         {
             svmul(ir->wall_ewald_zfac, box[ZZ], box[ZZ]);
@@ -2012,13 +2013,13 @@ int gmx_grompp(int argc, char *argv[])
        potentially conflict if not handled correctly. */
     if (ir->efep != efepNO)
     {
-        state.fep_state = ir->fepvals->init_fep_state;
+        state->fep_state = ir->fepvals->init_fep_state;
         for (i = 0; i < efptNR; i++)
         {
             /* init_lambda trumps state definitions*/
             if (ir->fepvals->init_lambda >= 0)
             {
-                state.lambda[i] = ir->fepvals->init_lambda;
+                state->lambda[i] = ir->fepvals->init_lambda;
             }
             else
             {
@@ -2028,7 +2029,7 @@ int gmx_grompp(int argc, char *argv[])
                 }
                 else
                 {
-                    state.lambda[i] = ir->fepvals->all_lambda[i][state.fep_state];
+                    state->lambda[i] = ir->fepvals->all_lambda[i][state->fep_state];
                 }
             }
         }
@@ -2036,12 +2037,12 @@ int gmx_grompp(int argc, char *argv[])
 
     if (ir->bPull)
     {
-        set_pull_init(ir, sys, state.x, state.box, state.lambda[efptMASS], oenv);
+        set_pull_init(ir, sys, state->x, state->box, state->lambda[efptMASS], oenv);
     }
 
     if (ir->bRot)
     {
-        set_reference_positions(ir->rot, state.x, state.box,
+        set_reference_positions(ir->rot, state->x, state->box,
                                 opt2fn("-ref", NFILE, fnm), opt2bSet("-ref", NFILE, fnm),
                                 wi);
     }
@@ -2050,7 +2051,7 @@ int gmx_grompp(int argc, char *argv[])
 
     if (EEL_PME(ir->coulombtype))
     {
-        float ratio = pme_load_estimate(sys, ir, state.box);
+        float ratio = pme_load_estimate(sys, ir, state->box);
         fprintf(stderr, "Estimate for the relative computational load of the PME mesh part: %.2f\n", ratio);
         /* With free energy we might need to do PME both for the A and B state
          * charges. This will double the cost, but the optimal performance will
@@ -2092,11 +2093,13 @@ int gmx_grompp(int argc, char *argv[])
     }
 
     done_warning(wi, FARGS);
-    write_tpx_state(ftp2fn(efTPR, NFILE, fnm), ir, &state, sys);
+    write_tpx_state(ftp2fn(efTPR, NFILE, fnm), ir, state, sys);
 
     /* Output IMD group, if bIMD is TRUE */
-    write_IMDgroup_to_file(ir->bIMD, ir, &state, sys, NFILE, fnm);
+    write_IMDgroup_to_file(ir->bIMD, ir, state, sys, NFILE, fnm);
 
+    done_state(state);
+    sfree(state);
     done_atomtype(atype);
     done_mtop(sys, TRUE);
     done_inputrec_strings();
index 7f1102a8cf110deae40759f6088151cfbb84b8fa..3ab80b45d6203daa653e36fa94e7e2337447b458 100644 (file)
@@ -170,6 +170,9 @@ static inline int calc_nb_kernel_nblock(int nwork_units, gmx_device_info_t *dinf
     int max_grid_x_size;
 
     assert(dinfo);
+    /* CUDA does not accept grid dimension of 0 (which can happen e.g. with an
+       empty domain) and that case should be handled before this point. */
+    assert(nwork_units > 0);
 
     max_grid_x_size = dinfo->prop.maxGridSize[0];
 
@@ -348,7 +351,8 @@ void nbnxn_gpu_launch_kernel(gmx_nbnxn_cuda_t       *nb,
        we always call the local kernel, the local x+q copy and later (not in
        this function) the stream wait, local f copyback and the f buffer
        clearing. All these operations, except for the local interaction kernel,
-       are needed for the non-local interactions. */
+       are needed for the non-local interactions. The skip of the local kernel
+       call is taken care of later in this function. */
     if (iloc == eintNonlocal && plist->nsci == 0)
     {
         return;
@@ -399,6 +403,12 @@ void nbnxn_gpu_launch_kernel(gmx_nbnxn_cuda_t       *nb,
         CU_RET_ERR(stat, "cudaEventRecord failed");
     }
 
+    if (plist->nsci == 0)
+    {
+        /* Don't launch an empty local kernel (not allowed with CUDA) */
+        return;
+    }
+
     /* beginning of timed nonbonded calculation section */
     if (bDoTime)
     {
index 68b2b54784893b4f8b0215e8bc613125ac2816ff..b6ef24f748f6797d26c9b15eaba8c9f85e17cffb 100644 (file)
@@ -37,6 +37,7 @@ function (gmx_add_unit_test_object_library NAME)
         include_directories(BEFORE ${GMOCK_INCLUDE_DIRS})
         add_library(${NAME} OBJECT ${UNITTEST_TARGET_OPTIONS} ${ARGN})
         set_property(TARGET ${NAME} APPEND PROPERTY COMPILE_DEFINITIONS "${GMOCK_COMPILE_DEFINITIONS}")
+        set_property(TARGET ${NAME} APPEND PROPERTY COMPILE_FLAGS "${GMOCK_COMPILE_FLAGS}")
     endif()
 endfunction ()
 
@@ -45,6 +46,7 @@ function (gmx_build_unit_test NAME EXENAME)
         include_directories(BEFORE ${GMOCK_INCLUDE_DIRS})
         add_executable(${EXENAME} ${UNITTEST_TARGET_OPTIONS} ${ARGN} ${TESTUTILS_DIR}/unittest_main.cpp)
         set_property(TARGET ${EXENAME} APPEND PROPERTY COMPILE_DEFINITIONS "${GMOCK_COMPILE_DEFINITIONS}")
+        set_property(TARGET ${EXENAME} APPEND PROPERTY COMPILE_FLAGS "${GMOCK_COMPILE_FLAGS}")
         target_link_libraries(${EXENAME} ${TESTUTILS_LIBS} libgromacs ${GMOCK_LIBRARIES} ${GMX_EXE_LINKER_FLAGS})
         file(RELATIVE_PATH _input_files_path ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
         set(_temporary_files_path "${CMAKE_CURRENT_BINARY_DIR}/Testing/Temporary")
index 1f5d3d579bc34b89f72088e95917974799da5357..021be60c6ef400233385b8b703103fdceb4c8313 100644 (file)
@@ -40,8 +40,7 @@ option(REGRESSIONTEST_DOWNLOAD
 if(REGRESSIONTEST_DOWNLOAD)
     if (NOT SOURCE_IS_SOURCE_DISTRIBUTION)
         set(REGRESSIONTEST_URL http://gerrit.gromacs.org/snapshot/${REGRESSIONTEST_BRANCH})
-        set(REGRESSIONTEST_PATH "${CMAKE_CURRENT_BINARY_DIR}/regressiontests"
-            CACHE PATH "Path to auto-downloaded regressiontests" FORCE)
+        # REGRESSIONTEST_PATH for dev trees is set later based on the dirname found in the tar
     else()
         set(REGRESSIONTEST_URL http://gerrit.gromacs.org/download/regressiontests-${REGRESSIONTEST_VERSION}.tar.gz)
         set(REGRESSIONTEST_PATH
@@ -65,6 +64,18 @@ log: ${log}")
         if(NOT ${REGRESSIONTEST_MD5SUM} STREQUAL ${COMPUTED_MD5SUM})
             message(FATAL_ERROR "Download of regressiontests failed. Expected MD5 of ${REGRESSIONTEST_MD5SUM} but download has ${COMPUTED_MD5SUM}")
         endif()
+    else()
+        # Extract the REGRESSIONTEST_PATH from the tar when using dev tree.
+        execute_process(COMMAND ${CMAKE_COMMAND} -E tar tf "${REGRESSIONTEST_FILE}"
+                RESULT_VARIABLE _tar_tf_res
+                OUTPUT_VARIABLE _tar_tf_out)
+        if (${_tar_tf_res} EQUAL 0)
+            string(REGEX REPLACE "/\n.*$" "" _regressiontest_dir "${_tar_tf_out}")
+            set(REGRESSIONTEST_PATH "${CMAKE_CURRENT_BINARY_DIR}/${_regressiontest_dir}"
+                CACHE PATH "Path to auto-downloaded regressiontests" FORCE)
+        else()
+            message(FATAL_ERROR "Failed to list the contents of the downloaded tarball: ${REGRESSIONTEST_FILE}")
+        endif()
     endif()
 
     file(REMOVE_RECURSE "${REGRESSIONTEST_PATH}") #delete potential prior folder