From 0b309ceec5c5f099792cf3528754fc48e8629d87 Mon Sep 17 00:00:00 2001 From: Andrey Alekseenko Date: Thu, 11 Mar 2021 05:33:39 +0000 Subject: [PATCH] Properly check for frozen atoms when disabling GPU update Follow-up of !1241 (9550c3e8564068c86a0f34baee0f578e8ce6d5a9) Initially, the check was overly relaxed, and was triggered even when there were no frozen atoms. Thanks to @alangray3 for noticing! --- src/gromacs/mdlib/mdatoms.cpp | 3 +-- src/gromacs/mdrun/runner.cpp | 3 ++- src/gromacs/mdtypes/inputrec.cpp | 7 +++++++ src/gromacs/mdtypes/inputrec.h | 3 +++ src/gromacs/modularsimulator/modularsimulator.cpp | 4 +--- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/gromacs/mdlib/mdatoms.cpp b/src/gromacs/mdlib/mdatoms.cpp index 66e412cee3..1fc7f919e8 100644 --- a/src/gromacs/mdlib/mdatoms.cpp +++ b/src/gromacs/mdlib/mdatoms.cpp @@ -288,8 +288,7 @@ void atoms2md(const gmx_mtop_t* mtop, /* We always copy cTC with domain decomposition */ } srenew(md->cENER, md->nalloc); - if (opts->nFreeze - && (opts->ngfrz > 1 || opts->nFreeze[0][XX] || opts->nFreeze[0][YY] || opts->nFreeze[0][ZZ])) + if (inputrecFrozenAtoms(ir)) { srenew(md->cFREEZE, md->nalloc); } diff --git a/src/gromacs/mdrun/runner.cpp b/src/gromacs/mdrun/runner.cpp index 05a7239325..8202effc13 100644 --- a/src/gromacs/mdrun/runner.cpp +++ b/src/gromacs/mdrun/runner.cpp @@ -1361,6 +1361,7 @@ int Mdrunner::mdrunner() try { const bool useUpdateGroups = cr->dd ? ddUsesUpdateGroups(*cr->dd) : false; + const bool haveFrozenAtoms = inputrecFrozenAtoms(inputrec.get()); useGpuForUpdate = decideWhetherToUseGpuForUpdate(useDomainDecomposition, useUpdateGroups, @@ -1374,7 +1375,7 @@ int Mdrunner::mdrunner() doEssentialDynamics, gmx_mtop_ftype_count(mtop, F_ORIRES) > 0, replExParams.exchangeInterval > 0, - inputrec->opts.nFreeze != nullptr, + haveFrozenAtoms, doRerun, devFlags, mdlog); diff --git a/src/gromacs/mdtypes/inputrec.cpp b/src/gromacs/mdtypes/inputrec.cpp index ab292ec523..0300c4e5d8 100644 --- a/src/gromacs/mdtypes/inputrec.cpp +++ b/src/gromacs/mdtypes/inputrec.cpp @@ -1584,6 +1584,13 @@ bool inputrecPbcXY2Walls(const t_inputrec* ir) return (ir->pbcType == PbcType::XY && ir->nwall == 2); } +bool inputrecFrozenAtoms(const t_inputrec* ir) +{ + return ((ir->opts.nFreeze != nullptr) + && (ir->opts.ngfrz > 1 || ir->opts.nFreeze[0][XX] != 0 || ir->opts.nFreeze[0][YY] != 0 + || ir->opts.nFreeze[0][ZZ] != 0)); +} + bool integratorHasConservedEnergyQuantity(const t_inputrec* ir) { if (!EI_MD(ir->eI)) diff --git a/src/gromacs/mdtypes/inputrec.h b/src/gromacs/mdtypes/inputrec.h index 7b50eb0b9b..5f97a2e4ed 100644 --- a/src/gromacs/mdtypes/inputrec.h +++ b/src/gromacs/mdtypes/inputrec.h @@ -643,6 +643,9 @@ gmx_bool inputrecNphTrotter(const t_inputrec* ir); /*! \brief Return true if the simulation is 2D periodic with two walls. */ bool inputrecPbcXY2Walls(const t_inputrec* ir); +//! \brief Return true if the simulation has frozen atoms (non-trivial freeze groups). +bool inputrecFrozenAtoms(const t_inputrec* ir); + /*! \brief Returns true for MD integator with T and/or P-coupling that supports * calculating a conserved energy quantity. * diff --git a/src/gromacs/modularsimulator/modularsimulator.cpp b/src/gromacs/modularsimulator/modularsimulator.cpp index fbb962be3d..b285fc054c 100644 --- a/src/gromacs/modularsimulator/modularsimulator.cpp +++ b/src/gromacs/modularsimulator/modularsimulator.cpp @@ -262,9 +262,7 @@ bool ModularSimulator::isInputCompatible(bool exitOn "Acceleration is not supported by the modular simulator."); isInputCompatible = isInputCompatible - && conditionalAssert(inputrec->opts.ngfrz == 1 && inputrec->opts.nFreeze[0][XX] == 0 - && inputrec->opts.nFreeze[0][YY] == 0 - && inputrec->opts.nFreeze[0][ZZ] == 0, + && conditionalAssert(!inputrecFrozenAtoms(inputrec), "Freeze groups are not supported by the modular simulator."); isInputCompatible = isInputCompatible -- 2.22.0