Commit 2be8bb45 authored by Robert McGibbon's avatar Robert McGibbon
Browse files

Maybe faster appveyor

parents 5fb0a748 149faaed
...@@ -41,11 +41,11 @@ script: ...@@ -41,11 +41,11 @@ script:
- # Run the testInstallation script - # Run the testInstallation script
- python -m simtk.testInstallation - python -m simtk.testInstallation
- # run all of the tests, making sure failures at this stage don't cause travis failures - # run all of the tests, making sure failures at this stage don't cause travis failures
- ctest -j2 -V || true - ctest -j2 || true
- # get a list of all of the failed tests into this stupid ctest format - # get a list of all of the failed tests into this stupid ctest format
- python -c 'fn = "Testing/Temporary/LastTestsFailed.log"; import os; os.path.exists(fn) or exit(0); l = [line.split(":")[0] for line in open(fn)]; triplets = zip(l, l, [","]*len(l)); print "".join(",".join(t) for t in triplets)' > FailedTests.log - python -c 'fn = "Testing/Temporary/LastTestsFailed.log"; import os; os.path.exists(fn) or exit(0); l = [line.split(":")[0] for line in open(fn)]; triplets = zip(l, l, [","]*len(l)); print "".join(",".join(t) for t in triplets)' > FailedTests.log
- # rerun all of the failed tests - # rerun all of the failed tests
- if [ -s FailedTests.log ]; then ctest -V -I FailedTests.log; fi; - if [ -s Testing/Temporary/LastTestsFailed.log ]; then ctest -I FailedTests.log; fi;
- # run the python tests too - # run the python tests too
- cd python/tests - cd python/tests
- pip install nose - pip install nose
......
...@@ -122,7 +122,10 @@ ELSE (APPLE AND (NOT PNACL)) ...@@ -122,7 +122,10 @@ ELSE (APPLE AND (NOT PNACL))
IF (MSVC OR ANDROID OR PNACL) IF (MSVC OR ANDROID OR PNACL)
SET(EXTRA_COMPILE_FLAGS) SET(EXTRA_COMPILE_FLAGS)
IF (MSVC) IF (MSVC)
# Use warning level 2, not whatever warning level CMake picked.
STRING(REGEX REPLACE "/W[0-4]" "/W2" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") STRING(REGEX REPLACE "/W[0-4]" "/W2" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
# Explicitly suppress warnings 4305 and 4244.
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4305 /wd4244")
ENDIF (MSVC) ENDIF (MSVC)
ELSE (MSVC OR ANDROID OR PNACL) ELSE (MSVC OR ANDROID OR PNACL)
SET(EXTRA_COMPILE_FLAGS "-msse2") SET(EXTRA_COMPILE_FLAGS "-msse2")
......
...@@ -28,16 +28,19 @@ install: ...@@ -28,16 +28,19 @@ install:
- cd build - cd build
- cmake -G "NMake Makefiles" %CMAKE_FLAGS% -LA .. - cmake -G "NMake Makefiles" %CMAKE_FLAGS% -LA ..
build_script: # Run the build
- cmake --build . --target install - cmake --build . --target install
- cmake --build . --target PythonInstall - cmake --build . --target PythonInstall
build: false
test_script: test_script:
- ctest && exit 0 - ctest || exit 0
- python -c "import os; fn = os.path.join('Testing', 'Temporary', 'LastTestsFailed.log'); os.path.exists(fn) or exit(0); l = [line.split(':')[0] for line in open(fn)]; triplets = zip(l, l, [',']*len(l)); print(''.join(','.join(t) for t in triplets))" > FailedTests.log - python -c "import os; fn = os.path.join('Testing', 'Temporary', 'LastTestsFailed.log'); os.path.exists(fn) or exit(0); failed = [line.split(':')[0] for line in open(fn)]; print(','.join(x+','+x for x in failed))" > FailedTests.log
- ps: > - ps: >
If (Test-Path "FailedTests.log") { If (Test-Path "Testing\\Temporary\\LastTestsFailed.log") {
ctest -V -I FailedTests.log cat Testing\\Temporary\\LastTestsFailed.log
cat FailedTests.log
ctest -I FailedTests.log
} }
- cd python\tests - cd python\tests
- nosetests -vv --processes=-1 --process-timeout=200 - nosetests -vv --processes=-1 --process-timeout=200
......
...@@ -142,8 +142,10 @@ public: ...@@ -142,8 +142,10 @@ public:
void computeInteractions(int forceGroups); void computeInteractions(int forceGroups);
/** /**
* Check to see if the neighbor list arrays are large enough, and make them bigger if necessary. * Check to see if the neighbor list arrays are large enough, and make them bigger if necessary.
*
* @return true if the neighbor list needed to be enlarged.
*/ */
void updateNeighborListSize(); bool updateNeighborListSize();
/** /**
* Get the array containing the center of each atom block. * Get the array containing the center of each atom block.
*/ */
......
...@@ -375,11 +375,16 @@ void CudaNonbondedUtilities::prepareInteractions(int forceGroups) { ...@@ -375,11 +375,16 @@ void CudaNonbondedUtilities::prepareInteractions(int forceGroups) {
if (lastCutoff != kernels.cutoffDistance) if (lastCutoff != kernels.cutoffDistance)
forceRebuildNeighborList = true; forceRebuildNeighborList = true;
bool rebuild = false;
do {
context.executeKernel(kernels.findBlockBoundsKernel, &findBlockBoundsArgs[0], context.getNumAtoms()); context.executeKernel(kernels.findBlockBoundsKernel, &findBlockBoundsArgs[0], context.getNumAtoms());
blockSorter->sort(*sortedBlocks); blockSorter->sort(*sortedBlocks);
context.executeKernel(kernels.sortBoxDataKernel, &sortBoxDataArgs[0], context.getNumAtoms()); context.executeKernel(kernels.sortBoxDataKernel, &sortBoxDataArgs[0], context.getNumAtoms());
context.executeKernel(kernels.findInteractingBlocksKernel, &findInteractingBlocksArgs[0], context.getNumAtoms(), 256); context.executeKernel(kernels.findInteractingBlocksKernel, &findInteractingBlocksArgs[0], context.getNumAtoms(), 256);
forceRebuildNeighborList = false; forceRebuildNeighborList = false;
if (context.getComputeForceCount() == 1)
rebuild = updateNeighborListSize(); // This is the first time step, so check whether our initial guess was large enough.
} while(rebuild);
lastCutoff = kernels.cutoffDistance; lastCutoff = kernels.cutoffDistance;
} }
...@@ -389,18 +394,16 @@ void CudaNonbondedUtilities::computeInteractions(int forceGroups) { ...@@ -389,18 +394,16 @@ void CudaNonbondedUtilities::computeInteractions(int forceGroups) {
KernelSet& kernels = groupKernels[forceGroups]; KernelSet& kernels = groupKernels[forceGroups];
if (kernels.hasForces) { if (kernels.hasForces) {
context.executeKernel(kernels.forceKernel, &forceArgs[0], numForceThreadBlocks*forceThreadBlockSize, forceThreadBlockSize); context.executeKernel(kernels.forceKernel, &forceArgs[0], numForceThreadBlocks*forceThreadBlockSize, forceThreadBlockSize);
if (context.getComputeForceCount() == 1)
updateNeighborListSize(); // This is the first time step, so check whether our initial guess was large enough.
} }
} }
void CudaNonbondedUtilities::updateNeighborListSize() { bool CudaNonbondedUtilities::updateNeighborListSize() {
if (!useCutoff) if (!useCutoff)
return; return false;
unsigned int* pinnedInteractionCount = (unsigned int*) context.getPinnedBuffer(); unsigned int* pinnedInteractionCount = (unsigned int*) context.getPinnedBuffer();
interactionCount->download(pinnedInteractionCount); interactionCount->download(pinnedInteractionCount);
if (pinnedInteractionCount[0] <= (unsigned int) maxTiles) if (pinnedInteractionCount[0] <= (unsigned int) maxTiles)
return; return false;
// The most recent timestep had too many interactions to fit in the arrays. Make the arrays bigger to prevent // The most recent timestep had too many interactions to fit in the arrays. Make the arrays bigger to prevent
// this from happening in the future. // this from happening in the future.
...@@ -422,6 +425,7 @@ void CudaNonbondedUtilities::updateNeighborListSize() { ...@@ -422,6 +425,7 @@ void CudaNonbondedUtilities::updateNeighborListSize() {
forceArgs[17] = &interactingAtoms->getDevicePointer(); forceArgs[17] = &interactingAtoms->getDevicePointer();
findInteractingBlocksArgs[7] = &interactingAtoms->getDevicePointer(); findInteractingBlocksArgs[7] = &interactingAtoms->getDevicePointer();
forceRebuildNeighborList = true; forceRebuildNeighborList = true;
return true;
} }
void CudaNonbondedUtilities::setUsePadding(bool padding) { void CudaNonbondedUtilities::setUsePadding(bool padding) {
......
...@@ -154,8 +154,10 @@ public: ...@@ -154,8 +154,10 @@ public:
void computeInteractions(int forceGroups); void computeInteractions(int forceGroups);
/** /**
* Check to see if the neighbor list arrays are large enough, and make them bigger if necessary. * Check to see if the neighbor list arrays are large enough, and make them bigger if necessary.
*
* @return true if the neighbor list needed to be enlarged.
*/ */
void updateNeighborListSize(); bool updateNeighborListSize();
/** /**
* Get the array containing the center of each atom block. * Get the array containing the center of each atom block.
*/ */
......
...@@ -341,6 +341,8 @@ void OpenCLNonbondedUtilities::prepareInteractions(int forceGroups) { ...@@ -341,6 +341,8 @@ void OpenCLNonbondedUtilities::prepareInteractions(int forceGroups) {
if (lastCutoff != kernels.cutoffDistance) if (lastCutoff != kernels.cutoffDistance)
forceRebuildNeighborList = true; forceRebuildNeighborList = true;
bool rebuild = false;
do {
setPeriodicBoxArgs(context, kernels.findBlockBoundsKernel, 1); setPeriodicBoxArgs(context, kernels.findBlockBoundsKernel, 1);
context.executeKernel(kernels.findBlockBoundsKernel, context.getNumAtoms()); context.executeKernel(kernels.findBlockBoundsKernel, context.getNumAtoms());
blockSorter->sort(*sortedBlocks); blockSorter->sort(*sortedBlocks);
...@@ -349,6 +351,9 @@ void OpenCLNonbondedUtilities::prepareInteractions(int forceGroups) { ...@@ -349,6 +351,9 @@ void OpenCLNonbondedUtilities::prepareInteractions(int forceGroups) {
setPeriodicBoxArgs(context, kernels.findInteractingBlocksKernel, 0); setPeriodicBoxArgs(context, kernels.findInteractingBlocksKernel, 0);
context.executeKernel(kernels.findInteractingBlocksKernel, context.getNumAtoms(), interactingBlocksThreadBlockSize); context.executeKernel(kernels.findInteractingBlocksKernel, context.getNumAtoms(), interactingBlocksThreadBlockSize);
forceRebuildNeighborList = false; forceRebuildNeighborList = false;
if (context.getComputeForceCount() == 1)
rebuild = updateNeighborListSize(); // This is the first time step, so check whether our initial guess was large enough.
} while (rebuild);
lastCutoff = kernels.cutoffDistance; lastCutoff = kernels.cutoffDistance;
} }
...@@ -360,18 +365,16 @@ void OpenCLNonbondedUtilities::computeInteractions(int forceGroups) { ...@@ -360,18 +365,16 @@ void OpenCLNonbondedUtilities::computeInteractions(int forceGroups) {
if (useCutoff) if (useCutoff)
setPeriodicBoxArgs(context, kernels.forceKernel, 9); setPeriodicBoxArgs(context, kernels.forceKernel, 9);
context.executeKernel(kernels.forceKernel, numForceThreadBlocks*forceThreadBlockSize, forceThreadBlockSize); context.executeKernel(kernels.forceKernel, numForceThreadBlocks*forceThreadBlockSize, forceThreadBlockSize);
if (context.getComputeForceCount() == 1)
updateNeighborListSize(); // This is the first time step, so check whether our initial guess was large enough.
} }
} }
void OpenCLNonbondedUtilities::updateNeighborListSize() { bool OpenCLNonbondedUtilities::updateNeighborListSize() {
if (!useCutoff) if (!useCutoff)
return; return false;
unsigned int* pinnedInteractionCount = (unsigned int*) context.getPinnedBuffer(); unsigned int* pinnedInteractionCount = (unsigned int*) context.getPinnedBuffer();
interactionCount->download(pinnedInteractionCount); interactionCount->download(pinnedInteractionCount);
if (pinnedInteractionCount[0] <= (unsigned int) interactingTiles->getSize()) if (pinnedInteractionCount[0] <= (unsigned int) interactingTiles->getSize())
return; return false;
// The most recent timestep had too many interactions to fit in the arrays. Make the arrays bigger to prevent // The most recent timestep had too many interactions to fit in the arrays. Make the arrays bigger to prevent
// this from happening in the future. // this from happening in the future.
...@@ -395,6 +398,7 @@ void OpenCLNonbondedUtilities::updateNeighborListSize() { ...@@ -395,6 +398,7 @@ void OpenCLNonbondedUtilities::updateNeighborListSize() {
iter->second.findInteractingBlocksKernel.setArg<cl_uint>(9, maxTiles); iter->second.findInteractingBlocksKernel.setArg<cl_uint>(9, maxTiles);
} }
forceRebuildNeighborList = true; forceRebuildNeighborList = true;
return true;
} }
void OpenCLNonbondedUtilities::setUsePadding(bool padding) { void OpenCLNonbondedUtilities::setUsePadding(bool padding) {
......
...@@ -4,11 +4,18 @@ from simtk.openmm.app import * ...@@ -4,11 +4,18 @@ from simtk.openmm.app import *
from simtk.openmm import * from simtk.openmm import *
from simtk.unit import * from simtk.unit import *
import simtk.openmm.app.element as elem import simtk.openmm.app.element as elem
try:
from scipy.io import netcdf
SCIPY_IMPORT_FAILED = False
except:
SCIPY_IMPORT_FAILED = True
def compareByElement(array1, array2, cmp): def compareByElement(array1, array2, cmp):
for x, y in zip(array1, array2): for x, y in zip(array1, array2):
cmp(x, y) cmp(x, y)
class TestAmberInpcrdFile(unittest.TestCase): class TestAmberInpcrdFile(unittest.TestCase):
"""Test the Amber inpcrd file parser""" """Test the Amber inpcrd file parser"""
...@@ -24,14 +31,11 @@ class TestAmberInpcrdFile(unittest.TestCase): ...@@ -24,14 +31,11 @@ class TestAmberInpcrdFile(unittest.TestCase):
compareByElement(inpcrd.boxVectors[0].value_in_unit(angstroms), compareByElement(inpcrd.boxVectors[0].value_in_unit(angstroms),
[30.2642725, 0.0, 0.0], cmp) [30.2642725, 0.0, 0.0], cmp)
@unittest.skipIf(SCIPY_IMPORT_FAILED, "Scipy is not installed")
def test_NetCDF(self): def test_NetCDF(self):
""" Test NetCDF restart file parsing """ """ Test NetCDF restart file parsing """
cmp = self.assertAlmostEqual cmp = self.assertAlmostEqual
try:
from scipy.io import netcdf
except ImportError:
print('Not testing NetCDF file parser... scipy cannot be found')
else:
inpcrd = AmberInpcrdFile('systems/amber.ncrst') inpcrd = AmberInpcrdFile('systems/amber.ncrst')
self.assertEqual(len(inpcrd.positions), 2101) self.assertEqual(len(inpcrd.positions), 2101)
compareByElement(inpcrd.positions[0].value_in_unit(angstroms), compareByElement(inpcrd.positions[0].value_in_unit(angstroms),
......
import os import os
import unittest import unittest
import tempfile import tempfile
import numpy as np
from simtk.openmm import app from simtk.openmm import app
import simtk.openmm as mm import simtk.openmm as mm
from simtk import unit from simtk import unit
...@@ -24,17 +23,19 @@ class TestCheckpointReporter(unittest.TestCase): ...@@ -24,17 +23,19 @@ class TestCheckpointReporter(unittest.TestCase):
self.simulation.step(1) self.simulation.step(1)
# get the current positions # get the current positions
positions = self.simulation.context.getState(getPositions=True).getPositions(asNumpy=True)._value positions = self.simulation.context.getState(getPositions=True).getPositions()
# now set the positions into junk... # now set the positions into junk...
self.simulation.context.setPositions(np.random.random(positions.shape)) self.simulation.context.setPositions([mm.Vec3(0, 0, 0)] * len(positions))
# then reload the right positions from the checkpoint # then reload the right positions from the checkpoint
file.close() file.close()
with open(file.name, 'rb') as f: with open(file.name, 'rb') as f:
self.simulation.context.loadCheckpoint(f.read()) self.simulation.context.loadCheckpoint(f.read())
os.unlink(file.name) os.unlink(file.name)
newPositions = self.simulation.context.getState(getPositions=True).getPositions(asNumpy=True)._value newPositions = self.simulation.context.getState(getPositions=True).getPositions()
np.testing.assert_array_equal(positions, newPositions) self.assertSequenceEqual(positions, newPositions)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
import unittest import unittest
import numpy as np
from simtk.openmm import app from simtk.openmm import app
import simtk.openmm as mm import simtk.openmm as mm
from simtk import unit from simtk import unit
try:
import numpy as np
NUMPY_IMPORT_FAILED = False
except ImportError:
NUMPY_IMPORT_FAILED = True
@unittest.skipIf(NUMPY_IMPORT_FAILED, 'Numpy is not installed')
class TestNumpyCompatibility(unittest.TestCase): class TestNumpyCompatibility(unittest.TestCase):
def setUp(self): def setUp(self):
...@@ -80,6 +85,8 @@ class TestNumpyCompatibility(unittest.TestCase): ...@@ -80,6 +85,8 @@ class TestNumpyCompatibility(unittest.TestCase):
self.assertEqual(size, 10) self.assertEqual(size, 10)
np.testing.assert_array_almost_equal(energy, np.asarray(energy_out)) np.testing.assert_array_almost_equal(energy, np.asarray(energy_out))
@unittest.skipIf(NUMPY_IMPORT_FAILED, 'Numpy is not installed')
class TestNumpyUnits(unittest.TestCase): class TestNumpyUnits(unittest.TestCase):
def setUp(self): def setUp(self):
......
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