Commit 5270f858 authored by Charlles Abreu's avatar Charlles Abreu
Browse files

resolved PR #2611 merge conflicts

parents 697ab72e eec9cd69
...@@ -80,7 +80,7 @@ void LangevinMiddleIntegrator::step(int steps) { ...@@ -80,7 +80,7 @@ void LangevinMiddleIntegrator::step(int steps) {
throw OpenMMException("This Integrator is not bound to a context!"); throw OpenMMException("This Integrator is not bound to a context!");
for (int i = 0; i < steps; ++i) { for (int i = 0; i < steps; ++i) {
context->updateContextState(); context->updateContextState();
context->calcForcesAndEnergy(true, false); context->calcForcesAndEnergy(true, false, getIntegrationForceGroups());
kernel.getAs<IntegrateLangevinMiddleStepKernel>().execute(*context, *this); kernel.getAs<IntegrateLangevinMiddleStepKernel>().execute(*context, *this);
} }
} }
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * Medical Research, grant U54 GM072970. See https://simtk.org. *
* * * *
* Portions copyright (c) 2010-2016 Stanford University and the Authors. * * Portions copyright (c) 2010-2020 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -79,7 +79,7 @@ struct MinimizerData { ...@@ -79,7 +79,7 @@ struct MinimizerData {
static double computeForcesAndEnergy(Context& context, const vector<Vec3>& positions, lbfgsfloatval_t *g) { static double computeForcesAndEnergy(Context& context, const vector<Vec3>& positions, lbfgsfloatval_t *g) {
context.setPositions(positions); context.setPositions(positions);
context.computeVirtualSites(); context.computeVirtualSites();
State state = context.getState(State::Forces | State::Energy); State state = context.getState(State::Forces | State::Energy, false, context.getIntegrator().getIntegrationForceGroups());
const vector<Vec3>& forces = state.getForces(); const vector<Vec3>& forces = state.getForces();
const System& system = context.getSystem(); const System& system = context.getSystem();
for (int i = 0; i < forces.size(); i++) { for (int i = 0; i < forces.size(); i++) {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * Medical Research, grant U54 GM072970. See https://simtk.org. *
* * * *
* Portions copyright (c) 2010-2019 Stanford University and the Authors. * * Portions copyright (c) 2010-2020 Stanford University and the Authors. *
* Authors: Peter Eastman, Lee-Ping Wang * * Authors: Peter Eastman, Lee-Ping Wang *
* Contributors: * * Contributors: *
* * * *
...@@ -72,7 +72,8 @@ void MonteCarloAnisotropicBarostatImpl::updateContextState(ContextImpl& context) ...@@ -72,7 +72,8 @@ void MonteCarloAnisotropicBarostatImpl::updateContextState(ContextImpl& context)
// Compute the current potential energy. // Compute the current potential energy.
double initialEnergy = context.getOwner().getState(State::Energy).getPotentialEnergy(); int groups = context.getIntegrator().getIntegrationForceGroups();
double initialEnergy = context.getOwner().getState(State::Energy, false, groups).getPotentialEnergy();
double pressure; double pressure;
// Choose which axis to modify at random. // Choose which axis to modify at random.
...@@ -114,7 +115,7 @@ void MonteCarloAnisotropicBarostatImpl::updateContextState(ContextImpl& context) ...@@ -114,7 +115,7 @@ void MonteCarloAnisotropicBarostatImpl::updateContextState(ContextImpl& context)
// Compute the energy of the modified system. // Compute the energy of the modified system.
double finalEnergy = context.getOwner().getState(State::Energy).getPotentialEnergy(); double finalEnergy = context.getOwner().getState(State::Energy, false, groups).getPotentialEnergy();
double kT = BOLTZ*context.getParameter(MonteCarloAnisotropicBarostat::Temperature()); double kT = BOLTZ*context.getParameter(MonteCarloAnisotropicBarostat::Temperature());
double w = finalEnergy-initialEnergy + pressure*deltaVolume - context.getMolecules().size()*kT*std::log(newVolume/volume); double w = finalEnergy-initialEnergy + pressure*deltaVolume - context.getMolecules().size()*kT*std::log(newVolume/volume);
if (w > 0 && SimTKOpenMMUtilities::getUniformlyDistributedRandomNumber() > std::exp(-w/kT)) { if (w > 0 && SimTKOpenMMUtilities::getUniformlyDistributedRandomNumber() > std::exp(-w/kT)) {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * Medical Research, grant U54 GM072970. See https://simtk.org. *
* * * *
* Portions copyright (c) 2010-2019 Stanford University and the Authors. * * Portions copyright (c) 2010-2020 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -68,7 +68,8 @@ void MonteCarloBarostatImpl::updateContextState(ContextImpl& context, bool& forc ...@@ -68,7 +68,8 @@ void MonteCarloBarostatImpl::updateContextState(ContextImpl& context, bool& forc
// Compute the current potential energy. // Compute the current potential energy.
double initialEnergy = context.getOwner().getState(State::Energy).getPotentialEnergy(); int groups = context.getIntegrator().getIntegrationForceGroups();
double initialEnergy = context.getOwner().getState(State::Energy, false, groups).getPotentialEnergy();
// Modify the periodic box size. // Modify the periodic box size.
...@@ -83,7 +84,7 @@ void MonteCarloBarostatImpl::updateContextState(ContextImpl& context, bool& forc ...@@ -83,7 +84,7 @@ void MonteCarloBarostatImpl::updateContextState(ContextImpl& context, bool& forc
// Compute the energy of the modified system. // Compute the energy of the modified system.
double finalEnergy = context.getOwner().getState(State::Energy).getPotentialEnergy(); double finalEnergy = context.getOwner().getState(State::Energy, false, groups).getPotentialEnergy();
double pressure = context.getParameter(MonteCarloBarostat::Pressure())*(AVOGADRO*1e-25); double pressure = context.getParameter(MonteCarloBarostat::Pressure())*(AVOGADRO*1e-25);
double kT = BOLTZ*context.getParameter(MonteCarloBarostat::Temperature()); double kT = BOLTZ*context.getParameter(MonteCarloBarostat::Temperature());
double w = finalEnergy-initialEnergy + pressure*deltaVolume - context.getMolecules().size()*kT*std::log(newVolume/volume); double w = finalEnergy-initialEnergy + pressure*deltaVolume - context.getMolecules().size()*kT*std::log(newVolume/volume);
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * Medical Research, grant U54 GM072970. See https://simtk.org. *
* * * *
* Portions copyright (c) 2010-2019 Stanford University and the Authors. * * Portions copyright (c) 2010-2020 Stanford University and the Authors. *
* Authors: Peter Eastman, Lee-Ping Wang * * Authors: Peter Eastman, Lee-Ping Wang *
* Contributors: * * Contributors: *
* * * *
...@@ -70,7 +70,8 @@ void MonteCarloMembraneBarostatImpl::updateContextState(ContextImpl& context) { ...@@ -70,7 +70,8 @@ void MonteCarloMembraneBarostatImpl::updateContextState(ContextImpl& context) {
// Compute the current potential energy. // Compute the current potential energy.
double initialEnergy = context.getOwner().getState(State::Energy).getPotentialEnergy(); int groups = context.getIntegrator().getIntegrationForceGroups();
double initialEnergy = context.getOwner().getState(State::Energy, false, groups).getPotentialEnergy();
double pressure = context.getParameter(MonteCarloMembraneBarostat::Pressure())*(AVOGADRO*1e-25); double pressure = context.getParameter(MonteCarloMembraneBarostat::Pressure())*(AVOGADRO*1e-25);
double tension = context.getParameter(MonteCarloMembraneBarostat::SurfaceTension())*(AVOGADRO*1e-25); double tension = context.getParameter(MonteCarloMembraneBarostat::SurfaceTension())*(AVOGADRO*1e-25);
...@@ -115,7 +116,7 @@ void MonteCarloMembraneBarostatImpl::updateContextState(ContextImpl& context) { ...@@ -115,7 +116,7 @@ void MonteCarloMembraneBarostatImpl::updateContextState(ContextImpl& context) {
// Compute the energy of the modified system. // Compute the energy of the modified system.
double finalEnergy = context.getOwner().getState(State::Energy).getPotentialEnergy(); double finalEnergy = context.getOwner().getState(State::Energy, false, groups).getPotentialEnergy();
double kT = BOLTZ*context.getParameter(MonteCarloMembraneBarostat::Temperature()); double kT = BOLTZ*context.getParameter(MonteCarloMembraneBarostat::Temperature());
double w = finalEnergy-initialEnergy + pressure*deltaVolume - tension*deltaArea - context.getMolecules().size()*kT*std::log(newVolume/volume); double w = finalEnergy-initialEnergy + pressure*deltaVolume - tension*deltaArea - context.getMolecules().size()*kT*std::log(newVolume/volume);
if (w > 0 && SimTKOpenMMUtilities::getUniformlyDistributedRandomNumber() > std::exp(-w/kT)) { if (w > 0 && SimTKOpenMMUtilities::getUniformlyDistributedRandomNumber() > std::exp(-w/kT)) {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * Medical Research, grant U54 GM072970. See https://simtk.org. *
* * * *
* Portions copyright (c) 2019 Stanford University and the Authors. * * Portions copyright (c) 2019-2020 Stanford University and the Authors. *
* Authors: Andreas Krämer and Andrew C. Simmonett * * Authors: Andreas Krämer and Andrew C. Simmonett *
* Contributors: * * Contributors: *
* * * *
...@@ -337,7 +337,7 @@ void NoseHooverIntegrator::step(int steps) { ...@@ -337,7 +337,7 @@ void NoseHooverIntegrator::step(int steps) {
for (int i = 0; i < steps; ++i) { for (int i = 0; i < steps; ++i) {
if(context->updateContextState()) if(context->updateContextState())
forcesAreValid = false; forcesAreValid = false;
context->calcForcesAndEnergy(true, false); context->calcForcesAndEnergy(true, false, getIntegrationForceGroups());
kernel.getAs<IntegrateNoseHooverStepKernel>().execute(*context, *this, forcesAreValid); kernel.getAs<IntegrateNoseHooverStepKernel>().execute(*context, *this, forcesAreValid);
} }
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * Medical Research, grant U54 GM072970. See https://simtk.org. *
* * * *
* Portions copyright (c) 2008-2019 Stanford University and the Authors. * * Portions copyright (c) 2008-2020 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -80,7 +80,7 @@ void VariableLangevinIntegrator::step(int steps) { ...@@ -80,7 +80,7 @@ void VariableLangevinIntegrator::step(int steps) {
throw OpenMMException("This Integrator is not bound to a context!"); throw OpenMMException("This Integrator is not bound to a context!");
for (int i = 0; i < steps; ++i) { for (int i = 0; i < steps; ++i) {
context->updateContextState(); context->updateContextState();
context->calcForcesAndEnergy(true, false); context->calcForcesAndEnergy(true, false, getIntegrationForceGroups());
setStepSize(kernel.getAs<IntegrateVariableLangevinStepKernel>().execute(*context, *this, std::numeric_limits<double>::infinity())); setStepSize(kernel.getAs<IntegrateVariableLangevinStepKernel>().execute(*context, *this, std::numeric_limits<double>::infinity()));
} }
} }
...@@ -90,7 +90,7 @@ void VariableLangevinIntegrator::stepTo(double time) { ...@@ -90,7 +90,7 @@ void VariableLangevinIntegrator::stepTo(double time) {
throw OpenMMException("This Integrator is not bound to a context!"); throw OpenMMException("This Integrator is not bound to a context!");
while (time > context->getTime()) { while (time > context->getTime()) {
context->updateContextState(); context->updateContextState();
context->calcForcesAndEnergy(true, false); context->calcForcesAndEnergy(true, false, getIntegrationForceGroups());
setStepSize(kernel.getAs<IntegrateVariableLangevinStepKernel>().execute(*context, *this, time)); setStepSize(kernel.getAs<IntegrateVariableLangevinStepKernel>().execute(*context, *this, time));
} }
} }
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * Medical Research, grant U54 GM072970. See https://simtk.org. *
* * * *
* Portions copyright (c) 2008-2019 Stanford University and the Authors. * * Portions copyright (c) 2008-2020 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -74,7 +74,7 @@ void VariableVerletIntegrator::step(int steps) { ...@@ -74,7 +74,7 @@ void VariableVerletIntegrator::step(int steps) {
throw OpenMMException("This Integrator is not bound to a context!"); throw OpenMMException("This Integrator is not bound to a context!");
for (int i = 0; i < steps; ++i) { for (int i = 0; i < steps; ++i) {
context->updateContextState(); context->updateContextState();
context->calcForcesAndEnergy(true, false); context->calcForcesAndEnergy(true, false, getIntegrationForceGroups());
setStepSize(kernel.getAs<IntegrateVariableVerletStepKernel>().execute(*context, *this, std::numeric_limits<double>::infinity())); setStepSize(kernel.getAs<IntegrateVariableVerletStepKernel>().execute(*context, *this, std::numeric_limits<double>::infinity()));
} }
} }
...@@ -84,7 +84,7 @@ void VariableVerletIntegrator::stepTo(double time) { ...@@ -84,7 +84,7 @@ void VariableVerletIntegrator::stepTo(double time) {
throw OpenMMException("This Integrator is not bound to a context!"); throw OpenMMException("This Integrator is not bound to a context!");
while (time > context->getTime()) { while (time > context->getTime()) {
context->updateContextState(); context->updateContextState();
context->calcForcesAndEnergy(true, false); context->calcForcesAndEnergy(true, false, getIntegrationForceGroups());
setStepSize(kernel.getAs<IntegrateVariableVerletStepKernel>().execute(*context, *this, time)); setStepSize(kernel.getAs<IntegrateVariableVerletStepKernel>().execute(*context, *this, time));
} }
} }
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * Medical Research, grant U54 GM072970. See https://simtk.org. *
* * * *
* Portions copyright (c) 2008-2012 Stanford University and the Authors. * * Portions copyright (c) 2008-2020 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -73,7 +73,7 @@ void VerletIntegrator::step(int steps) { ...@@ -73,7 +73,7 @@ void VerletIntegrator::step(int steps) {
throw OpenMMException("This Integrator is not bound to a context!"); throw OpenMMException("This Integrator is not bound to a context!");
for (int i = 0; i < steps; ++i) { for (int i = 0; i < steps; ++i) {
context->updateContextState(); context->updateContextState();
context->calcForcesAndEnergy(true, false); context->calcForcesAndEnergy(true, false, getIntegrationForceGroups());
kernel.getAs<IntegrateVerletStepKernel>().execute(*context, *this); kernel.getAs<IntegrateVerletStepKernel>().execute(*context, *this);
} }
} }
...@@ -5709,7 +5709,7 @@ void CommonIntegrateNoseHooverStepKernel::execute(ContextImpl& context, const No ...@@ -5709,7 +5709,7 @@ void CommonIntegrateNoseHooverStepKernel::execute(ContextImpl& context, const No
// If the atom reordering has occured, the forces from the previous step are permuted and thus invalid. // If the atom reordering has occured, the forces from the previous step are permuted and thus invalid.
// They need to be either sorted or recomputed; here we choose the latter. // They need to be either sorted or recomputed; here we choose the latter.
if (!forcesAreValid || cc.getAtomsWereReordered()) context.calcForcesAndEnergy(true, false); if (!forcesAreValid || cc.getAtomsWereReordered()) context.calcForcesAndEnergy(true, false, integrator.getIntegrationForceGroups());
const auto& atomList = integrator.getAllThermostatedIndividualParticles(); const auto& atomList = integrator.getAllThermostatedIndividualParticles();
const auto& pairList = integrator.getAllThermostatedPairs(); const auto& pairList = integrator.getAllThermostatedPairs();
...@@ -6770,7 +6770,7 @@ void CommonIntegrateCustomStepKernel::prepareForComputation(ContextImpl& context ...@@ -6770,7 +6770,7 @@ void CommonIntegrateCustomStepKernel::prepareForComputation(ContextImpl& context
// Record the variable names and flags for the force and energy in each step. // Record the variable names and flags for the force and energy in each step.
forceGroupFlags.resize(numSteps, -1); forceGroupFlags.resize(numSteps, integrator.getIntegrationForceGroups());
vector<string> forceGroupName; vector<string> forceGroupName;
vector<string> energyGroupName; vector<string> energyGroupName;
for (int i = 0; i < 32; i++) { for (int i = 0; i < 32; i++) {
...@@ -6957,7 +6957,7 @@ void CommonIntegrateCustomStepKernel::prepareForComputation(ContextImpl& context ...@@ -6957,7 +6957,7 @@ void CommonIntegrateCustomStepKernel::prepareForComputation(ContextImpl& context
if (cc.getUseMixedPrecision()) if (cc.getUseMixedPrecision())
kernel->addArg(cc.getPosqCorrection()); kernel->addArg(cc.getPosqCorrection());
else else
kernel->addArg(NULL); kernel->addArg(nullptr);
kernel->addArg(integration.getPosDelta()); kernel->addArg(integration.getPosDelta());
kernel->addArg(cc.getVelm()); kernel->addArg(cc.getVelm());
kernel->addArg(cc.getLongForceBuffer()); kernel->addArg(cc.getLongForceBuffer());
...@@ -6992,7 +6992,7 @@ void CommonIntegrateCustomStepKernel::prepareForComputation(ContextImpl& context ...@@ -6992,7 +6992,7 @@ void CommonIntegrateCustomStepKernel::prepareForComputation(ContextImpl& context
if (cc.getUseMixedPrecision()) if (cc.getUseMixedPrecision())
kernel->addArg(cc.getPosqCorrection()); kernel->addArg(cc.getPosqCorrection());
else else
kernel->addArg(NULL); kernel->addArg(nullptr);
kernel->addArg(integration.getPosDelta()); kernel->addArg(integration.getPosDelta());
} }
} }
...@@ -7048,7 +7048,7 @@ void CommonIntegrateCustomStepKernel::prepareForComputation(ContextImpl& context ...@@ -7048,7 +7048,7 @@ void CommonIntegrateCustomStepKernel::prepareForComputation(ContextImpl& context
if (cc.getUseMixedPrecision()) if (cc.getUseMixedPrecision())
kineticEnergyKernel->addArg(cc.getPosqCorrection()); kineticEnergyKernel->addArg(cc.getPosqCorrection());
else else
kineticEnergyKernel->addArg(NULL); kineticEnergyKernel->addArg(nullptr);
kineticEnergyKernel->addArg(integration.getPosDelta()); kineticEnergyKernel->addArg(integration.getPosDelta());
kineticEnergyKernel->addArg(cc.getVelm()); kineticEnergyKernel->addArg(cc.getVelm());
kineticEnergyKernel->addArg(cc.getLongForceBuffer()); kineticEnergyKernel->addArg(cc.getLongForceBuffer());
......
...@@ -549,7 +549,7 @@ IntegrationUtilities::IntegrationUtilities(ComputeContext& context, const System ...@@ -549,7 +549,7 @@ IntegrationUtilities::IntegrationUtilities(ComputeContext& context, const System
if (context.getUseMixedPrecision()) if (context.getUseMixedPrecision())
vsitePositionKernel->addArg(context.getPosqCorrection()); vsitePositionKernel->addArg(context.getPosqCorrection());
else else
vsitePositionKernel->addArg(NULL); vsitePositionKernel->addArg(nullptr);
vsitePositionKernel->addArg(vsite2AvgAtoms); vsitePositionKernel->addArg(vsite2AvgAtoms);
vsitePositionKernel->addArg(vsite2AvgWeights); vsitePositionKernel->addArg(vsite2AvgWeights);
vsitePositionKernel->addArg(vsite3AvgAtoms); vsitePositionKernel->addArg(vsite3AvgAtoms);
...@@ -565,7 +565,7 @@ IntegrationUtilities::IntegrationUtilities(ComputeContext& context, const System ...@@ -565,7 +565,7 @@ IntegrationUtilities::IntegrationUtilities(ComputeContext& context, const System
if (context.getUseMixedPrecision()) if (context.getUseMixedPrecision())
vsiteForceKernel->addArg(context.getPosqCorrection()); vsiteForceKernel->addArg(context.getPosqCorrection());
else else
vsiteForceKernel->addArg(NULL); vsiteForceKernel->addArg(nullptr);
vsiteForceKernel->addArg(); // Skip argument 2: the force array hasn't been created yet. vsiteForceKernel->addArg(); // Skip argument 2: the force array hasn't been created yet.
vsiteForceKernel->addArg(vsite2AvgAtoms); vsiteForceKernel->addArg(vsite2AvgAtoms);
vsiteForceKernel->addArg(vsite2AvgWeights); vsiteForceKernel->addArg(vsite2AvgWeights);
......
...@@ -61,8 +61,8 @@ angleB = fmod(angleB+2.0f*PI, 2.0f*PI); ...@@ -61,8 +61,8 @@ angleB = fmod(angleB+2.0f*PI, 2.0f*PI);
int2 pos = MAP_POS[MAPS[index]]; int2 pos = MAP_POS[MAPS[index]];
int size = pos.y; int size = pos.y;
real delta = 2*PI/size; real delta = 2*PI/size;
int s = (int) fmin(angleA/delta, size-1); int s = (int) fmin(angleA/delta, (real) (size-1));
int t = (int) fmin(angleB/delta, size-1); int t = (int) fmin(angleB/delta, (real) (size-1));
float4 c[4]; float4 c[4];
int coeffIndex = pos.x+4*(s+size*t); int coeffIndex = pos.x+4*(s+size*t);
c[0] = COEFF[coeffIndex]; c[0] = COEFF[coeffIndex];
......
...@@ -3,8 +3,8 @@ typedef double TempType; ...@@ -3,8 +3,8 @@ typedef double TempType;
typedef double3 TempType3; typedef double3 TempType3;
typedef double4 TempType4; typedef double4 TempType4;
#define make_TempType3(...) make_double3(__VA_ARGS__) #define make_TempType3 make_double3
#define make_TempType4(...) make_double4(__VA_ARGS__) #define make_TempType4 make_double4
#define convertToTempType3(a) make_double3((a).x, (a).y, (a).z) #define convertToTempType3(a) make_double3((a).x, (a).y, (a).z)
#define convertToTempType4(a) make_double4((a).x, (a).y, (a).z, (a).w) #define convertToTempType4(a) make_double4((a).x, (a).y, (a).z, (a).w)
...@@ -16,8 +16,8 @@ typedef float TempType; ...@@ -16,8 +16,8 @@ typedef float TempType;
typedef float3 TempType3; typedef float3 TempType3;
typedef float4 TempType4; typedef float4 TempType4;
#define make_TempType3(...) make_float3(__VA_ARGS__) #define make_TempType3 make_float3
#define make_TempType4(...) make_float4(__VA_ARGS__) #define make_TempType4 make_float4
#define convertToTempType3(a) make_float3((a).x, (a).y, (a).z) #define convertToTempType3(a) make_float3((a).x, (a).y, (a).z)
#define convertToTempType4(a) make_float4((a).x, (a).y, (a).z, (a).w) #define convertToTempType4(a) make_float4((a).x, (a).y, (a).z, (a).w)
#endif #endif
......
...@@ -51,7 +51,7 @@ public: ...@@ -51,7 +51,7 @@ public:
const Vec3* periodicBoxVectors, bool usePeriodic, float maxDistance, ThreadPool& threads); const Vec3* periodicBoxVectors, bool usePeriodic, float maxDistance, ThreadPool& threads);
int getNumBlocks() const; int getNumBlocks() const;
int getBlockSize() const; int getBlockSize() const;
const std::vector<int>& getSortedAtoms() const; const std::vector<int32_t>& getSortedAtoms() const;
const std::vector<int>& getBlockNeighbors(int blockIndex) const; const std::vector<int>& getBlockNeighbors(int blockIndex) const;
/** /**
......
...@@ -109,10 +109,8 @@ CpuNonbondedForceFvec<FVEC>::approximateFunctionFromTable(const std::vector<floa ...@@ -109,10 +109,8 @@ CpuNonbondedForceFvec<FVEC>::approximateFunctionFromTable(const std::vector<floa
FVEC s1, s2; FVEC s1, s2;
gatherVecPair(table.data(), index, s1, s2); gatherVecPair(table.data(), index, s1, s2);
const auto coeff2 = x1-FVEC(index); const auto coeff2 = x1 - FVEC(index);
const auto coeff1 = 1.0f-coeff2; return (s1 - coeff2 * s1) + coeff2 * s2;
return coeff1*s1 + coeff2*s2;
} }
template<typename FVEC> template<typename FVEC>
...@@ -140,7 +138,7 @@ void CpuNonbondedForceFvec<FVEC>::calculateBlockIxnHandler(int blockIndex, float ...@@ -140,7 +138,7 @@ void CpuNonbondedForceFvec<FVEC>::calculateBlockIxnHandler(int blockIndex, float
using std::min; using std::min;
using std::max; using std::max;
const int* blockAtom = &neighborList->getSortedAtoms()[blockSize*blockIndex]; const int32_t* blockAtom = &neighborList->getSortedAtoms()[blockSize*blockIndex];
float minx, maxx, miny, maxy, minz, maxz; float minx, maxx, miny, maxy, minz, maxz;
minx = maxx = posq[4*blockAtom[0]]; minx = maxx = posq[4*blockAtom[0]];
miny = maxy = posq[4*blockAtom[0]+1]; miny = maxy = posq[4*blockAtom[0]+1];
...@@ -183,7 +181,7 @@ template <int PERIODIC_TYPE, BlockType BLOCK_TYPE> ...@@ -183,7 +181,7 @@ template <int PERIODIC_TYPE, BlockType BLOCK_TYPE>
void CpuNonbondedForceFvec<FVEC>::calculateBlockIxnImpl(int blockIndex, float* forces, double* totalEnergy, const fvec4& boxSize, const fvec4& invBoxSize, const fvec4& blockCenter) { void CpuNonbondedForceFvec<FVEC>::calculateBlockIxnImpl(int blockIndex, float* forces, double* totalEnergy, const fvec4& boxSize, const fvec4& invBoxSize, const fvec4& blockCenter) {
// Load the positions and parameters of the atoms in the block. // Load the positions and parameters of the atoms in the block.
const int* blockAtom = &neighborList->getSortedAtoms()[blockSize * blockIndex]; const int32_t* blockAtom = &neighborList->getSortedAtoms()[blockSize * blockIndex];
fvec4 blockAtomPosq[blockSize]; fvec4 blockAtomPosq[blockSize];
FVEC blockAtomForceX(0.0f), blockAtomForceY(0.0f), blockAtomForceZ(0.0f); FVEC blockAtomForceX(0.0f), blockAtomForceY(0.0f), blockAtomForceZ(0.0f);
FVEC blockAtomX, blockAtomY, blockAtomZ, blockAtomCharge; FVEC blockAtomX, blockAtomY, blockAtomZ, blockAtomCharge;
...@@ -216,6 +214,8 @@ void CpuNonbondedForceFvec<FVEC>::calculateBlockIxnImpl(int blockIndex, float* f ...@@ -216,6 +214,8 @@ void CpuNonbondedForceFvec<FVEC>::calculateBlockIxnImpl(int blockIndex, float* f
// Loop over neighbors for this block. // Loop over neighbors for this block.
const auto& neighbors = neighborList->getBlockNeighbors(blockIndex); const auto& neighbors = neighborList->getBlockNeighbors(blockIndex);
const auto& exclusions = neighborList->getBlockExclusions(blockIndex); const auto& exclusions = neighborList->getBlockExclusions(blockIndex);
FVEC partialEnergy = {};
for (int i = 0; i < (int) neighbors.size(); i++) { for (int i = 0; i < (int) neighbors.size(); i++) {
// Load the next neighbor. // Load the next neighbor.
...@@ -230,7 +230,7 @@ void CpuNonbondedForceFvec<FVEC>::calculateBlockIxnImpl(int blockIndex, float* f ...@@ -230,7 +230,7 @@ void CpuNonbondedForceFvec<FVEC>::calculateBlockIxnImpl(int blockIndex, float* f
getDeltaR<PERIODIC_TYPE>(atomPos, blockAtomX, blockAtomY, blockAtomZ, dx, dy, dz, r2, boxSize, invBoxSize); getDeltaR<PERIODIC_TYPE>(atomPos, blockAtomX, blockAtomY, blockAtomZ, dx, dy, dz, r2, boxSize, invBoxSize);
const auto exclNotMask = FVEC::expandBitsToMask(~exclusions[i]); const auto exclNotMask = FVEC::expandBitsToMask(~exclusions[i]);
const auto include = blendZero(r2 < cutoffDistance*cutoffDistance, exclNotMask); const auto include = blendZero(r2 < cutoffDistanceSquared, exclNotMask);
if (!any(include)) if (!any(include))
continue; // No interactions to compute. continue; // No interactions to compute.
...@@ -296,7 +296,8 @@ void CpuNonbondedForceFvec<FVEC>::calculateBlockIxnImpl(int blockIndex, float* f ...@@ -296,7 +296,8 @@ void CpuNonbondedForceFvec<FVEC>::calculateBlockIxnImpl(int blockIndex, float* f
energy += chargeProd*inverseR; energy += chargeProd*inverseR;
} }
energy = blendZero(energy, include); energy = blendZero(energy, include);
*totalEnergy += reduceAdd(energy);
partialEnergy += energy;
} }
// Accumulate forces. // Accumulate forces.
...@@ -313,6 +314,9 @@ void CpuNonbondedForceFvec<FVEC>::calculateBlockIxnImpl(int blockIndex, float* f ...@@ -313,6 +314,9 @@ void CpuNonbondedForceFvec<FVEC>::calculateBlockIxnImpl(int blockIndex, float* f
newAtomForce.store(atomForce); newAtomForce.store(atomForce);
} }
if (totalEnergy)
*totalEnergy += reduceAdd(partialEnergy);
// Record the forces on the block atoms. // Record the forces on the block atoms.
fvec4 f[blockSize]; fvec4 f[blockSize];
transpose(blockAtomForceX, blockAtomForceY, blockAtomForceZ, 0.0f, f); transpose(blockAtomForceX, blockAtomForceY, blockAtomForceZ, 0.0f, f);
......
FOREACH(file ${SOURCE_FILES}) FOREACH(file ${SOURCE_FILES})
IF(file MATCHES ".*Vec8.*") IF(X86 AND NOT MSVC)
IF(MSVC) SET_SOURCE_FILES_PROPERTIES(${file} PROPERTIES COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} -msse4.1")
SET_SOURCE_FILES_PROPERTIES(${file} PROPERTIES COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} /arch:AVX /D__AVX__")
ELSEIF(X86)
SET_SOURCE_FILES_PROPERTIES(${file} PROPERTIES COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} -msse4.1 -mavx")
ELSE()
SET_SOURCE_FILES_PROPERTIES(${file} PROPERTIES COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS}")
ENDIF()
ELSE()
IF(X86 AND NOT MSVC)
SET_SOURCE_FILES_PROPERTIES(${file} PROPERTIES COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} -msse4.1")
ENDIF()
ENDIF() ENDIF()
ENDFOREACH(file) ENDFOREACH(file)
# Override some sources files with platform specific flags.
IF(MSVC)
SET_SOURCE_FILES_PROPERTIES(${CMAKE_SOURCE_DIR}/platforms/cpu/src/CpuNonbondedForceAvx.cpp PROPERTIES COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} /arch:AVX /D__AVX__")
SET_SOURCE_FILES_PROPERTIES(${CMAKE_SOURCE_DIR}/platforms/cpu/src/CpuNonbondedForceAvx2.cpp PROPERTIES COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} /arch:AVX2 /D__AVX2__")
ELSEIF(X86)
SET_SOURCE_FILES_PROPERTIES(${CMAKE_SOURCE_DIR}/platforms/cpu/src/CpuNonbondedForceAvx.cpp PROPERTIES COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} -mavx")
SET_SOURCE_FILES_PROPERTIES(${CMAKE_SOURCE_DIR}/platforms/cpu/src/CpuNonbondedForceAvx2.cpp PROPERTIES COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} -mavx2 -mfma")
ENDIF()
ADD_LIBRARY(${SHARED_TARGET} SHARED ${SOURCE_FILES} ${SOURCE_INCLUDE_FILES} ${API_ABS_INCLUDE_FILES}) ADD_LIBRARY(${SHARED_TARGET} SHARED ${SOURCE_FILES} ${SOURCE_INCLUDE_FILES} ${API_ABS_INCLUDE_FILES})
TARGET_LINK_LIBRARIES(${SHARED_TARGET} ${OPENMM_LIBRARY_NAME} ${PTHREADS_LIB}) TARGET_LINK_LIBRARIES(${SHARED_TARGET} ${OPENMM_LIBRARY_NAME} ${PTHREADS_LIB})
......
...@@ -41,7 +41,7 @@ CpuBondForce::CpuBondForce() { ...@@ -41,7 +41,7 @@ CpuBondForce::CpuBondForce() {
void CpuBondForce::initialize(int numAtoms, int numBonds, int numAtomsPerBond, vector<vector<int> >& bondAtoms, ThreadPool& threads) { void CpuBondForce::initialize(int numAtoms, int numBonds, int numAtomsPerBond, vector<vector<int> >& bondAtoms, ThreadPool& threads) {
this->numBonds = numBonds; this->numBonds = numBonds;
this->numAtomsPerBond = numAtomsPerBond; this->numAtomsPerBond = numAtomsPerBond;
this->bondAtoms = &bondAtoms[0]; this->bondAtoms = bondAtoms.empty() ? nullptr : bondAtoms.data();
this->threads = &threads; this->threads = &threads;
int numThreads = threads.getNumThreads(); int numThreads = threads.getNumThreads();
int targetBondsPerThread = numBonds/numThreads; int targetBondsPerThread = numBonds/numThreads;
......
...@@ -361,7 +361,7 @@ void CpuCustomGBForce::calculateParticlePairValue(int index, ThreadData& data, i ...@@ -361,7 +361,7 @@ void CpuCustomGBForce::calculateParticlePairValue(int index, ThreadData& data, i
if (blockIndex >= neighborList->getNumBlocks()) if (blockIndex >= neighborList->getNumBlocks())
break; break;
const int blockSize = neighborList->getBlockSize(); const int blockSize = neighborList->getBlockSize();
const int* blockAtom = &neighborList->getSortedAtoms()[blockSize*blockIndex]; const int32_t* blockAtom = &neighborList->getSortedAtoms()[blockSize*blockIndex];
const vector<int>& neighbors = neighborList->getBlockNeighbors(blockIndex); const vector<int>& neighbors = neighborList->getBlockNeighbors(blockIndex);
const auto& blockExclusions = neighborList->getBlockExclusions(blockIndex); const auto& blockExclusions = neighborList->getBlockExclusions(blockIndex);
for (int i = 0; i < (int) neighbors.size(); i++) { for (int i = 0; i < (int) neighbors.size(); i++) {
...@@ -456,7 +456,7 @@ void CpuCustomGBForce::calculateParticlePairEnergyTerm(int index, ThreadData& da ...@@ -456,7 +456,7 @@ void CpuCustomGBForce::calculateParticlePairEnergyTerm(int index, ThreadData& da
if (blockIndex >= neighborList->getNumBlocks()) if (blockIndex >= neighborList->getNumBlocks())
break; break;
const int blockSize = neighborList->getBlockSize(); const int blockSize = neighborList->getBlockSize();
const int* blockAtom = &neighborList->getSortedAtoms()[blockSize*blockIndex]; const int32_t* blockAtom = &neighborList->getSortedAtoms()[blockSize*blockIndex];
const vector<int>& neighbors = neighborList->getBlockNeighbors(blockIndex); const vector<int>& neighbors = neighborList->getBlockNeighbors(blockIndex);
const auto& blockExclusions = neighborList->getBlockExclusions(blockIndex); const auto& blockExclusions = neighborList->getBlockExclusions(blockIndex);
for (int i = 0; i < (int) neighbors.size(); i++) { for (int i = 0; i < (int) neighbors.size(); i++) {
...@@ -543,7 +543,7 @@ void CpuCustomGBForce::calculateChainRuleForces(ThreadData& data, int numAtoms, ...@@ -543,7 +543,7 @@ void CpuCustomGBForce::calculateChainRuleForces(ThreadData& data, int numAtoms,
if (blockIndex >= neighborList->getNumBlocks()) if (blockIndex >= neighborList->getNumBlocks())
break; break;
const int blockSize = neighborList->getBlockSize(); const int blockSize = neighborList->getBlockSize();
const int* blockAtom = &neighborList->getSortedAtoms()[blockSize*blockIndex]; const int32_t* blockAtom = &neighborList->getSortedAtoms()[blockSize*blockIndex];
const vector<int>& neighbors = neighborList->getBlockNeighbors(blockIndex); const vector<int>& neighbors = neighborList->getBlockNeighbors(blockIndex);
const auto& blockExclusions = neighborList->getBlockExclusions(blockIndex); const auto& blockExclusions = neighborList->getBlockExclusions(blockIndex);
for (int i = 0; i < (int) neighbors.size(); i++) { for (int i = 0; i < (int) neighbors.size(); i++) {
......
...@@ -193,7 +193,7 @@ void CpuCustomNonbondedForce::threadComputeForce(ThreadPool& threads, int thread ...@@ -193,7 +193,7 @@ void CpuCustomNonbondedForce::threadComputeForce(ThreadPool& threads, int thread
if (blockIndex >= neighborList->getNumBlocks()) if (blockIndex >= neighborList->getNumBlocks())
break; break;
const int blockSize = neighborList->getBlockSize(); const int blockSize = neighborList->getBlockSize();
const int* blockAtom = &neighborList->getSortedAtoms()[blockSize*blockIndex]; const int32_t* blockAtom = &neighborList->getSortedAtoms()[blockSize*blockIndex];
const vector<int>& neighbors = neighborList->getBlockNeighbors(blockIndex); const vector<int>& neighbors = neighborList->getBlockNeighbors(blockIndex);
const auto& exclusions = neighborList->getBlockExclusions(blockIndex); const auto& exclusions = neighborList->getBlockExclusions(blockIndex);
for (int i = 0; i < (int) neighbors.size(); i++) { for (int i = 0; i < (int) neighbors.size(); i++) {
......
...@@ -181,7 +181,7 @@ void CpuGayBerneForce::threadComputeForce(ThreadPool& threads, int threadIndex, ...@@ -181,7 +181,7 @@ void CpuGayBerneForce::threadComputeForce(ThreadPool& threads, int threadIndex,
if (blockIndex >= neighborList->getNumBlocks()) if (blockIndex >= neighborList->getNumBlocks())
break; break;
const int blockSize = neighborList->getBlockSize(); const int blockSize = neighborList->getBlockSize();
const int* blockAtom = &neighborList->getSortedAtoms()[blockSize*blockIndex]; const int32_t* blockAtom = &neighborList->getSortedAtoms()[blockSize*blockIndex];
const vector<int>& neighbors = neighborList->getBlockNeighbors(blockIndex); const vector<int>& neighbors = neighborList->getBlockNeighbors(blockIndex);
const auto& exclusions = neighborList->getBlockExclusions(blockIndex); const auto& exclusions = neighborList->getBlockExclusions(blockIndex);
for (int i = 0; i < (int) neighbors.size(); i++) { for (int i = 0; i < (int) neighbors.size(); i++) {
......
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