From: Mark Abraham Date: Fri, 12 Feb 2021 13:02:37 +0000 (+0000) Subject: Improve CUDA codegen flags X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=a660b04e8d8756ed9c4dd355ad5d0d23d503eaa9;p=alexxy%2Fgromacs.git Improve CUDA codegen flags - onnly generate PTX for an early and the latest arch (3.5 and 8.0) - add binary 8.0 and 8.6 targets --- diff --git a/api/gmxapi/CMakeLists.txt b/api/gmxapi/CMakeLists.txt index 1fcf9b69ec..865abe2925 100644 --- a/api/gmxapi/CMakeLists.txt +++ b/api/gmxapi/CMakeLists.txt @@ -64,17 +64,12 @@ set_target_properties(gmxapi PROPERTIES if (GMX_LIB_MPI) # GROMACS is built against an MPI library. - # Clarification should be possible with resolution of #3672. set(_gmx_mpi_type "library") - # Ref https://cmake.org/cmake/help/v3.13/module/FindMPI.html#variables-for-using-mpi - find_package(MPI COMPONENTS CXX) - if (MPI_CXX_FOUND) -target_link_libraries(gmxapi PRIVATE MPI::MPI_CXX) - # If clients also need to link this target, we need to provide help in gmxapi-config.cmake - set(_gmxapi_find_dependencies "find_dependency(MPI COMPONENTS CXX)") - else() - message(FATAL_ERROR "Building gmxapi for MPI-enabled GROMACS, but no MPI toolchain found.") - endif () + # TODO: Normative solution with #3672. + # Do not target_link_options(gmxapi PRIVATE ${MPI_LINKER_FLAGS}) + # because the root CMakeLists.txt sets CMAKE_SHARED_LINKER_FLAGS. + target_compile_options(gmxapi PUBLIC ${MPI_COMPILE_FLAGS}) + target_link_libraries(gmxapi PUBLIC ${MPI_CXX_LIBRARIES}) elseif(GMX_THREAD_MPI) # GROMACS is built with its internal thread-MPI implementation. set(_gmx_mpi_type "tmpi") diff --git a/api/nblib/basicdefinitions.h b/api/nblib/basicdefinitions.h index 41dabd3270..ebb4d3f43d 100644 --- a/api/nblib/basicdefinitions.h +++ b/api/nblib/basicdefinitions.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2020, by the GROMACS development team, led by + * Copyright (c) 2020,2021, 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. @@ -88,6 +88,11 @@ constexpr const int N_IVEC = (N_BOX_Z * N_BOX_Y * N_BOX_X); //! Needed for generating Bolzmann velocity distribution (kJ/(mol K)) constexpr const real BOLTZ = (detail::RGAS / detail::KILO); /* */ +#ifndef M_PI +//! Required work-around for platforms that don't implement POSIX-style cmath header +# define M_PI 3.14159265358979323846 +#endif + //! Charge multiplication factor for Coulomb interactions constexpr const real ONE_4PI_EPS0 = (1.0 / (4.0 * M_PI * detail::EPSILON0)); diff --git a/cmake/gmxManageNvccConfig.cmake b/cmake/gmxManageNvccConfig.cmake index 12e54cb40e..b5f5663f4c 100644 --- a/cmake/gmxManageNvccConfig.cmake +++ b/cmake/gmxManageNvccConfig.cmake @@ -2,7 +2,7 @@ # This file is part of the GROMACS molecular simulation package. # # Copyright (c) 2012,2013,2014,2015,2016 by the GROMACS development team. -# Copyright (c) 2017,2018,2019,2020, by the GROMACS development team, led by +# Copyright (c) 2017,2018,2019,2020,2021, 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. @@ -101,11 +101,11 @@ if (GMX_CUDA_TARGET_SM OR GMX_CUDA_TARGET_COMPUTE) else() # Set the CUDA GPU architectures to compile for: # - with CUDA >=9.0 CC 7.0 is supported and CC 2.0 is no longer supported - # => compile sm_30, sm_35, sm_37, sm_50, sm_52, sm_60, sm_61, sm_70 SASS, and compute_70 PTX + # => compile sm_30, sm_35, sm_37, sm_50, sm_52, sm_60, sm_61, sm_70 SASS, and compute_35, compute_70 PTX # - with CUDA >=10.0 CC 7.5 is supported - # => compile sm_30, sm_35, sm_37, sm_50, sm_52, sm_60, sm_61, sm_70, sm_75 SASS, and compute_75 PTX + # => compile sm_30, sm_35, sm_37, sm_50, sm_52, sm_60, sm_61, sm_70, sm_75 SASS, and compute_35, compute_75 PTX # - with CUDA >=11.0 CC 8.0 is supported - # => compile sm_35, sm_37, sm_50, sm_52, sm_60, sm_61, sm_70, sm_75, sm_80 SASS, and compute_80 PTX + # => compile sm_35, sm_37, sm_50, sm_52, sm_60, sm_61, sm_70, sm_75, sm_80 SASS, and compute_35, compute_80 PTX # First add flags that trigger SASS (binary) code generation for physical arch if(CUDA_VERSION VERSION_LESS "11.0") @@ -118,22 +118,28 @@ else() list (APPEND GMX_CUDA_NVCC_GENCODE_FLAGS "-gencode;arch=compute_60,code=sm_60") list (APPEND GMX_CUDA_NVCC_GENCODE_FLAGS "-gencode;arch=compute_61,code=sm_61") list (APPEND GMX_CUDA_NVCC_GENCODE_FLAGS "-gencode;arch=compute_70,code=sm_70") + if(NOT CUDA_VERSION VERSION_LESS "10.0") + list (APPEND GMX_CUDA_NVCC_GENCODE_FLAGS "-gencode;arch=compute_75,code=sm_75") + endif() if(NOT CUDA_VERSION VERSION_LESS "11.0") + list (APPEND GMX_CUDA_NVCC_GENCODE_FLAGS "-gencode;arch=compute_80,code=sm_80") # Requesting sm or compute 35, 37, or 50 triggers deprecation messages with # nvcc 11.0, which we need to suppress for use in CI list (APPEND GMX_CUDA_NVCC_GENCODE_FLAGS "-Wno-deprecated-gpu-targets") endif() + if(NOT CUDA_VERSION VERSION_LESS "11.1") + list (APPEND GMX_CUDA_NVCC_GENCODE_FLAGS "-gencode;arch=compute_86,code=sm_86") + endif() - # Next add flags that trigger PTX code generation for the newest supported virtual arch - # that's useful to JIT to future architectures + # Next add flags that trigger PTX code generation for the + # newest supported virtual arch that's useful to JIT to future architectures + # as well as an older one suitable for JIT-ing to any rare intermediate arch + # (like that of Jetson / Drive PX devices) list (APPEND GMX_CUDA_NVCC_GENCODE_FLAGS "-gencode;arch=compute_35,code=compute_35") - list (APPEND GMX_CUDA_NVCC_GENCODE_FLAGS "-gencode;arch=compute_50,code=compute_50") - list (APPEND GMX_CUDA_NVCC_GENCODE_FLAGS "-gencode;arch=compute_52,code=compute_52") - list (APPEND GMX_CUDA_NVCC_GENCODE_FLAGS "-gencode;arch=compute_60,code=compute_60") - list (APPEND GMX_CUDA_NVCC_GENCODE_FLAGS "-gencode;arch=compute_61,code=compute_61") - list (APPEND GMX_CUDA_NVCC_GENCODE_FLAGS "-gencode;arch=compute_70,code=compute_70") - if(NOT CUDA_VERSION VERSION_LESS "10.0") - list (APPEND GMX_CUDA_NVCC_GENCODE_FLAGS "-gencode;arch=compute_75,code=compute_75") + if(CUDA_VERSION VERSION_LESS "11.0") + list (APPEND GMX_CUDA_NVCC_GENCODE_FLAGS "-gencode;arch=compute_32,code=compute_32") + else() + list (APPEND GMX_CUDA_NVCC_GENCODE_FLAGS "-gencode;arch=compute_53,code=compute_53") endif() if(NOT CUDA_VERSION VERSION_LESS "11.0") list (APPEND GMX_CUDA_NVCC_GENCODE_FLAGS "-gencode;arch=compute_80,code=compute_80") diff --git a/cmake/gmxTestCompilerProblems.cmake b/cmake/gmxTestCompilerProblems.cmake index edb8c47142..620f1767ed 100644 --- a/cmake/gmxTestCompilerProblems.cmake +++ b/cmake/gmxTestCompilerProblems.cmake @@ -47,27 +47,27 @@ macro(gmx_test_compiler_problems) message(WARNING "The versions of the C and C++ compilers do not match (${CMAKE_C_COMPILER_VERSION} and ${CMAKE_CXX_COMPILER_VERSION}, respectively). Mixing different C/C++ compilers can cause problems.") endif() - # Error if compiler doesn't support required C++14 features. + # Error if compiler doesn't support required C++17 features. # cmake feature detection is currently inconsistent: gitlab.kitware.com/cmake/cmake/issues/18869 - # When we use C++17 we might want to switch to using feature test macros. + # We might want to switch to using feature test macros some time. if(CMAKE_COMPILER_IS_GNUCXX) - if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5) - set(cxx_required_version "GCC version 5") + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7) + set(cxx_required_version "GCC version 7") endif() elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.15) set(cxx_required_version "Visual Studio 2017") endif() elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.6) # For feature complete C++14 only 3.4 is needed. - set(cxx_required_version "Clang 3.6") # But prior version have bugs (e.g. debug symbol support) + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5) + set(cxx_required_version "Clang 5") endif() else() - message(WARNING "You are using an unsupported compiler. Please make sure it fully supports C++14.") + message(WARNING "You are using an unsupported compiler. Please make sure it fully supports C++17.") endif() if (cxx_required_version) message(FATAL_ERROR "${cxx_required_version} or later required. " - "Earlier versions don't have full C++14 support.") + "Earlier versions don't have full C++17 support.") endif() if (CMAKE_CXX_COMPILER_ID MATCHES "Intel") diff --git a/docs/reference-manual/plots/GMX_logos/gmx_logo_black.svg b/docs/reference-manual/plots/GMX_logos/gmx_logo_black.svg index 703166eb70..728403c7ea 100644 --- a/docs/reference-manual/plots/GMX_logos/gmx_logo_black.svg +++ b/docs/reference-manual/plots/GMX_logos/gmx_logo_black.svg @@ -14,14 +14,14 @@ xml:space="preserve" style="clip-rule:evenodd;fill-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2" id="svg923" - sodipodi:docname="Gromacs Logo [Blue].svg" + sodipodi:docname="gmx_logo_black.svg" inkscape:version="0.92.3 (2405546, 2018-03-11)" inkscape:export-filename="/home/cathrine/Pictures/svg_files/gromacs_logo1.png" inkscape:export-xdpi="300" inkscape:export-ydpi="300">image/svg+xml @@ -58,8 +58,8 @@ guidetolerance="10" inkscape:pageopacity="0" inkscape:pageshadow="2" - inkscape:window-width="1853" - inkscape:window-height="1145" + inkscape:window-width="2493" + inkscape:window-height="1385" id="namedview925" showgrid="false" units="mm" @@ -69,7 +69,7 @@ inkscape:window-x="67" inkscape:window-y="27" inkscape:window-maximized="1" - inkscape:current-layer="g1133" + inkscape:current-layer="text915" viewbox-width="6349" /> @@ -122,28 +122,94 @@ d="m 5615.2719,3031.0101 c 0.075,-1.2289 0.6651,-4.6992 2.7475,-4.0926 2.2666,1.5467 3.7201,3.9506 4.3543,7.8539 0.2282,1.9516 0.2476,3.5697 -2.5883,1.3807 -1.4708,-1.3462 -2.0008,-1.608 -4.5135,-5.142 z" id="path1103-2" />GROMACS + id="path931" /> -FAST. FLEXIBLE. FREE. + id="text915"> +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/reference-manual/plots/GMX_logos/gmx_logo_blue.svg b/docs/reference-manual/plots/GMX_logos/gmx_logo_blue.svg index cb70bdc2eb..b1634f687c 100644 --- a/docs/reference-manual/plots/GMX_logos/gmx_logo_blue.svg +++ b/docs/reference-manual/plots/GMX_logos/gmx_logo_blue.svg @@ -14,14 +14,14 @@ xml:space="preserve" style="clip-rule:evenodd;fill-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2" id="svg923" - sodipodi:docname="Gromacs Logo [Blue].svg" + sodipodi:docname="gmx_logo_blue.svg" inkscape:version="0.92.3 (2405546, 2018-03-11)" inkscape:export-filename="/home/cathrine/Pictures/svg_files/gromacs_logo1.png" inkscape:export-xdpi="300" inkscape:export-ydpi="300">image/svg+xml @@ -58,8 +58,8 @@ guidetolerance="10" inkscape:pageopacity="0" inkscape:pageshadow="2" - inkscape:window-width="1853" - inkscape:window-height="1145" + inkscape:window-width="2493" + inkscape:window-height="1385" id="namedview925" showgrid="false" units="mm" @@ -69,7 +69,7 @@ inkscape:window-x="67" inkscape:window-y="27" inkscape:window-maximized="1" - inkscape:current-layer="g1133" + inkscape:current-layer="g1073" viewbox-width="6349" /> @@ -116,28 +116,94 @@ style="fill:#4e6f98;fill-opacity:1;stroke:none;stroke-width:0.29999998;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="m 5615.2719,3031.0101 c 0.075,-1.2289 0.6651,-4.6992 2.7475,-4.0926 2.2666,1.5467 3.7201,3.9506 4.3543,7.8539 0.2282,1.9516 0.2476,3.5697 -2.5883,1.3807 -1.4708,-1.3462 -2.0008,-1.608 -4.5135,-5.142 z" id="path1103-2" />GROMACS + id="path1021" /> -FAST. FLEXIBLE. FREE. + id="text915"> +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/reference-manual/plots/GMX_logos/gmx_logo_waterstamp.svg b/docs/reference-manual/plots/GMX_logos/gmx_logo_waterstamp.svg index 88bfff62ae..5c1e60d5d2 100644 --- a/docs/reference-manual/plots/GMX_logos/gmx_logo_waterstamp.svg +++ b/docs/reference-manual/plots/GMX_logos/gmx_logo_waterstamp.svg @@ -14,14 +14,14 @@ xml:space="preserve" style="clip-rule:evenodd;fill-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2" id="svg923" - sodipodi:docname="Gromacs Logo [Blue].svg" + sodipodi:docname="gmx_logo_waterstamp.svg" inkscape:version="0.92.3 (2405546, 2018-03-11)" inkscape:export-filename="/home/cathrine/Pictures/svg_files/gromacs_logo1.png" inkscape:export-xdpi="300" inkscape:export-ydpi="300">image/svg+xml @@ -58,18 +58,18 @@ guidetolerance="10" inkscape:pageopacity="0" inkscape:pageshadow="2" - inkscape:window-width="1853" - inkscape:window-height="1145" + inkscape:window-width="2493" + inkscape:window-height="1385" id="namedview925" showgrid="false" units="mm" inkscape:zoom="0.1767767" - inkscape:cx="3203.3303" + inkscape:cx="2216.2093" inkscape:cy="513.69543" inkscape:window-x="67" inkscape:window-y="27" inkscape:window-maximized="1" - inkscape:current-layer="g1133" + inkscape:current-layer="text915" viewbox-width="6349" /> @@ -122,28 +122,94 @@ d="m 5615.2719,3031.0101 c 0.075,-1.2289 0.6651,-4.6992 2.7475,-4.0926 2.2666,1.5467 3.7201,3.9506 4.3543,7.8539 0.2282,1.9516 0.2476,3.5697 -2.5883,1.3807 -1.4708,-1.3462 -2.0008,-1.608 -4.5135,-5.142 z" id="path1103-2" />GROMACS + id="path1943" /> -FAST. FLEXIBLE. FREE. + id="text915"> +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/reference-manual/plots/GMX_logos/gmx_logo_white.svg b/docs/reference-manual/plots/GMX_logos/gmx_logo_white.svg index 91e9c06198..aa491d8f0c 100644 --- a/docs/reference-manual/plots/GMX_logos/gmx_logo_white.svg +++ b/docs/reference-manual/plots/GMX_logos/gmx_logo_white.svg @@ -14,14 +14,14 @@ xml:space="preserve" style="clip-rule:evenodd;fill-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2" id="svg923" - sodipodi:docname="Gromacs Logo [Blue].svg" + sodipodi:docname="gmx_logo_white.svg" inkscape:version="0.92.3 (2405546, 2018-03-11)" inkscape:export-filename="/home/cathrine/Pictures/svg_files/gromacs_logo1.png" inkscape:export-xdpi="300" inkscape:export-ydpi="300">image/svg+xml @@ -58,8 +58,8 @@ guidetolerance="10" inkscape:pageopacity="0" inkscape:pageshadow="2" - inkscape:window-width="1853" - inkscape:window-height="1145" + inkscape:window-width="2493" + inkscape:window-height="1385" id="namedview925" showgrid="false" units="mm" @@ -69,7 +69,7 @@ inkscape:window-x="67" inkscape:window-y="27" inkscape:window-maximized="1" - inkscape:current-layer="g1133" + inkscape:current-layer="g862" viewbox-width="6349" /> @@ -122,28 +122,94 @@ d="m 5615.2719,3031.0101 c 0.075,-1.2289 0.6651,-4.6992 2.7475,-4.0926 2.2666,1.5467 3.7201,3.9506 4.3543,7.8539 0.2282,1.9516 0.2476,3.5697 -2.5883,1.3807 -1.4708,-1.3462 -2.0008,-1.608 -4.5135,-5.142 z" id="path1103-2" />GROMACS + id="path985" /> -FAST. FLEXIBLE. FREE. + id="text915"> +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/release-notes/2021/2021.1.rst b/docs/release-notes/2021/2021.1.rst index 4b884a69f3..9eb10dae2c 100644 --- a/docs/release-notes/2021/2021.1.rst +++ b/docs/release-notes/2021/2021.1.rst @@ -19,9 +19,34 @@ Fixes where mdrun could behave incorrectly Fixes for ``gmx`` tools ^^^^^^^^^^^^^^^^^^^^^^^ +Fix periodic boundary conditions in analysis framework tools +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +There was a bug in the trajectory analysis framework which caused +molecules that were broken over PBC not to be made whole. This would +usually lead to obviously incorrect outliers in analysis output. + +:issue:`3900` + +Fix range checking bug in gmx covar +""""""""""""""""""""""""""""""""""" + +A check was inverted causing range checking to be applied wrong. + +:issue:`3902` + Fixes that affect portability ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Fixed compilation on Cygwin +""""""""""""""""""""""""""" + +A |Gromacs| header file was not including the necessary standard +header. A problem with the ``M_PI`` math constant defined only by +POSIX and not by C++ was also worked around. + +:issue:`3890` + Miscellaneous ^^^^^^^^^^^^^ - +* Updated |Gromacs| logos diff --git a/docs/release-notes/2021/major/miscellaneous.rst b/docs/release-notes/2021/major/miscellaneous.rst index 91f8cca080..dfa74e3dba 100644 --- a/docs/release-notes/2021/major/miscellaneous.rst +++ b/docs/release-notes/2021/major/miscellaneous.rst @@ -52,6 +52,7 @@ The environment variables that had exactly the same meaning in OpenCL and CUDA w Dysfunctional parts of the QMMM interface has been removed """""""""""""""""""""""""""""""""""""""""""""""""""""""""" -Currently, GROMACS supports QM/MM officially only via MiMiC. All other QM/MM +Currently, GROMACS supports QM/MM officially only via MiMiC; a new CP2K QM/MM interface is being +developed within BioExcel. All other QM/MM support has been untested and likely dysfunctional for years and has now been removed from .mdp input and output, resulting in smaller .mdp output files from grompp. diff --git a/src/external/CMakeLists.txt b/src/external/CMakeLists.txt index e850736ec4..57f73c60d0 100644 --- a/src/external/CMakeLists.txt +++ b/src/external/CMakeLists.txt @@ -61,8 +61,9 @@ if(BUILD_TESTING AND GMX_BUILD_UNITTESTS) ) target_compile_definitions(gtest PUBLIC GTEST_LANG_CXX11) if (CYGWIN) - # Ensure GoogleTest can find POSIX things it needs - target_compile_definitions(gtest PRIVATE _POSIX_C_SOURCE=200809L) + # Ensure GoogleTest and things that use it can find + # POSIX things needed by GoogleTest + target_compile_definitions(gtest PUBLIC _POSIX_C_SOURCE=200809L) endif() gmx_target_warning_suppression(gmock -Wno-deprecated-copy HAVE_NO_DEPRECATED_COPY) diff --git a/src/gromacs/domdec/partition.cpp b/src/gromacs/domdec/partition.cpp index 06b4937caf..dca7464ba7 100644 --- a/src/gromacs/domdec/partition.cpp +++ b/src/gromacs/domdec/partition.cpp @@ -1125,7 +1125,7 @@ static void print_dd_load_av(FILE* fplog, gmx_domdec_t* dd) fprintf(fplog, "\n"); fprintf(stderr, "\n"); - if (lossFraction >= DD_PERF_LOSS_WARN) + if ((lossFraction >= DD_PERF_LOSS_WARN) && (dd->comm->dlbState != DlbState::offTemporarilyLocked)) { std::string message = gmx::formatString( "NOTE: %.1f %% of the available CPU time was lost due to load imbalance\n" @@ -1133,9 +1133,16 @@ static void print_dd_load_av(FILE* fplog, gmx_domdec_t* dd) lossFraction * 100); bool hadSuggestion = false; - if (!isDlbOn(comm)) + if (dd->comm->dlbState == DlbState::offUser) { - message += " You might want to use dynamic load balancing (option -dlb.)\n"; + message += " You might want to allow dynamic load balancing (option -dlb auto.)\n"; + hadSuggestion = true; + } + else if (dd->comm->dlbState == DlbState::offCanTurnOn) + { + message += + " Dynamic load balancing was automatically disabled, but it might be " + "beneficial to manually tuning it on (option -dlb on.)\n"; hadSuggestion = true; } else if (dlbWasLimited) @@ -1151,7 +1158,6 @@ static void print_dd_load_av(FILE* fplog, gmx_domdec_t* dd) " considerable inhomogeneity in the simulated system.", hadSuggestion ? "also " : ""); - fprintf(fplog, "%s\n", message.c_str()); fprintf(stderr, "%s\n", message.c_str()); } diff --git a/src/gromacs/gmxana/gmx_covar.cpp b/src/gromacs/gmxana/gmx_covar.cpp index a6a07535ca..33c3fae1bc 100644 --- a/src/gromacs/gmxana/gmx_covar.cpp +++ b/src/gromacs/gmxana/gmx_covar.cpp @@ -4,7 +4,7 @@ * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team. - * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by + * Copyright (c) 2018,2019,2020,2021, 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. @@ -73,27 +73,25 @@ namespace /*! \brief Throw an error if any element in index exceeds a given number. * * \param[in] indices to be acessed - * \param[in] largestOkayIndex to be accessed + * \param[in] numAtoms to be accessed * \param[in] indexUsagePurpose to be more explicit in the error message * - * \throws RangeError if largestOkayIndex is larger than any element in indices + * \throws RangeError if any element in indices is larger than or equal numAtoms * */ -void throwErrorIfIndexOutOfBounds(ArrayRef indices, - const int largestOkayIndex, - const std::string& indexUsagePurpose) +void throwErrorIfIndexOutOfBounds(ArrayRef indices, const int numAtoms, const std::string& indexUsagePurpose) { // do nothing if index is empty - if (indices.ssize() == 0) + if (indices.empty()) { return; } const int largestIndex = *std::max_element(indices.begin(), indices.end()); - if (largestIndex < largestOkayIndex) + if (largestIndex >= numAtoms) { - GMX_THROW(RangeError("The provided structure file only contains " - + std::to_string(largestOkayIndex) + " coordinates, but coordinate index " - + std::to_string(largestIndex) + " was requested for " + indexUsagePurpose + GMX_THROW(RangeError("The provided structure file only contains " + std::to_string(numAtoms) + + " coordinates, but coordinate index " + std::to_string(largestIndex + 1) + + " was requested for " + indexUsagePurpose + ". Make sure to update structure files " "and index files if you store only a part of your system.")); } diff --git a/src/gromacs/gmxpreprocess/genhydro.cpp b/src/gromacs/gmxpreprocess/genhydro.cpp index af370d5e71..5ee31602a3 100644 --- a/src/gromacs/gmxpreprocess/genhydro.cpp +++ b/src/gromacs/gmxpreprocess/genhydro.cpp @@ -3,7 +3,7 @@ * * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. - * Copyright (c) 2013-2019,2020, by the GROMACS development team, led by + * Copyright (c) 2013-2019,2020,2021, 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. @@ -80,6 +80,21 @@ static int pdbasearch_atom(const char* name, return search_atom(name, i, pdba, searchtype, bAllowMissing, cyclicBondsIndex); } +/*! \brief Return the index of the first atom whose residue index + * matches and which has a patch with the given name. + * + * \param[out] ii Index of the first atom in the residue that matches, + * -1 if no match occurs. + * \param[out] jj Index of the patch that matches, + * unchanged if no match occurs. + * \param[in] name Name of the desired patch to match + * \param[in] patches The patch database to search + * \param[in] resind The residue index to match + * \param[in] pdba The atoms to work with + * + * \todo The short-circuit logic will be simpler if this returned a + * std::pair as soon as the first double match is found. + */ static void hacksearch_atom(int* ii, int* jj, const char* name, @@ -105,6 +120,10 @@ static void hacksearch_atom(int* ii, { *ii = i; *jj = j; + if (*ii >= 0) + { + break; + } } j++; } @@ -220,8 +239,11 @@ static void expand_hackblocks_one(const MoleculePatchDatabase& newPatch, if (singlePatch.tp == 10 && k == 2) { /* This is a water virtual site, not a hydrogen */ - /* Ugly hardcoded name hack */ - patch->nname.assign("M"); + /* Ugly hardcoded name hack to replace 'H' with 'M' */ + GMX_RELEASE_ASSERT( + !patch->nname.empty() && patch->nname[0] == 'H', + "Water virtual site should be named starting with H at this point"); + patch->nname[0] = 'M'; } else if (singlePatch.tp == 11 && k >= 2) { diff --git a/src/gromacs/gmxpreprocess/tests/pdb2gmx.cpp b/src/gromacs/gmxpreprocess/tests/pdb2gmx.cpp index f9bac4c828..fd5fcfc7c6 100644 --- a/src/gromacs/gmxpreprocess/tests/pdb2gmx.cpp +++ b/src/gromacs/gmxpreprocess/tests/pdb2gmx.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by + * Copyright (c) 2018,2019,2020,2021, 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,7 +65,7 @@ using test::CommandLine; //! Test parameter struct. using CommandLineOptionParams = - std::tuple; + std::tuple; /*! \brief Strings containing regular expressions for lines to skip * when matching. @@ -94,6 +94,8 @@ public: Pdb2gmxTest() { int outputFileType = std::get<6>(GetParam()); + // If the file type of the output configuration is one + // commonly used (ie. pdb, gro), then check its content. if (outputFileType == efPDB) { // If we're writing PDB output, we are interested in @@ -103,9 +105,9 @@ public: ExactTextMatch settings; setOutputFile("-o", outputfile.c_str(), TextFileMatch(settings)); } - else + else if (outputFileType == efGRO) { - setOutputFile("-o", "conf.gro", ConfMatch()); + setOutputFile("-o", "conf.gro", ConfMatch().matchFullConfiguration(std::get<7>(GetParam()))); } setOutputFile("-p", "topol.top", TextFileMatch(c_textMatcher)); } @@ -151,7 +153,8 @@ INSTANTIATE_TEST_CASE_P(ForOplsaa, "fragment2.pdb", "fragment3.pdb", "fragment4.pdb"), - ::testing::Values(efGRO))); + ::testing::Values(efGRO), + ::testing::Values(false))); #endif #if GROMOS @@ -166,7 +169,8 @@ INSTANTIATE_TEST_CASE_P(ForGromos43a1, "fragment2.pdb", "fragment3.pdb", "fragment4.pdb"), - ::testing::Values(efGRO))); + ::testing::Values(efGRO), + ::testing::Values(false))); INSTANTIATE_TEST_CASE_P(ForGromos53a6, Pdb2gmxTest, @@ -179,7 +183,8 @@ INSTANTIATE_TEST_CASE_P(ForGromos53a6, "fragment2.pdb", "fragment3.pdb", "fragment4.pdb"), - ::testing::Values(efGRO))); + ::testing::Values(efGRO), + ::testing::Values(false))); #endif #if AMBER @@ -194,7 +199,18 @@ INSTANTIATE_TEST_CASE_P(ForAmber99sb_ildn, "fragment2.pdb", "fragment3.pdb", "fragment4.pdb"), - ::testing::Values(efGRO))); + ::testing::Values(efGRO), + ::testing::Values(false))); +INSTANTIATE_TEST_CASE_P(ForAmber99sb_ildnWithTip4p, + Pdb2gmxTest, + ::testing::Combine(::testing::Values("amber99sb-ildn"), + ::testing::Values("tip4p"), + ::testing::Values("none"), + ::testing::Values("id_or_ter"), + ::testing::Values("no"), + ::testing::Values("tip4p.pdb"), + ::testing::Values(efGRO), + ::testing::Values(true))); #endif #if CHARMM @@ -209,7 +225,8 @@ INSTANTIATE_TEST_CASE_P(ForCharmm27, "fragment2.pdb", "fragment3.pdb", "fragment4.pdb"), - ::testing::Values(efGRO))); + ::testing::Values(efGRO), + ::testing::Values(false))); INSTANTIATE_TEST_CASE_P(ChainSep, @@ -220,7 +237,8 @@ INSTANTIATE_TEST_CASE_P(ChainSep, ::testing::Values("id", "ter", "id_or_ter", "id_and_ter"), ::testing::Values("all", "no"), ::testing::Values("chainTer.pdb"), - ::testing::Values(efGRO))); + ::testing::Values(efGRO), + ::testing::Values(false))); INSTANTIATE_TEST_CASE_P(ChainChanges, Pdb2gmxTest, @@ -230,7 +248,8 @@ INSTANTIATE_TEST_CASE_P(ChainChanges, ::testing::Values("id", "ter", "id_or_ter", "id_and_ter"), ::testing::Values("no"), ::testing::Values("two-fragments.pdb"), - ::testing::Values(efPDB))); + ::testing::Values(efPDB), + ::testing::Values(false))); INSTANTIATE_TEST_CASE_P(ForCharmm27CyclicSystem, Pdb2gmxTest, @@ -241,7 +260,8 @@ INSTANTIATE_TEST_CASE_P(ForCharmm27CyclicSystem, ::testing::Values("no", "all"), ::testing::Values("cyclic-rna.pdb", "cyclic-protein-small.pdb"), - ::testing::Values(efGRO))); + ::testing::Values(efGRO), + ::testing::Values(false))); #endif } // namespace diff --git a/src/gromacs/gmxpreprocess/tests/refdata/ForAmber99sb_ildnWithTip4p_Pdb2gmxTest_ProducesMatchingTopology_0.xml b/src/gromacs/gmxpreprocess/tests/refdata/ForAmber99sb_ildnWithTip4p_Pdb2gmxTest_ProducesMatchingTopology_0.xml new file mode 100644 index 0000000000..de032d5e8f --- /dev/null +++ b/src/gromacs/gmxpreprocess/tests/refdata/ForAmber99sb_ildnWithTip4p_Pdb2gmxTest_ProducesMatchingTopology_0.xml @@ -0,0 +1,60 @@ + + + + + + + TIP4p ice to test that MW is handled correctly + 8 + + + + + + + + diff --git a/src/gromacs/gmxpreprocess/tests/tip4p.pdb b/src/gromacs/gmxpreprocess/tests/tip4p.pdb new file mode 100644 index 0000000000..eb55c00f6f --- /dev/null +++ b/src/gromacs/gmxpreprocess/tests/tip4p.pdb @@ -0,0 +1,9 @@ +TITLE TIP4p ice to test that MW is handled correctly +ATOM 1 OW SOL A 1 -24.744 -55.257 -4.969 1.00 1.00 A O +ATOM 2 HW1 SOL A 1 -25.692 -55.390 -4.996 1.00 0.00 A H +ATOM 3 HW2 SOL A 1 -24.532 -55.232 -4.035 1.00 0.00 A H +ATOM 4 MW SOL A 1 -24.838 -55.271 -4.853 1.00 0.00 A O +ATOM 5 OW SOL A 2 -24.964 -52.416 -8.778 1.00 1.00 A O +ATOM 6 HW1 SOL A 2 -24.502 -52.770 -8.018 1.00 0.00 A H +ATOM 7 HW2 SOL A 2 -24.314 -51.874 -9.224 1.00 0.00 A H +ATOM 8 MW SOL A 2 -24.822 -52.393 -8.738 1.00 0.00 A O diff --git a/src/gromacs/mdlib/stat.h b/src/gromacs/mdlib/stat.h index d3cf97713a..ad7c7657e7 100644 --- a/src/gromacs/mdlib/stat.h +++ b/src/gromacs/mdlib/stat.h @@ -39,6 +39,8 @@ #ifndef GMX_MDLIB_STAT_H #define GMX_MDLIB_STAT_H +#include + #include "gromacs/math/vectypes.h" struct gmx_ekindata_t; diff --git a/src/gromacs/nbnxm/gpu_types_common.h b/src/gromacs/nbnxm/gpu_types_common.h index 57d791be2a..2d2e90791e 100644 --- a/src/gromacs/nbnxm/gpu_types_common.h +++ b/src/gromacs/nbnxm/gpu_types_common.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2017,2018,2019,2020, by the GROMACS development team, led by + * Copyright (c) 2017,2018,2019,2020,2021, 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. @@ -212,11 +212,11 @@ struct gpu_plist int excl_nalloc; /* parameter+variables for normal and rolling pruning */ - //! true after search, indictes that initial pruning with outer prunning is needed + //! true after search, indicates that initial pruning with outer pruning is needed bool haveFreshList; - //! the number of parts/steps over which one cyle of roling pruning takes places + //! the number of parts/steps over which one cycle of rolling pruning takes places int rollingPruningNumParts; - //! the next part to which the roling pruning needs to be applied + //! the next part to which the rolling pruning needs to be applied int rollingPruningPart; }; diff --git a/src/gromacs/nbnxm/nbnxm_gpu_data_mgmt.cpp b/src/gromacs/nbnxm/nbnxm_gpu_data_mgmt.cpp index 2a2a394cae..9fe755c586 100644 --- a/src/gromacs/nbnxm/nbnxm_gpu_data_mgmt.cpp +++ b/src/gromacs/nbnxm/nbnxm_gpu_data_mgmt.cpp @@ -191,16 +191,18 @@ void init_plist(gpu_plist* pl) pl->excl = nullptr; /* size -1 indicates that the respective array hasn't been initialized yet */ - pl->na_c = -1; - pl->nsci = -1; - pl->sci_nalloc = -1; - pl->ncj4 = -1; - pl->cj4_nalloc = -1; - pl->nimask = -1; - pl->imask_nalloc = -1; - pl->nexcl = -1; - pl->excl_nalloc = -1; - pl->haveFreshList = false; + pl->na_c = -1; + pl->nsci = -1; + pl->sci_nalloc = -1; + pl->ncj4 = -1; + pl->cj4_nalloc = -1; + pl->nimask = -1; + pl->imask_nalloc = -1; + pl->nexcl = -1; + pl->excl_nalloc = -1; + pl->haveFreshList = false; + pl->rollingPruningNumParts = 0; + pl->rollingPruningPart = 0; } void init_timings(gmx_wallclock_gpu_nbnxn_t* t) diff --git a/src/gromacs/pbcutil/rmpbc.cpp b/src/gromacs/pbcutil/rmpbc.cpp index ee79717113..9f8f591dd7 100644 --- a/src/gromacs/pbcutil/rmpbc.cpp +++ b/src/gromacs/pbcutil/rmpbc.cpp @@ -4,7 +4,7 @@ * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team. - * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by + * Copyright (c) 2018,2019,2020,2021, 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. @@ -76,7 +76,8 @@ static t_graph* gmx_rmpbc_get_graph(gmx_rmpbc_t gpbc, PbcType pbcType, int natom int i; rmpbc_graph_t* gr; - if (pbcType == PbcType::No || nullptr == gpbc || nullptr == gpbc->idef || gpbc->idef->ntypes <= 0) + if (pbcType == PbcType::No || nullptr == gpbc + || (nullptr == gpbc->interactionDefinitions && (nullptr == gpbc->idef || gpbc->idef->ntypes <= 0))) { return nullptr; } diff --git a/src/testutils/conftest.cpp b/src/testutils/conftest.cpp index 3fd50276cb..c9fe485234 100644 --- a/src/testutils/conftest.cpp +++ b/src/testutils/conftest.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2017,2018,2019,2020, by the GROMACS development team, led by + * Copyright (c) 2017,2018,2019,2020,2021, 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. @@ -48,6 +48,7 @@ #include "gromacs/utility/gmxassert.h" #include "gromacs/utility/stringutil.h" +#include "gromacs/utility/textreader.h" #include "gromacs/utility/textstream.h" #include "testutils/refdata.h" @@ -79,11 +80,11 @@ private: } // namespace -void checkConfFile(TextInputStream* input, TestReferenceChecker* checker, const ConfMatchSettings& /*unused*/) +void checkConfFile(TextInputStream* input, TestReferenceChecker* checker, const ConfMatchSettings& settings) { TestReferenceChecker groChecker(checker->checkCompound("GroFile", "Header")); - // Just check the first two lines of the output file + // Check the first two lines of the output file std::string line; EXPECT_TRUE(input->readLine(&line)); line = stripSuffixIfPresent(line, "\n"); @@ -91,6 +92,12 @@ void checkConfFile(TextInputStream* input, TestReferenceChecker* checker, const EXPECT_TRUE(input->readLine(&line)); line = stripSuffixIfPresent(line, "\n"); groChecker.checkInteger(std::atoi(line.c_str()), "Number of atoms"); + // Check the full configuration only if required + if (settings.matchFullConfiguration) + { + TextReader reader(input); + checker->checkTextBlock(reader.readAll(), "Configuration"); + } } TextBlockMatcherPointer ConfMatch::createMatcher() const diff --git a/src/testutils/include/testutils/conftest.h b/src/testutils/include/testutils/conftest.h index d22033c537..144a60f436 100644 --- a/src/testutils/include/testutils/conftest.h +++ b/src/testutils/include/testutils/conftest.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2017,2018,2019,2020, by the GROMACS development team, led by + * Copyright (c) 2017,2018,2019,2020,2021, 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. @@ -60,9 +60,8 @@ class TestReferenceChecker; struct ConfMatchSettings { - ConfMatchSettings() : tolerance(defaultRealTolerance()) {} - - FloatingPointTolerance tolerance; + FloatingPointTolerance tolerance = defaultRealTolerance(); + bool matchFullConfiguration = false; }; /*! \brief @@ -96,6 +95,12 @@ public: settings_.tolerance = tolerance; return *this; } + //! Sets whether the full file contents should be matched + ConfMatch& matchFullConfiguration(const bool flag) + { + settings_.matchFullConfiguration = flag; + return *this; + } TextBlockMatcherPointer createMatcher() const override;