Created
May 5, 2014 17:38
-
-
Save proteneer/cf5f480138d2f67cbcc1 to your computer and use it in GitHub Desktop.
MultiGPU Bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import simtk.openmm | |
import simtk.unit as unit | |
import math | |
state = simtk.openmm.XmlSerializer.deserialize(open('state.xml').read()) | |
system = simtk.openmm.XmlSerializer.deserialize(open('system.xml').read()) | |
for i, force in enumerate(system.getForces()): | |
force.setForceGroup(i) | |
system.getForce(3).setReciprocalSpaceForceGroup(6) | |
properties = {"OpenCLPlatformIndex": "0", "OpenCLDeviceIndex": "0,1"} | |
integrator = simtk.openmm.XmlSerializer.deserialize(open('integrator.xml').read()) | |
gpuContext = simtk.openmm.Context(system, integrator, simtk.openmm.Platform.getPlatformByName('OpenCL'), properties) | |
gpuContext.setState(state) | |
integrator2 = simtk.openmm.XmlSerializer.deserialize(open('integrator.xml').read()) | |
refContext = simtk.openmm.Context(system, integrator2, simtk.openmm.Platform.getPlatformByName('Reference')) | |
refContext.setState(state) | |
group = 3 | |
gpuForces = gpuContext.getState(getForces=True, groups=1<<group).getForces() | |
refForces = refContext.getState(getForces=True, groups=1<<group).getForces() | |
mse = 0 | |
for i, (f1, f2) in enumerate(zip(gpuForces, refForces)): | |
diff = f1 - f2 | |
error = (diff[0]*diff[0]+diff[1]*diff[1]+diff[2]*diff[2]).value_in_unit(unit.kilojoules**2/(unit.nanometers**2*unit.moles**2)) | |
if(error > 2000): | |
print(f1, f2) | |
print(i, error) | |
mse += error | |
mse = math.sqrt(mse/len(refForces)) | |
print('RMSE: ', error) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment