"openmmapi/vscode:/vscode.git/clone" did not exist on "97ff35ad336aaeb5a841029c1e062ea43d570015"
Commit e274d455 authored by Peter Eastman's avatar Peter Eastman
Browse files

Fixed bug when CustomGBForce was told to use exclusions, but didn't have any...

Fixed bug when CustomGBForce was told to use exclusions, but didn't have any exclusions.  (See bug 1519.)
parent 6ab42996
...@@ -2136,15 +2136,14 @@ void OpenCLCalcCustomGBForceKernel::initialize(const System& system, const Custo ...@@ -2136,15 +2136,14 @@ void OpenCLCalcCustomGBForceKernel::initialize(const System& system, const Custo
for (int i = 0; i < force.getNumGlobalParameters(); i++) for (int i = 0; i < force.getNumGlobalParameters(); i++)
variables[force.getGlobalParameterName(i)] = "globals["+intToString(i)+"]"; variables[force.getGlobalParameterName(i)] = "globals["+intToString(i)+"]";
stringstream n2EnergySource; stringstream n2EnergySource;
bool anyExclusions = false; bool anyExclusions = (force.getNumExclusions() > 0);
for (int i = 0; i < force.getNumEnergyTerms(); i++) { for (int i = 0; i < force.getNumEnergyTerms(); i++) {
string expression; string expression;
CustomGBForce::ComputationType type; CustomGBForce::ComputationType type;
force.getEnergyTermParameters(i, expression, type); force.getEnergyTermParameters(i, expression, type);
if (type == CustomGBForce::SingleParticle) if (type == CustomGBForce::SingleParticle)
continue; continue;
bool exclude = (type == CustomGBForce::ParticlePair); bool exclude = (anyExclusions && type == CustomGBForce::ParticlePair);
anyExclusions |= exclude;
map<string, Lepton::ParsedExpression> n2EnergyExpressions; map<string, Lepton::ParsedExpression> n2EnergyExpressions;
n2EnergyExpressions["tempEnergy += "] = Lepton::Parser::parse(expression, functions).optimize(); n2EnergyExpressions["tempEnergy += "] = Lepton::Parser::parse(expression, functions).optimize();
n2EnergyExpressions["dEdR += "] = Lepton::Parser::parse(expression, functions).differentiate("r").optimize(); n2EnergyExpressions["dEdR += "] = Lepton::Parser::parse(expression, functions).differentiate("r").optimize();
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
using namespace OpenMM; using namespace OpenMM;
using namespace std; using namespace std;
OpenCLNonbondedUtilities::OpenCLNonbondedUtilities(OpenCLContext& context) : context(context), cutoff(-1.0), useCutoff(false), OpenCLNonbondedUtilities::OpenCLNonbondedUtilities(OpenCLContext& context) : context(context), cutoff(-1.0), useCutoff(false), anyExclusions(false),
numForceBuffers(0), exclusionIndices(NULL), exclusionRowIndices(NULL), exclusions(NULL), interactingTiles(NULL), interactionFlags(NULL), numForceBuffers(0), exclusionIndices(NULL), exclusionRowIndices(NULL), exclusions(NULL), interactingTiles(NULL), interactionFlags(NULL),
interactionCount(NULL), blockCenter(NULL), blockBoundingBox(NULL) { interactionCount(NULL), blockCenter(NULL), blockBoundingBox(NULL) {
// Decide how many thread blocks and force buffers to use. // Decide how many thread blocks and force buffers to use.
...@@ -93,7 +93,7 @@ void OpenCLNonbondedUtilities::addInteraction(bool usesCutoff, bool usesPeriodic ...@@ -93,7 +93,7 @@ void OpenCLNonbondedUtilities::addInteraction(bool usesCutoff, bool usesPeriodic
if (cutoffDistance != cutoff) if (cutoffDistance != cutoff)
throw OpenMMException("All Forces must use the same cutoff distance"); throw OpenMMException("All Forces must use the same cutoff distance");
} }
if (usesExclusions && atomExclusions.size() != 0) { if (usesExclusions && anyExclusions) {
bool sameExclusions = (exclusionList.size() == atomExclusions.size()); bool sameExclusions = (exclusionList.size() == atomExclusions.size());
for (int i = 0; i < (int) exclusionList.size() && sameExclusions; i++) { for (int i = 0; i < (int) exclusionList.size() && sameExclusions; i++) {
if (exclusionList[i].size() != atomExclusions[i].size()) if (exclusionList[i].size() != atomExclusions[i].size())
...@@ -109,8 +109,10 @@ void OpenCLNonbondedUtilities::addInteraction(bool usesCutoff, bool usesPeriodic ...@@ -109,8 +109,10 @@ void OpenCLNonbondedUtilities::addInteraction(bool usesCutoff, bool usesPeriodic
usePeriodic = usesPeriodic; usePeriodic = usesPeriodic;
cutoff = cutoffDistance; cutoff = cutoffDistance;
kernelSource += kernel+"\n"; kernelSource += kernel+"\n";
if (usesExclusions) if (usesExclusions && !anyExclusions) {
atomExclusions = exclusionList; atomExclusions = exclusionList;
anyExclusions = true;
}
} }
void OpenCLNonbondedUtilities::addParameter(const ParameterInfo& parameter) { void OpenCLNonbondedUtilities::addParameter(const ParameterInfo& parameter) {
......
...@@ -245,7 +245,7 @@ private: ...@@ -245,7 +245,7 @@ private:
std::string kernelSource; std::string kernelSource;
std::map<std::string, std::string> kernelDefines; std::map<std::string, std::string> kernelDefines;
double cutoff; double cutoff;
bool useCutoff, usePeriodic, forceBufferPerAtomBlock, deviceIsCpu; bool useCutoff, usePeriodic, forceBufferPerAtomBlock, deviceIsCpu, anyExclusions;
int numForceBuffers, startTileIndex, numTiles, numForceThreadBlocks, forceThreadBlockSize; int numForceBuffers, startTileIndex, numTiles, numForceThreadBlocks, forceThreadBlockSize;
}; };
......
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