Eliminate duplicate CPU->GPU copy of x
[alexxy/gromacs.git] / src / gromacs / mdrun / md.cpp
index dc6a0a25e1ddd48c1638fa4b6d5b79a73861dda6..200f46559c26dd6ded113ff201180229d62e2b12 100644 (file)
@@ -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