Unverified Commit 8e369f22 authored by Peter Eastman's avatar Peter Eastman Committed by GitHub
Browse files

Flush queue less frequently (#4177)

parent 7e6ecf71
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "openmm/internal/CustomCompoundBondForceImpl.h" #include "openmm/internal/CustomCompoundBondForceImpl.h"
#include "openmm/internal/CustomHbondForceImpl.h" #include "openmm/internal/CustomHbondForceImpl.h"
#include "openmm/internal/CustomManyParticleForceImpl.h" #include "openmm/internal/CustomManyParticleForceImpl.h"
#include "openmm/internal/timer.h"
#include "CommonKernelSources.h" #include "CommonKernelSources.h"
#include "lepton/CustomFunction.h" #include "lepton/CustomFunction.h"
#include "lepton/ExpressionTreeNode.h" #include "lepton/ExpressionTreeNode.h"
...@@ -98,6 +99,19 @@ static pair<ExpressionTreeNode, string> makeVariable(const string& name, const s ...@@ -98,6 +99,19 @@ static pair<ExpressionTreeNode, string> makeVariable(const string& name, const s
return make_pair(ExpressionTreeNode(new Operation::Variable(name)), value); return make_pair(ExpressionTreeNode(new Operation::Variable(name)), value);
} }
static void flushPeriodically(ComputeContext& cc) {
#ifdef WIN32
// When running on Windows, we periodically flush the queue to keep the UI responsive.
static double lastTime = getCurrentTime();
double currentTime = getCurrentTime();
if (currentTime-lastTime > 0.025) {
cc.flushQueue();
lastTime = currentTime;
}
#endif
}
void CommonApplyConstraintsKernel::initialize(const System& system) { void CommonApplyConstraintsKernel::initialize(const System& system) {
} }
...@@ -5381,10 +5395,8 @@ void CommonIntegrateVerletStepKernel::execute(ContextImpl& context, const Verlet ...@@ -5381,10 +5395,8 @@ void CommonIntegrateVerletStepKernel::execute(ContextImpl& context, const Verlet
cc.reorderAtoms(); cc.reorderAtoms();
// Reduce UI lag. // Reduce UI lag.
#ifdef WIN32 flushPeriodically(cc);
cc.flushQueue();
#endif
} }
double CommonIntegrateVerletStepKernel::computeKineticEnergy(ContextImpl& context, const VerletIntegrator& integrator) { double CommonIntegrateVerletStepKernel::computeKineticEnergy(ContextImpl& context, const VerletIntegrator& integrator) {
...@@ -5468,10 +5480,8 @@ void CommonIntegrateLangevinStepKernel::execute(ContextImpl& context, const Lang ...@@ -5468,10 +5480,8 @@ void CommonIntegrateLangevinStepKernel::execute(ContextImpl& context, const Lang
cc.reorderAtoms(); cc.reorderAtoms();
// Reduce UI lag. // Reduce UI lag.
#ifdef WIN32 flushPeriodically(cc);
cc.flushQueue();
#endif
} }
double CommonIntegrateLangevinStepKernel::computeKineticEnergy(ContextImpl& context, const LangevinIntegrator& integrator) { double CommonIntegrateLangevinStepKernel::computeKineticEnergy(ContextImpl& context, const LangevinIntegrator& integrator) {
...@@ -5562,10 +5572,8 @@ void CommonIntegrateLangevinMiddleStepKernel::execute(ContextImpl& context, cons ...@@ -5562,10 +5572,8 @@ void CommonIntegrateLangevinMiddleStepKernel::execute(ContextImpl& context, cons
cc.reorderAtoms(); cc.reorderAtoms();
// Reduce UI lag. // Reduce UI lag.
#ifdef WIN32 flushPeriodically(cc);
cc.flushQueue();
#endif
} }
double CommonIntegrateLangevinMiddleStepKernel::computeKineticEnergy(ContextImpl& context, const LangevinMiddleIntegrator& integrator) { double CommonIntegrateLangevinMiddleStepKernel::computeKineticEnergy(ContextImpl& context, const LangevinMiddleIntegrator& integrator) {
...@@ -5755,9 +5763,8 @@ void CommonIntegrateNoseHooverStepKernel::execute(ContextImpl& context, const No ...@@ -5755,9 +5763,8 @@ void CommonIntegrateNoseHooverStepKernel::execute(ContextImpl& context, const No
cc.reorderAtoms(); cc.reorderAtoms();
// Reduce UI lag. // Reduce UI lag.
#ifdef WIN32
cc.flushQueue(); flushPeriodically(cc);
#endif
} }
double CommonIntegrateNoseHooverStepKernel::computeKineticEnergy(ContextImpl& context, const NoseHooverIntegrator& integrator) { double CommonIntegrateNoseHooverStepKernel::computeKineticEnergy(ContextImpl& context, const NoseHooverIntegrator& integrator) {
...@@ -6318,10 +6325,8 @@ void CommonIntegrateBrownianStepKernel::execute(ContextImpl& context, const Brow ...@@ -6318,10 +6325,8 @@ void CommonIntegrateBrownianStepKernel::execute(ContextImpl& context, const Brow
cc.reorderAtoms(); cc.reorderAtoms();
// Reduce UI lag. // Reduce UI lag.
#ifdef WIN32 flushPeriodically(cc);
cc.flushQueue();
#endif
} }
double CommonIntegrateBrownianStepKernel::computeKineticEnergy(ContextImpl& context, const BrownianIntegrator& integrator) { double CommonIntegrateBrownianStepKernel::computeKineticEnergy(ContextImpl& context, const BrownianIntegrator& integrator) {
...@@ -6401,10 +6406,8 @@ double CommonIntegrateVariableVerletStepKernel::execute(ContextImpl& context, co ...@@ -6401,10 +6406,8 @@ double CommonIntegrateVariableVerletStepKernel::execute(ContextImpl& context, co
integration.computeVirtualSites(); integration.computeVirtualSites();
// Reduce UI lag. // Reduce UI lag.
#ifdef WIN32 flushPeriodically(cc);
cc.flushQueue();
#endif
// Update the time and step count. // Update the time and step count.
...@@ -6510,10 +6513,8 @@ double CommonIntegrateVariableLangevinStepKernel::execute(ContextImpl& context, ...@@ -6510,10 +6513,8 @@ double CommonIntegrateVariableLangevinStepKernel::execute(ContextImpl& context,
integration.computeVirtualSites(); integration.computeVirtualSites();
// Reduce UI lag. // Reduce UI lag.
#ifdef WIN32 flushPeriodically(cc);
cc.flushQueue();
#endif
// Update the time and step count. // Update the time and step count.
...@@ -7288,10 +7289,8 @@ void CommonIntegrateCustomStepKernel::execute(ContextImpl& context, CustomIntegr ...@@ -7288,10 +7289,8 @@ void CommonIntegrateCustomStepKernel::execute(ContextImpl& context, CustomIntegr
} }
// Reduce UI lag. // Reduce UI lag.
#ifdef WIN32 flushPeriodically(cc);
cc.flushQueue();
#endif
} }
bool CommonIntegrateCustomStepKernel::evaluateCondition(int step) { bool CommonIntegrateCustomStepKernel::evaluateCondition(int step) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment