Commit aa7bd1cf authored by peastman's avatar peastman
Browse files

Fixed problems running in PNaCl

parent e670188b
...@@ -143,42 +143,15 @@ State Context::getState(int types, bool enforcePeriodicBox, int groups) const { ...@@ -143,42 +143,15 @@ State Context::getState(int types, bool enforcePeriodicBox, int groups) const {
} }
void Context::setState(const State& state) { void Context::setState(const State& state) {
// Determine what information the state contains.
bool hasPositions = false, hasVelocities = false, hasParameters = false;
try {
state.getPositions();
hasPositions = true;
}
catch (OpenMMException& ex) {
// The State does not include positions.
}
try {
state.getVelocities();
hasVelocities = true;
}
catch (OpenMMException& ex) {
// The State does not include velocities.
}
try {
state.getParameters();
hasParameters = true;
}
catch (OpenMMException& ex) {
// The State does not include parameters.
}
// Copy it over.
setTime(state.getTime()); setTime(state.getTime());
Vec3 a, b, c; Vec3 a, b, c;
state.getPeriodicBoxVectors(a, b, c); state.getPeriodicBoxVectors(a, b, c);
setPeriodicBoxVectors(a, b, c); setPeriodicBoxVectors(a, b, c);
if (hasPositions) if ((state.getDataTypes()&State::Positions) != 0)
setPositions(state.getPositions()); setPositions(state.getPositions());
if (hasVelocities) if ((state.getDataTypes()&State::Velocities) != 0)
setVelocities(state.getVelocities()); setVelocities(state.getVelocities());
if (hasParameters) if ((state.getDataTypes()&State::Parameters) != 0)
for (map<string, double>::const_iterator iter = state.getParameters().begin(); iter != state.getParameters().end(); ++iter) for (map<string, double>::const_iterator iter = state.getParameters().begin(); iter != state.getParameters().end(); ++iter)
setParameter(iter->first, iter->second); setParameter(iter->first, iter->second);
} }
......
...@@ -508,13 +508,12 @@ double CpuCalcNonbondedForceKernel::execute(ContextImpl& context, bool includeFo ...@@ -508,13 +508,12 @@ double CpuCalcNonbondedForceKernel::execute(ContextImpl& context, bool includeFo
if (nonbondedMethod == PME) { if (nonbondedMethod == PME) {
// If available, use the optimized PME implementation. // If available, use the optimized PME implementation.
try { vector<string> kernelNames;
kernelNames.push_back("CalcPmeReciprocalForce");
useOptimizedPme = getPlatform().supportsKernels(kernelNames);
if (useOptimizedPme) {
optimizedPme = getPlatform().createKernel(CalcPmeReciprocalForceKernel::Name(), context); optimizedPme = getPlatform().createKernel(CalcPmeReciprocalForceKernel::Name(), context);
optimizedPme.getAs<CalcPmeReciprocalForceKernel>().initialize(gridSize[0], gridSize[1], gridSize[2], numParticles, ewaldAlpha); optimizedPme.getAs<CalcPmeReciprocalForceKernel>().initialize(gridSize[0], gridSize[1], gridSize[2], numParticles, ewaldAlpha);
useOptimizedPme = true;
}
catch (OpenMMException& ex) {
// The CPU PME plugin isn't available.
} }
} }
} }
......
...@@ -216,7 +216,7 @@ void CpuNonbondedForce::calculateReciprocalIxn(int numberOfAtoms, float* posq, c ...@@ -216,7 +216,7 @@ void CpuNonbondedForce::calculateReciprocalIxn(int numberOfAtoms, float* posq, c
// setup reciprocal box // setup reciprocal box
float recipBoxSize[3] = { TWO_PI / periodicBoxVectors[0][0], TWO_PI / periodicBoxVectors[1][1], TWO_PI / periodicBoxVectors[2][2]}; float recipBoxSize[3] = {(float) (TWO_PI/periodicBoxVectors[0][0]), (float) (TWO_PI/periodicBoxVectors[1][1]), (float) (TWO_PI/periodicBoxVectors[2][2])};
// setup K-vectors // setup K-vectors
......
...@@ -62,7 +62,7 @@ void testNeighborList(bool periodic, bool triclinic) { ...@@ -62,7 +62,7 @@ void testNeighborList(bool periodic, bool triclinic) {
boxVectors[1] = RealVec(0, 15, 0); boxVectors[1] = RealVec(0, 15, 0);
boxVectors[2] = RealVec(0, 0, 22); boxVectors[2] = RealVec(0, 0, 22);
} }
const float boxSize[3] = {boxVectors[0][0], boxVectors[1][1], boxVectors[2][2]}; const float boxSize[3] = {(float) boxVectors[0][0], (float) boxVectors[1][1], (float) boxVectors[2][2]};
const int blockSize = 8; const int blockSize = 8;
OpenMM_SFMT::SFMT sfmt; OpenMM_SFMT::SFMT sfmt;
init_gen_rand(0, sfmt); init_gen_rand(0, sfmt);
......
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