From 6d002ec667c955c5137acdad74663bdbc1712f2f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Szil=C3=A1rd=20P=C3=A1ll?= Date: Wed, 21 Apr 2021 19:48:04 +0200 Subject: [PATCH] Eliminate duplicate CPU->GPU copy of x x is copied to the GPU for buffer ops or PME as well as prior to GPU update on search steps which leads to a duplicate copying which is addressed in this change. Fixes #4033 Refs #3988 --- src/gromacs/mdrun/md.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gromacs/mdrun/md.cpp b/src/gromacs/mdrun/md.cpp index dc6a0a25e1..200f46559c 100644 --- a/src/gromacs/mdrun/md.cpp +++ b/src/gromacs/mdrun/md.cpp @@ -1523,8 +1523,15 @@ void gmx::LegacySimulator::do_md() *md); // Copy data to the GPU after buffers might have being reinitialized + // coordinates have been copied already if PME or buffer ops has not needed it this step. stateGpu->copyVelocitiesToGpu(state->v, AtomLocality::Local); - stateGpu->copyCoordinatesToGpu(state->x, AtomLocality::Local); + const bool useGpuPmeOnThisRank = runScheduleWork->simulationWork.useGpuPme + && thisRankHasDuty(cr, DUTY_PME) + && runScheduleWork->stepWork.computeSlowForces; + if (!useGpuPmeOnThisRank && !runScheduleWork->stepWork.useGpuXBufferOps) + { + stateGpu->copyCoordinatesToGpu(state->x, AtomLocality::Local); + } } if (simulationWork.useGpuPme && !runScheduleWork->simulationWork.useGpuPmePpCommunication -- 2.22.0