From 086ebc8821e64de7c57a25ea4bf4ea0280f0a3e6 Mon Sep 17 00:00:00 2001 From: Andrey Alekseenko Date: Mon, 26 Jul 2021 11:14:30 +0000 Subject: [PATCH] Remove duplicate waiting for coordinates --- src/gromacs/mdlib/sim_util.cpp | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/gromacs/mdlib/sim_util.cpp b/src/gromacs/mdlib/sim_util.cpp index 45026b2ad5..4210f696cd 100644 --- a/src/gromacs/mdlib/sim_util.cpp +++ b/src/gromacs/mdlib/sim_util.cpp @@ -1665,19 +1665,22 @@ void do_force(FILE* fplog, xWholeMolecules = fr->wholeMoleculeTransform->wholeMoleculeCoordinates(x.unpaddedArrayRef(), box); } + // For the rest of the CPU tasks that depend on GPU-update produced coordinates, + // this wait ensures that the D2H transfer is complete. + if (simulationWork.useGpuUpdate && !stepWork.doNeighborSearch + && (runScheduleWork->domainWork.haveCpuLocalForceWork || stepWork.computeVirial + || simulationWork.computeMuTot)) + { + GMX_ASSERT(haveCopiedXFromGpu, "a wait should only be triggered if copy has been scheduled"); + stateGpu->waitCoordinatesReadyOnHost(AtomLocality::Local); + } + DipoleData dipoleData; if (simulationWork.computeMuTot) { const int start = 0; - if (simulationWork.useGpuUpdate && !stepWork.doNeighborSearch) - { - GMX_ASSERT(haveCopiedXFromGpu, - "a wait should only be triggered if copy has been scheduled"); - stateGpu->waitCoordinatesReadyOnHost(AtomLocality::Local); - } - /* Calculate total (local) dipole moment in a temporary common array. * This makes it possible to sum them over nodes faster. */ @@ -1707,15 +1710,6 @@ void do_force(FILE* fplog, dd_force_flop_start(cr->dd, nrnb); } - // For the rest of the CPU tasks that depend on GPU-update produced coordinates, - // this wait ensures that the D2H transfer is complete. - if (simulationWork.useGpuUpdate && !stepWork.doNeighborSearch - && (runScheduleWork->domainWork.haveCpuLocalForceWork || stepWork.computeVirial)) - { - GMX_ASSERT(haveCopiedXFromGpu, "a wait should only be triggered if copy has been scheduled"); - stateGpu->waitCoordinatesReadyOnHost(AtomLocality::Local); - } - if (inputrec.bRot) { wallcycle_start(wcycle, WallCycleCounter::Rot); -- 2.22.0