From cff07e5a99bf8c6a6a49bc2ba60bdf08da527236 Mon Sep 17 00:00:00 2001 From: Andrey Alekseenko Date: Fri, 13 Aug 2021 07:39:35 +0000 Subject: [PATCH] Remove duplicate waiting for coordinates --- src/gromacs/mdlib/sim_util.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/gromacs/mdlib/sim_util.cpp b/src/gromacs/mdlib/sim_util.cpp index 563a36239e..6bce5123f0 100644 --- a/src/gromacs/mdlib/sim_util.cpp +++ b/src/gromacs/mdlib/sim_util.cpp @@ -1668,12 +1668,17 @@ void do_force(FILE* fplog, // 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)) + if (simulationWork.useGpuUpdate && !stepWork.doNeighborSearch) { - GMX_ASSERT(haveCopiedXFromGpu, "a wait should only be triggered if copy has been scheduled"); - stateGpu->waitCoordinatesReadyOnHost(AtomLocality::Local); + const bool needCoordsOnHost = (runScheduleWork->domainWork.haveCpuLocalForceWork + || stepWork.computeVirial || simulationWork.computeMuTot); + const bool haveAlreadyWaited = haveHostHaloExchangeComms; + if (needCoordsOnHost && !haveAlreadyWaited) + { + GMX_ASSERT(haveCopiedXFromGpu, + "a wait should only be triggered if copy has been scheduled"); + stateGpu->waitCoordinatesReadyOnHost(AtomLocality::Local); + } } DipoleData dipoleData; -- 2.22.0