Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
3c8adf0c
Commit
3c8adf0c
authored
Oct 31, 2012
by
Peter Eastman
Browse files
OpenCL and CUDA tests are run three times, once for each precision model
parent
6f4ec6b6
Changes
80
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
112 additions
and
103 deletions
+112
-103
platforms/cuda/tests/CMakeLists.txt
platforms/cuda/tests/CMakeLists.txt
+7
-1
platforms/cuda/tests/TestCudaAndersenThermostat.cpp
platforms/cuda/tests/TestCudaAndersenThermostat.cpp
+5
-4
platforms/cuda/tests/TestCudaBrownianIntegrator.cpp
platforms/cuda/tests/TestCudaBrownianIntegrator.cpp
+5
-5
platforms/cuda/tests/TestCudaCMAPTorsionForce.cpp
platforms/cuda/tests/TestCudaCMAPTorsionForce.cpp
+5
-2
platforms/cuda/tests/TestCudaCMMotionRemover.cpp
platforms/cuda/tests/TestCudaCMMotionRemover.cpp
+5
-2
platforms/cuda/tests/TestCudaCheckpoints.cpp
platforms/cuda/tests/TestCudaCheckpoints.cpp
+5
-2
platforms/cuda/tests/TestCudaCustomAngleForce.cpp
platforms/cuda/tests/TestCudaCustomAngleForce.cpp
+5
-4
platforms/cuda/tests/TestCudaCustomBondForce.cpp
platforms/cuda/tests/TestCudaCustomBondForce.cpp
+5
-4
platforms/cuda/tests/TestCudaCustomCompoundBondForce.cpp
platforms/cuda/tests/TestCudaCustomCompoundBondForce.cpp
+5
-5
platforms/cuda/tests/TestCudaCustomExternalForce.cpp
platforms/cuda/tests/TestCudaCustomExternalForce.cpp
+5
-4
platforms/cuda/tests/TestCudaCustomGBForce.cpp
platforms/cuda/tests/TestCudaCustomGBForce.cpp
+5
-7
platforms/cuda/tests/TestCudaCustomHbondForce.cpp
platforms/cuda/tests/TestCudaCustomHbondForce.cpp
+5
-6
platforms/cuda/tests/TestCudaCustomIntegrator.cpp
platforms/cuda/tests/TestCudaCustomIntegrator.cpp
+5
-13
platforms/cuda/tests/TestCudaCustomNonbondedForce.cpp
platforms/cuda/tests/TestCudaCustomNonbondedForce.cpp
+5
-10
platforms/cuda/tests/TestCudaCustomTorsionForce.cpp
platforms/cuda/tests/TestCudaCustomTorsionForce.cpp
+5
-5
platforms/cuda/tests/TestCudaEwald.cpp
platforms/cuda/tests/TestCudaEwald.cpp
+13
-12
platforms/cuda/tests/TestCudaGBSAOBCForce.cpp
platforms/cuda/tests/TestCudaGBSAOBCForce.cpp
+7
-6
platforms/cuda/tests/TestCudaHarmonicAngleForce.cpp
platforms/cuda/tests/TestCudaHarmonicAngleForce.cpp
+5
-3
platforms/cuda/tests/TestCudaHarmonicBondForce.cpp
platforms/cuda/tests/TestCudaHarmonicBondForce.cpp
+5
-3
platforms/cuda/tests/TestCudaLangevinIntegrator.cpp
platforms/cuda/tests/TestCudaLangevinIntegrator.cpp
+5
-5
No files found.
platforms/cuda/tests/CMakeLists.txt
View file @
3c8adf0c
...
@@ -7,6 +7,8 @@ ENABLE_TESTING()
...
@@ -7,6 +7,8 @@ ENABLE_TESTING()
INCLUDE
(
FindCUDA
)
INCLUDE
(
FindCUDA
)
INCLUDE_DIRECTORIES
(
${
CUDA_TOOLKIT_INCLUDE
}
)
INCLUDE_DIRECTORIES
(
${
CUDA_TOOLKIT_INCLUDE
}
)
SET
(
OPENMM_BUILD_CUDA_DOUBLE_PRECISION_TESTS TRUE CACHE BOOL
"Whether to build double precision versions of CUDA test cases"
)
SET
(
INCLUDE_SERIALIZATION FALSE
)
SET
(
INCLUDE_SERIALIZATION FALSE
)
#SET( INCLUDE_SERIALIZATION TRUE )
#SET( INCLUDE_SERIALIZATION TRUE )
...
@@ -53,6 +55,10 @@ FOREACH(TEST_PROG ${TEST_PROGS})
...
@@ -53,6 +55,10 @@ FOREACH(TEST_PROG ${TEST_PROGS})
ENDIF
(
INCLUDE_SERIALIZATION
)
ENDIF
(
INCLUDE_SERIALIZATION
)
ENDIF
(
${
TEST_ROOT
}
STREQUAL
"TestCUDAGBSAOBCForce2"
)
ENDIF
(
${
TEST_ROOT
}
STREQUAL
"TestCUDAGBSAOBCForce2"
)
ADD_TEST
(
${
TEST_ROOT
}
${
EXECUTABLE_OUTPUT_PATH
}
/
${
TEST_ROOT
}
)
ADD_TEST
(
${
TEST_ROOT
}
Single
${
EXECUTABLE_OUTPUT_PATH
}
/
${
TEST_ROOT
}
single
)
IF
(
OPENMM_BUILD_CUDA_DOUBLE_PRECISION_TESTS
)
ADD_TEST
(
${
TEST_ROOT
}
Mixed
${
EXECUTABLE_OUTPUT_PATH
}
/
${
TEST_ROOT
}
mixed
)
ADD_TEST
(
${
TEST_ROOT
}
Double
${
EXECUTABLE_OUTPUT_PATH
}
/
${
TEST_ROOT
}
double
)
ENDIF
(
OPENMM_BUILD_CUDA_DOUBLE_PRECISION_TESTS
)
ENDFOREACH
(
TEST_PROG
${
TEST_PROGS
}
)
ENDFOREACH
(
TEST_PROG
${
TEST_PROGS
}
)
platforms/cuda/tests/TestCudaAndersenThermostat.cpp
View file @
3c8adf0c
...
@@ -48,12 +48,13 @@
...
@@ -48,12 +48,13 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
CudaPlatform
platform
;
void
testTemperature
()
{
void
testTemperature
()
{
const
int
numParticles
=
8
;
const
int
numParticles
=
8
;
const
double
temp
=
100.0
;
const
double
temp
=
100.0
;
const
double
collisionFreq
=
10.0
;
const
double
collisionFreq
=
10.0
;
const
int
numSteps
=
10000
;
const
int
numSteps
=
10000
;
CudaPlatform
platform
;
System
system
;
System
system
;
VerletIntegrator
integrator
(
0.005
);
VerletIntegrator
integrator
(
0.005
);
NonbondedForce
*
forceField
=
new
NonbondedForce
();
NonbondedForce
*
forceField
=
new
NonbondedForce
();
...
@@ -92,7 +93,6 @@ void testConstraints() {
...
@@ -92,7 +93,6 @@ void testConstraints() {
const
double
temp
=
100.0
;
const
double
temp
=
100.0
;
const
double
collisionFreq
=
10.0
;
const
double
collisionFreq
=
10.0
;
const
int
numSteps
=
10000
;
const
int
numSteps
=
10000
;
CudaPlatform
platform
;
System
system
;
System
system
;
VerletIntegrator
integrator
(
0.005
);
VerletIntegrator
integrator
(
0.005
);
NonbondedForce
*
forceField
=
new
NonbondedForce
();
NonbondedForce
*
forceField
=
new
NonbondedForce
();
...
@@ -144,7 +144,6 @@ void testRandomSeed() {
...
@@ -144,7 +144,6 @@ void testRandomSeed() {
const
int
numParticles
=
8
;
const
int
numParticles
=
8
;
const
double
temp
=
100.0
;
const
double
temp
=
100.0
;
const
double
collisionFreq
=
10.0
;
const
double
collisionFreq
=
10.0
;
CudaPlatform
platform
;
System
system
;
System
system
;
VerletIntegrator
integrator
(
0.01
);
VerletIntegrator
integrator
(
0.01
);
NonbondedForce
*
forceField
=
new
NonbondedForce
();
NonbondedForce
*
forceField
=
new
NonbondedForce
();
...
@@ -201,8 +200,10 @@ void testRandomSeed() {
...
@@ -201,8 +200,10 @@ void testRandomSeed() {
}
}
}
}
int
main
()
{
int
main
(
int
argc
,
char
*
argv
[]
)
{
try
{
try
{
if
(
argc
>
1
)
platform
.
setPropertyDefaultValue
(
"CudaPrecision"
,
string
(
argv
[
1
]));
testTemperature
();
testTemperature
();
testConstraints
();
testConstraints
();
testRandomSeed
();
testRandomSeed
();
...
...
platforms/cuda/tests/TestCudaBrownianIntegrator.cpp
View file @
3c8adf0c
...
@@ -53,8 +53,9 @@ using namespace std;
...
@@ -53,8 +53,9 @@ using namespace std;
const
double
TOL
=
1e-5
;
const
double
TOL
=
1e-5
;
CudaPlatform
platform
;
void
testSingleBond
()
{
void
testSingleBond
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
system
.
addParticle
(
2.0
);
system
.
addParticle
(
2.0
);
system
.
addParticle
(
2.0
);
system
.
addParticle
(
2.0
);
...
@@ -91,7 +92,6 @@ void testTemperature() {
...
@@ -91,7 +92,6 @@ void testTemperature() {
const
int
numParticles
=
8
;
const
int
numParticles
=
8
;
const
int
numBonds
=
numParticles
-
1
;
const
int
numBonds
=
numParticles
-
1
;
const
double
temp
=
10.0
;
const
double
temp
=
10.0
;
CudaPlatform
platform
;
System
system
;
System
system
;
BrownianIntegrator
integrator
(
temp
,
2.0
,
0.01
);
BrownianIntegrator
integrator
(
temp
,
2.0
,
0.01
);
HarmonicBondForce
*
forceField
=
new
HarmonicBondForce
();
HarmonicBondForce
*
forceField
=
new
HarmonicBondForce
();
...
@@ -128,7 +128,6 @@ void testConstraints() {
...
@@ -128,7 +128,6 @@ void testConstraints() {
const
int
numParticles
=
8
;
const
int
numParticles
=
8
;
const
int
numConstraints
=
5
;
const
int
numConstraints
=
5
;
const
double
temp
=
20.0
;
const
double
temp
=
20.0
;
CudaPlatform
platform
;
System
system
;
System
system
;
BrownianIntegrator
integrator
(
temp
,
2.0
,
0.001
);
BrownianIntegrator
integrator
(
temp
,
2.0
,
0.001
);
integrator
.
setConstraintTolerance
(
1e-5
);
integrator
.
setConstraintTolerance
(
1e-5
);
...
@@ -177,7 +176,6 @@ void testRandomSeed() {
...
@@ -177,7 +176,6 @@ void testRandomSeed() {
const
int
numParticles
=
8
;
const
int
numParticles
=
8
;
const
double
temp
=
100.0
;
const
double
temp
=
100.0
;
const
double
collisionFreq
=
10.0
;
const
double
collisionFreq
=
10.0
;
CudaPlatform
platform
;
System
system
;
System
system
;
BrownianIntegrator
integrator
(
temp
,
2.0
,
0.001
);
BrownianIntegrator
integrator
(
temp
,
2.0
,
0.001
);
NonbondedForce
*
forceField
=
new
NonbondedForce
();
NonbondedForce
*
forceField
=
new
NonbondedForce
();
...
@@ -232,8 +230,10 @@ void testRandomSeed() {
...
@@ -232,8 +230,10 @@ void testRandomSeed() {
}
}
}
}
int
main
()
{
int
main
(
int
argc
,
char
*
argv
[]
)
{
try
{
try
{
if
(
argc
>
1
)
platform
.
setPropertyDefaultValue
(
"CudaPrecision"
,
string
(
argv
[
1
]));
testSingleBond
();
testSingleBond
();
testTemperature
();
testTemperature
();
testConstraints
();
testConstraints
();
...
...
platforms/cuda/tests/TestCudaCMAPTorsionForce.cpp
View file @
3c8adf0c
...
@@ -50,13 +50,14 @@ using namespace std;
...
@@ -50,13 +50,14 @@ using namespace std;
const
double
TOL
=
1e-5
;
const
double
TOL
=
1e-5
;
CudaPlatform
platform
;
void
testCMAPTorsions
()
{
void
testCMAPTorsions
()
{
const
int
mapSize
=
36
;
const
int
mapSize
=
36
;
// Create two systems: one with a pair of periodic torsions, and one with a CMAP torsion
// Create two systems: one with a pair of periodic torsions, and one with a CMAP torsion
// that approximates the same force.
// that approximates the same force.
CudaPlatform
platform
;
System
system1
;
System
system1
;
for
(
int
i
=
0
;
i
<
5
;
i
++
)
for
(
int
i
=
0
;
i
<
5
;
i
++
)
system1
.
addParticle
(
1.0
);
system1
.
addParticle
(
1.0
);
...
@@ -104,8 +105,10 @@ void testCMAPTorsions() {
...
@@ -104,8 +105,10 @@ void testCMAPTorsions() {
}
}
}
}
int
main
()
{
int
main
(
int
argc
,
char
*
argv
[]
)
{
try
{
try
{
if
(
argc
>
1
)
platform
.
setPropertyDefaultValue
(
"CudaPrecision"
,
string
(
argv
[
1
]));
testCMAPTorsions
();
testCMAPTorsions
();
}
}
catch
(
const
exception
&
e
)
{
catch
(
const
exception
&
e
)
{
...
...
platforms/cuda/tests/TestCudaCMMotionRemover.cpp
View file @
3c8adf0c
...
@@ -50,6 +50,8 @@
...
@@ -50,6 +50,8 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
CudaPlatform
platform
;
Vec3
calcCM
(
const
vector
<
Vec3
>&
values
,
System
&
system
)
{
Vec3
calcCM
(
const
vector
<
Vec3
>&
values
,
System
&
system
)
{
Vec3
cm
;
Vec3
cm
;
for
(
int
j
=
0
;
j
<
system
.
getNumParticles
();
++
j
)
{
for
(
int
j
=
0
;
j
<
system
.
getNumParticles
();
++
j
)
{
...
@@ -62,7 +64,6 @@ Vec3 calcCM(const vector<Vec3>& values, System& system) {
...
@@ -62,7 +64,6 @@ Vec3 calcCM(const vector<Vec3>& values, System& system) {
void
testMotionRemoval
(
Integrator
&
integrator
)
{
void
testMotionRemoval
(
Integrator
&
integrator
)
{
const
int
numParticles
=
8
;
const
int
numParticles
=
8
;
CudaPlatform
platform
;
System
system
;
System
system
;
HarmonicBondForce
*
bonds
=
new
HarmonicBondForce
();
HarmonicBondForce
*
bonds
=
new
HarmonicBondForce
();
bonds
->
addBond
(
2
,
3
,
2.0
,
0.5
);
bonds
->
addBond
(
2
,
3
,
2.0
,
0.5
);
...
@@ -103,8 +104,10 @@ void testMotionRemoval(Integrator& integrator) {
...
@@ -103,8 +104,10 @@ void testMotionRemoval(Integrator& integrator) {
}
}
}
}
int
main
()
{
int
main
(
int
argc
,
char
*
argv
[]
)
{
try
{
try
{
if
(
argc
>
1
)
platform
.
setPropertyDefaultValue
(
"CudaPrecision"
,
string
(
argv
[
1
]));
LangevinIntegrator
langevin
(
0.0
,
1e-5
,
0.01
);
LangevinIntegrator
langevin
(
0.0
,
1e-5
,
0.01
);
testMotionRemoval
(
langevin
);
testMotionRemoval
(
langevin
);
VerletIntegrator
verlet
(
0.01
);
VerletIntegrator
verlet
(
0.01
);
...
...
platforms/cuda/tests/TestCudaCheckpoints.cpp
View file @
3c8adf0c
...
@@ -50,6 +50,8 @@ using namespace std;
...
@@ -50,6 +50,8 @@ using namespace std;
const
double
TOL
=
1e-5
;
const
double
TOL
=
1e-5
;
CudaPlatform
platform
;
void
compareStates
(
State
&
s1
,
State
&
s2
)
{
void
compareStates
(
State
&
s1
,
State
&
s2
)
{
ASSERT_EQUAL_TOL
(
s1
.
getTime
(),
s2
.
getTime
(),
TOL
);
ASSERT_EQUAL_TOL
(
s1
.
getTime
(),
s2
.
getTime
(),
TOL
);
int
numParticles
=
s1
.
getPositions
().
size
();
int
numParticles
=
s1
.
getPositions
().
size
();
...
@@ -71,7 +73,6 @@ void testCheckpoint() {
...
@@ -71,7 +73,6 @@ void testCheckpoint() {
const
int
numParticles
=
100
;
const
int
numParticles
=
100
;
const
double
boxSize
=
5.0
;
const
double
boxSize
=
5.0
;
const
double
temperature
=
200.0
;
const
double
temperature
=
200.0
;
CudaPlatform
platform
;
System
system
;
System
system
;
system
.
addForce
(
new
AndersenThermostat
(
0.0
,
100.0
));
system
.
addForce
(
new
AndersenThermostat
(
0.0
,
100.0
));
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
...
@@ -158,8 +159,10 @@ void testCheckpoint() {
...
@@ -158,8 +159,10 @@ void testCheckpoint() {
compareStates
(
s6
,
s8
);
compareStates
(
s6
,
s8
);
}
}
int
main
()
{
int
main
(
int
argc
,
char
*
argv
[]
)
{
try
{
try
{
if
(
argc
>
1
)
platform
.
setPropertyDefaultValue
(
"CudaPrecision"
,
string
(
argv
[
1
]));
testCheckpoint
();
testCheckpoint
();
}
}
catch
(
const
exception
&
e
)
{
catch
(
const
exception
&
e
)
{
...
...
platforms/cuda/tests/TestCudaCustomAngleForce.cpp
View file @
3c8adf0c
...
@@ -49,9 +49,9 @@ using namespace std;
...
@@ -49,9 +49,9 @@ using namespace std;
const
double
TOL
=
1e-5
;
const
double
TOL
=
1e-5
;
void
testAngles
()
{
CudaPlatform
platform
;
CudaPlatform
platform
;
void
testAngles
()
{
// Create a system using a CustomAngleForce.
// Create a system using a CustomAngleForce.
System
customSystem
;
System
customSystem
;
...
@@ -132,7 +132,6 @@ void testAngles() {
...
@@ -132,7 +132,6 @@ void testAngles() {
}
}
void
testParallelComputation
()
{
void
testParallelComputation
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
const
int
numParticles
=
200
;
const
int
numParticles
=
200
;
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
...
@@ -161,8 +160,10 @@ void testParallelComputation() {
...
@@ -161,8 +160,10 @@ void testParallelComputation() {
ASSERT_EQUAL_VEC
(
state1
.
getForces
()[
i
],
state2
.
getForces
()[
i
],
1e-5
);
ASSERT_EQUAL_VEC
(
state1
.
getForces
()[
i
],
state2
.
getForces
()[
i
],
1e-5
);
}
}
int
main
()
{
int
main
(
int
argc
,
char
*
argv
[]
)
{
try
{
try
{
if
(
argc
>
1
)
platform
.
setPropertyDefaultValue
(
"CudaPrecision"
,
string
(
argv
[
1
]));
testAngles
();
testAngles
();
testParallelComputation
();
testParallelComputation
();
}
}
...
...
platforms/cuda/tests/TestCudaCustomBondForce.cpp
View file @
3c8adf0c
...
@@ -48,8 +48,9 @@ using namespace std;
...
@@ -48,8 +48,9 @@ using namespace std;
const
double
TOL
=
1e-5
;
const
double
TOL
=
1e-5
;
CudaPlatform
platform
;
void
testBonds
()
{
void
testBonds
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
...
@@ -102,7 +103,6 @@ void testBonds() {
...
@@ -102,7 +103,6 @@ void testBonds() {
}
}
void
testManyParameters
()
{
void
testManyParameters
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
...
@@ -136,7 +136,6 @@ void testManyParameters() {
...
@@ -136,7 +136,6 @@ void testManyParameters() {
}
}
void
testParallelComputation
()
{
void
testParallelComputation
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
const
int
numParticles
=
200
;
const
int
numParticles
=
200
;
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
...
@@ -165,8 +164,10 @@ void testParallelComputation() {
...
@@ -165,8 +164,10 @@ void testParallelComputation() {
ASSERT_EQUAL_VEC
(
state1
.
getForces
()[
i
],
state2
.
getForces
()[
i
],
1e-5
);
ASSERT_EQUAL_VEC
(
state1
.
getForces
()[
i
],
state2
.
getForces
()[
i
],
1e-5
);
}
}
int
main
()
{
int
main
(
int
argc
,
char
*
argv
[]
)
{
try
{
try
{
if
(
argc
>
1
)
platform
.
setPropertyDefaultValue
(
"CudaPrecision"
,
string
(
argv
[
1
]));
testBonds
();
testBonds
();
testManyParameters
();
testManyParameters
();
testParallelComputation
();
testParallelComputation
();
...
...
platforms/cuda/tests/TestCudaCustomCompoundBondForce.cpp
View file @
3c8adf0c
...
@@ -51,9 +51,9 @@ using namespace std;
...
@@ -51,9 +51,9 @@ using namespace std;
const
double
TOL
=
1e-5
;
const
double
TOL
=
1e-5
;
void
testBond
()
{
CudaPlatform
platform
;
CudaPlatform
platform
;
void
testBond
()
{
// Create a system using a CustomCompoundBondForce.
// Create a system using a CustomCompoundBondForce.
System
customSystem
;
System
customSystem
;
...
@@ -142,7 +142,6 @@ void testBond() {
...
@@ -142,7 +142,6 @@ void testBond() {
}
}
void
testPositionDependence
()
{
void
testPositionDependence
()
{
CudaPlatform
platform
;
System
customSystem
;
System
customSystem
;
customSystem
.
addParticle
(
1.0
);
customSystem
.
addParticle
(
1.0
);
customSystem
.
addParticle
(
1.0
);
customSystem
.
addParticle
(
1.0
);
...
@@ -168,7 +167,6 @@ void testPositionDependence() {
...
@@ -168,7 +167,6 @@ void testPositionDependence() {
}
}
void
testParallelComputation
()
{
void
testParallelComputation
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
const
int
numParticles
=
200
;
const
int
numParticles
=
200
;
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
...
@@ -201,8 +199,10 @@ void testParallelComputation() {
...
@@ -201,8 +199,10 @@ void testParallelComputation() {
ASSERT_EQUAL_VEC
(
state1
.
getForces
()[
i
],
state2
.
getForces
()[
i
],
1e-5
);
ASSERT_EQUAL_VEC
(
state1
.
getForces
()[
i
],
state2
.
getForces
()[
i
],
1e-5
);
}
}
int
main
()
{
int
main
(
int
argc
,
char
*
argv
[]
)
{
try
{
try
{
if
(
argc
>
1
)
platform
.
setPropertyDefaultValue
(
"CudaPrecision"
,
string
(
argv
[
1
]));
testBond
();
testBond
();
testPositionDependence
();
testPositionDependence
();
testParallelComputation
();
testParallelComputation
();
...
...
platforms/cuda/tests/TestCudaCustomExternalForce.cpp
View file @
3c8adf0c
...
@@ -49,8 +49,9 @@ using namespace std;
...
@@ -49,8 +49,9 @@ using namespace std;
const
double
TOL
=
1e-5
;
const
double
TOL
=
1e-5
;
CudaPlatform
platform
;
void
testForce
()
{
void
testForce
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
...
@@ -100,7 +101,6 @@ void testForce() {
...
@@ -100,7 +101,6 @@ void testForce() {
}
}
void
testManyParameters
()
{
void
testManyParameters
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
VerletIntegrator
integrator
(
0.01
);
VerletIntegrator
integrator
(
0.01
);
...
@@ -131,7 +131,6 @@ void testManyParameters() {
...
@@ -131,7 +131,6 @@ void testManyParameters() {
}
}
void
testParallelComputation
()
{
void
testParallelComputation
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
const
int
numParticles
=
200
;
const
int
numParticles
=
200
;
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
...
@@ -162,8 +161,10 @@ void testParallelComputation() {
...
@@ -162,8 +161,10 @@ void testParallelComputation() {
ASSERT_EQUAL_VEC
(
state1
.
getForces
()[
i
],
state2
.
getForces
()[
i
],
1e-5
);
ASSERT_EQUAL_VEC
(
state1
.
getForces
()[
i
],
state2
.
getForces
()[
i
],
1e-5
);
}
}
int
main
()
{
int
main
(
int
argc
,
char
*
argv
[]
)
{
try
{
try
{
if
(
argc
>
1
)
platform
.
setPropertyDefaultValue
(
"CudaPrecision"
,
string
(
argv
[
1
]));
testForce
();
testForce
();
testManyParameters
();
testManyParameters
();
testParallelComputation
();
testParallelComputation
();
...
...
platforms/cuda/tests/TestCudaCustomGBForce.cpp
View file @
3c8adf0c
...
@@ -50,11 +50,12 @@ using namespace std;
...
@@ -50,11 +50,12 @@ using namespace std;
const
double
TOL
=
1e-5
;
const
double
TOL
=
1e-5
;
CudaPlatform
platform
;
void
testOBC
(
GBSAOBCForce
::
NonbondedMethod
obcMethod
,
CustomGBForce
::
NonbondedMethod
customMethod
)
{
void
testOBC
(
GBSAOBCForce
::
NonbondedMethod
obcMethod
,
CustomGBForce
::
NonbondedMethod
customMethod
)
{
const
int
numMolecules
=
70
;
const
int
numMolecules
=
70
;
const
int
numParticles
=
numMolecules
*
2
;
const
int
numParticles
=
numMolecules
*
2
;
const
double
boxSize
=
10.0
;
const
double
boxSize
=
10.0
;
CudaPlatform
platform
;
// Create two systems: one with a GBSAOBCForce, and one using a CustomGBForce to implement the same interaction.
// Create two systems: one with a GBSAOBCForce, and one using a CustomGBForce to implement the same interaction.
...
@@ -168,7 +169,6 @@ void testMembrane() {
...
@@ -168,7 +169,6 @@ void testMembrane() {
const
int
numMolecules
=
70
;
const
int
numMolecules
=
70
;
const
int
numParticles
=
numMolecules
*
2
;
const
int
numParticles
=
numMolecules
*
2
;
const
double
boxSize
=
10.0
;
const
double
boxSize
=
10.0
;
CudaPlatform
platform
;
// Create a system with an implicit membrane.
// Create a system with an implicit membrane.
...
@@ -254,7 +254,6 @@ void testMembrane() {
...
@@ -254,7 +254,6 @@ void testMembrane() {
}
}
void
testTabulatedFunction
()
{
void
testTabulatedFunction
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
...
@@ -295,7 +294,6 @@ void testTabulatedFunction() {
...
@@ -295,7 +294,6 @@ void testTabulatedFunction() {
}
}
void
testMultipleChainRules
()
{
void
testMultipleChainRules
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
...
@@ -323,7 +321,6 @@ void testMultipleChainRules() {
...
@@ -323,7 +321,6 @@ void testMultipleChainRules() {
}
}
void
testPositionDependence
()
{
void
testPositionDependence
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
...
@@ -383,7 +380,6 @@ void testPositionDependence() {
...
@@ -383,7 +380,6 @@ void testPositionDependence() {
}
}
void
testExclusions
()
{
void
testExclusions
()
{
CudaPlatform
platform
;
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
System
system
;
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
...
@@ -449,8 +445,10 @@ void testExclusions() {
...
@@ -449,8 +445,10 @@ void testExclusions() {
}
}
}
}
int
main
()
{
int
main
(
int
argc
,
char
*
argv
[]
)
{
try
{
try
{
if
(
argc
>
1
)
platform
.
setPropertyDefaultValue
(
"CudaPrecision"
,
string
(
argv
[
1
]));
testOBC
(
GBSAOBCForce
::
NoCutoff
,
CustomGBForce
::
NoCutoff
);
testOBC
(
GBSAOBCForce
::
NoCutoff
,
CustomGBForce
::
NoCutoff
);
testOBC
(
GBSAOBCForce
::
CutoffNonPeriodic
,
CustomGBForce
::
CutoffNonPeriodic
);
testOBC
(
GBSAOBCForce
::
CutoffNonPeriodic
,
CustomGBForce
::
CutoffNonPeriodic
);
testOBC
(
GBSAOBCForce
::
CutoffPeriodic
,
CustomGBForce
::
CutoffPeriodic
);
testOBC
(
GBSAOBCForce
::
CutoffPeriodic
,
CustomGBForce
::
CutoffPeriodic
);
...
...
platforms/cuda/tests/TestCudaCustomHbondForce.cpp
View file @
3c8adf0c
...
@@ -51,9 +51,9 @@ using namespace std;
...
@@ -51,9 +51,9 @@ using namespace std;
const
double
TOL
=
1e-5
;
const
double
TOL
=
1e-5
;
void
testHbond
()
{
CudaPlatform
platform
;
CudaPlatform
platform
;
void
testHbond
()
{
// Create a system using a CustomHbondForce.
// Create a system using a CustomHbondForce.
System
customSystem
;
System
customSystem
;
...
@@ -149,7 +149,6 @@ void testHbond() {
...
@@ -149,7 +149,6 @@ void testHbond() {
}
}
void
testExclusions
()
{
void
testExclusions
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
...
@@ -176,7 +175,6 @@ void testExclusions() {
...
@@ -176,7 +175,6 @@ void testExclusions() {
}
}
void
testCutoff
()
{
void
testCutoff
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
...
@@ -204,7 +202,6 @@ void testCutoff() {
...
@@ -204,7 +202,6 @@ void testCutoff() {
}
}
void
testCustomFunctions
()
{
void
testCustomFunctions
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
...
@@ -233,8 +230,10 @@ void testCustomFunctions() {
...
@@ -233,8 +230,10 @@ void testCustomFunctions() {
ASSERT_EQUAL_TOL
(
0.1
*
2
+
0.1
*
2
,
state
.
getPotentialEnergy
(),
TOL
);
ASSERT_EQUAL_TOL
(
0.1
*
2
+
0.1
*
2
,
state
.
getPotentialEnergy
(),
TOL
);
}
}
int
main
()
{
int
main
(
int
argc
,
char
*
argv
[]
)
{
try
{
try
{
if
(
argc
>
1
)
platform
.
setPropertyDefaultValue
(
"CudaPrecision"
,
string
(
argv
[
1
]));
testHbond
();
testHbond
();
testExclusions
();
testExclusions
();
testCutoff
();
testCutoff
();
...
...
platforms/cuda/tests/TestCudaCustomIntegrator.cpp
View file @
3c8adf0c
...
@@ -49,13 +49,14 @@
...
@@ -49,13 +49,14 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
CudaPlatform
platform
;
const
double
TOL
=
1e-5
;
const
double
TOL
=
1e-5
;
/**
/**
* Test a simple leapfrog integrator on a single bond.
* Test a simple leapfrog integrator on a single bond.
*/
*/
void
testSingleBond
()
{
void
testSingleBond
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
system
.
addParticle
(
2.0
);
system
.
addParticle
(
2.0
);
system
.
addParticle
(
2.0
);
system
.
addParticle
(
2.0
);
...
@@ -100,8 +101,6 @@ void testSingleBond() {
...
@@ -100,8 +101,6 @@ void testSingleBond() {
*/
*/
void
testConstraints
()
{
void
testConstraints
()
{
const
int
numParticles
=
8
;
const
int
numParticles
=
8
;
const
double
temp
=
500.0
;
CudaPlatform
platform
;
System
system
;
System
system
;
CustomIntegrator
integrator
(
0.002
);
CustomIntegrator
integrator
(
0.002
);
integrator
.
addPerDofVariable
(
"oldx"
,
0
);
integrator
.
addPerDofVariable
(
"oldx"
,
0
);
...
@@ -160,7 +159,6 @@ void testConstraints() {
...
@@ -160,7 +159,6 @@ void testConstraints() {
*/
*/
void
testVelocityConstraints
()
{
void
testVelocityConstraints
()
{
const
int
numParticles
=
10
;
const
int
numParticles
=
10
;
CudaPlatform
platform
;
System
system
;
System
system
;
CustomIntegrator
integrator
(
0.002
);
CustomIntegrator
integrator
(
0.002
);
integrator
.
addPerDofVariable
(
"x1"
,
0
);
integrator
.
addPerDofVariable
(
"x1"
,
0
);
...
@@ -244,7 +242,6 @@ void testWithThermostat() {
...
@@ -244,7 +242,6 @@ void testWithThermostat() {
const
double
temp
=
100.0
;
const
double
temp
=
100.0
;
const
double
collisionFreq
=
10.0
;
const
double
collisionFreq
=
10.0
;
const
int
numSteps
=
10000
;
const
int
numSteps
=
10000
;
CudaPlatform
platform
;
System
system
;
System
system
;
CustomIntegrator
integrator
(
0.005
);
CustomIntegrator
integrator
(
0.005
);
integrator
.
addUpdateContextState
();
integrator
.
addUpdateContextState
();
...
@@ -285,7 +282,6 @@ void testWithThermostat() {
...
@@ -285,7 +282,6 @@ void testWithThermostat() {
* Test a Monte Carlo integrator that uses global variables and depends on energy.
* Test a Monte Carlo integrator that uses global variables and depends on energy.
*/
*/
void
testMonteCarlo
()
{
void
testMonteCarlo
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
...
@@ -340,7 +336,6 @@ void testMonteCarlo() {
...
@@ -340,7 +336,6 @@ void testMonteCarlo() {
void
testSum
()
{
void
testSum
()
{
const
int
numParticles
=
200
;
const
int
numParticles
=
200
;
const
double
boxSize
=
10
;
const
double
boxSize
=
10
;
CudaPlatform
platform
;
System
system
;
System
system
;
system
.
setDefaultPeriodicBoxVectors
(
Vec3
(
boxSize
,
0
,
0
),
Vec3
(
0
,
boxSize
,
0
),
Vec3
(
0
,
0
,
boxSize
));
system
.
setDefaultPeriodicBoxVectors
(
Vec3
(
boxSize
,
0
,
0
),
Vec3
(
0
,
boxSize
,
0
),
Vec3
(
0
,
0
,
boxSize
));
NonbondedForce
*
nb
=
new
NonbondedForce
();
NonbondedForce
*
nb
=
new
NonbondedForce
();
...
@@ -385,7 +380,6 @@ void testSum() {
...
@@ -385,7 +380,6 @@ void testSum() {
* Test an integrator that both uses and modifies a context parameter.
* Test an integrator that both uses and modifies a context parameter.
*/
*/
void
testParameter
()
{
void
testParameter
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
AndersenThermostat
*
thermostat
=
new
AndersenThermostat
(
0.1
,
0.1
);
AndersenThermostat
*
thermostat
=
new
AndersenThermostat
(
0.1
,
0.1
);
...
@@ -411,7 +405,6 @@ void testRandomDistributions() {
...
@@ -411,7 +405,6 @@ void testRandomDistributions() {
const
int
numParticles
=
100
;
const
int
numParticles
=
100
;
const
int
numBins
=
20
;
const
int
numBins
=
20
;
const
int
numSteps
=
100
;
const
int
numSteps
=
100
;
CudaPlatform
platform
;
System
system
;
System
system
;
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
...
@@ -479,7 +472,6 @@ void testRandomDistributions() {
...
@@ -479,7 +472,6 @@ void testRandomDistributions() {
void
testPerDofVariables
()
{
void
testPerDofVariables
()
{
const
int
numParticles
=
200
;
const
int
numParticles
=
200
;
const
double
boxSize
=
10
;
const
double
boxSize
=
10
;
CudaPlatform
platform
;
System
system
;
System
system
;
system
.
setDefaultPeriodicBoxVectors
(
Vec3
(
boxSize
,
0
,
0
),
Vec3
(
0
,
boxSize
,
0
),
Vec3
(
0
,
0
,
boxSize
));
system
.
setDefaultPeriodicBoxVectors
(
Vec3
(
boxSize
,
0
,
0
),
Vec3
(
0
,
boxSize
,
0
),
Vec3
(
0
,
0
,
boxSize
));
NonbondedForce
*
nb
=
new
NonbondedForce
();
NonbondedForce
*
nb
=
new
NonbondedForce
();
...
@@ -535,7 +527,6 @@ void testPerDofVariables() {
...
@@ -535,7 +527,6 @@ void testPerDofVariables() {
* Test evaluating force groups separately.
* Test evaluating force groups separately.
*/
*/
void
testForceGroups
()
{
void
testForceGroups
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
system
.
addParticle
(
2.0
);
system
.
addParticle
(
2.0
);
system
.
addParticle
(
2.0
);
system
.
addParticle
(
2.0
);
...
@@ -611,7 +602,6 @@ void testForceGroups() {
...
@@ -611,7 +602,6 @@ void testForceGroups() {
*/
*/
void
testRespa
()
{
void
testRespa
()
{
const
int
numParticles
=
8
;
const
int
numParticles
=
8
;
CudaPlatform
platform
;
System
system
;
System
system
;
system
.
setDefaultPeriodicBoxVectors
(
Vec3
(
4
,
0
,
0
),
Vec3
(
0
,
4
,
0
),
Vec3
(
0
,
0
,
4
));
system
.
setDefaultPeriodicBoxVectors
(
Vec3
(
4
,
0
,
0
),
Vec3
(
0
,
4
,
0
),
Vec3
(
0
,
0
,
4
));
CustomIntegrator
integrator
(
0.002
);
CustomIntegrator
integrator
(
0.002
);
...
@@ -662,8 +652,10 @@ void testRespa() {
...
@@ -662,8 +652,10 @@ void testRespa() {
}
}
}
}
int
main
()
{
int
main
(
int
argc
,
char
*
argv
[]
)
{
try
{
try
{
if
(
argc
>
1
)
platform
.
setPropertyDefaultValue
(
"CudaPrecision"
,
string
(
argv
[
1
]));
testSingleBond
();
testSingleBond
();
testConstraints
();
testConstraints
();
testVelocityConstraints
();
testVelocityConstraints
();
...
...
platforms/cuda/tests/TestCudaCustomNonbondedForce.cpp
View file @
3c8adf0c
...
@@ -48,10 +48,11 @@
...
@@ -48,10 +48,11 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
CudaPlatform
platform
;
const
double
TOL
=
1e-5
;
const
double
TOL
=
1e-5
;
void
testSimpleExpression
()
{
void
testSimpleExpression
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
...
@@ -74,7 +75,6 @@ void testSimpleExpression() {
...
@@ -74,7 +75,6 @@ void testSimpleExpression() {
}
}
void
testParameters
()
{
void
testParameters
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
...
@@ -135,7 +135,6 @@ void testParameters() {
...
@@ -135,7 +135,6 @@ void testParameters() {
}
}
void
testManyParameters
()
{
void
testManyParameters
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
...
@@ -174,7 +173,6 @@ void testManyParameters() {
...
@@ -174,7 +173,6 @@ void testManyParameters() {
}
}
void
testExclusions
()
{
void
testExclusions
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
VerletIntegrator
integrator
(
0.01
);
VerletIntegrator
integrator
(
0.01
);
CustomNonbondedForce
*
nonbonded
=
new
CustomNonbondedForce
(
"a*r; a=a1+a2"
);
CustomNonbondedForce
*
nonbonded
=
new
CustomNonbondedForce
(
"a*r; a=a1+a2"
);
...
@@ -205,7 +203,6 @@ void testExclusions() {
...
@@ -205,7 +203,6 @@ void testExclusions() {
}
}
void
testCutoff
()
{
void
testCutoff
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
...
@@ -233,7 +230,6 @@ void testCutoff() {
...
@@ -233,7 +230,6 @@ void testCutoff() {
}
}
void
testPeriodic
()
{
void
testPeriodic
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
...
@@ -262,7 +258,6 @@ void testPeriodic() {
...
@@ -262,7 +258,6 @@ void testPeriodic() {
}
}
void
testTabulatedFunction
()
{
void
testTabulatedFunction
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
...
@@ -305,7 +300,6 @@ void testCoulombLennardJones() {
...
@@ -305,7 +300,6 @@ void testCoulombLennardJones() {
const
int
numMolecules
=
300
;
const
int
numMolecules
=
300
;
const
int
numParticles
=
numMolecules
*
2
;
const
int
numParticles
=
numMolecules
*
2
;
const
double
boxSize
=
20.0
;
const
double
boxSize
=
20.0
;
CudaPlatform
platform
;
// Create two systems: one with a NonbondedForce, and one using a CustomNonbondedForce to implement the same interaction.
// Create two systems: one with a NonbondedForce, and one using a CustomNonbondedForce to implement the same interaction.
...
@@ -377,7 +371,6 @@ void testCoulombLennardJones() {
...
@@ -377,7 +371,6 @@ void testCoulombLennardJones() {
}
}
void
testParallelComputation
()
{
void
testParallelComputation
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
const
int
numParticles
=
200
;
const
int
numParticles
=
200
;
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
...
@@ -414,8 +407,10 @@ void testParallelComputation() {
...
@@ -414,8 +407,10 @@ void testParallelComputation() {
ASSERT_EQUAL_VEC
(
state1
.
getForces
()[
i
],
state2
.
getForces
()[
i
],
1e-5
);
ASSERT_EQUAL_VEC
(
state1
.
getForces
()[
i
],
state2
.
getForces
()[
i
],
1e-5
);
}
}
int
main
()
{
int
main
(
int
argc
,
char
*
argv
[]
)
{
try
{
try
{
if
(
argc
>
1
)
platform
.
setPropertyDefaultValue
(
"CudaPrecision"
,
string
(
argv
[
1
]));
testSimpleExpression
();
testSimpleExpression
();
testParameters
();
testParameters
();
testManyParameters
();
testManyParameters
();
...
...
platforms/cuda/tests/TestCudaCustomTorsionForce.cpp
View file @
3c8adf0c
...
@@ -50,11 +50,11 @@
...
@@ -50,11 +50,11 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
CudaPlatform
platform
;
const
double
TOL
=
1e-5
;
const
double
TOL
=
1e-5
;
void
testTorsions
()
{
void
testTorsions
()
{
CudaPlatform
platform
;
// Create a system using a CustomTorsionForce.
// Create a system using a CustomTorsionForce.
System
customSystem
;
System
customSystem
;
...
@@ -138,7 +138,6 @@ void testTorsions() {
...
@@ -138,7 +138,6 @@ void testTorsions() {
}
}
void
testRange
()
{
void
testRange
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
...
@@ -172,7 +171,6 @@ void testRange() {
...
@@ -172,7 +171,6 @@ void testRange() {
}
}
void
testParallelComputation
()
{
void
testParallelComputation
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
const
int
numParticles
=
200
;
const
int
numParticles
=
200
;
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
...
@@ -201,8 +199,10 @@ void testParallelComputation() {
...
@@ -201,8 +199,10 @@ void testParallelComputation() {
ASSERT_EQUAL_VEC
(
state1
.
getForces
()[
i
],
state2
.
getForces
()[
i
],
1e-5
);
ASSERT_EQUAL_VEC
(
state1
.
getForces
()[
i
],
state2
.
getForces
()[
i
],
1e-5
);
}
}
int
main
()
{
int
main
(
int
argc
,
char
*
argv
[]
)
{
try
{
try
{
if
(
argc
>
1
)
platform
.
setPropertyDefaultValue
(
"CudaPrecision"
,
string
(
argv
[
1
]));
testTorsions
();
testTorsions
();
testRange
();
testRange
();
testParallelComputation
();
testParallelComputation
();
...
...
platforms/cuda/tests/TestCudaEwald.cpp
View file @
3c8adf0c
...
@@ -50,6 +50,8 @@
...
@@ -50,6 +50,8 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
CudaPlatform
platform
;
const
double
TOL
=
1e-5
;
const
double
TOL
=
1e-5
;
void
testEwaldPME
(
bool
includeExceptions
)
{
void
testEwaldPME
(
bool
includeExceptions
)
{
...
@@ -61,7 +63,6 @@ void testEwaldPME(bool includeExceptions) {
...
@@ -61,7 +63,6 @@ void testEwaldPME(bool includeExceptions) {
const
double
boxSize
=
3.00646
;
const
double
boxSize
=
3.00646
;
double
tol
=
1e-5
;
double
tol
=
1e-5
;
CudaPlatform
cu
;
ReferencePlatform
reference
;
ReferencePlatform
reference
;
System
system
;
System
system
;
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
...
@@ -96,7 +97,7 @@ void testEwaldPME(bool includeExceptions) {
...
@@ -96,7 +97,7 @@ void testEwaldPME(bool includeExceptions) {
VerletIntegrator
integrator1
(
0.01
);
VerletIntegrator
integrator1
(
0.01
);
VerletIntegrator
integrator2
(
0.01
);
VerletIntegrator
integrator2
(
0.01
);
Context
cuContext
(
system
,
integrator1
,
cu
);
Context
cuContext
(
system
,
integrator1
,
platform
);
Context
referenceContext
(
system
,
integrator2
,
reference
);
Context
referenceContext
(
system
,
integrator2
,
reference
);
cuContext
.
setPositions
(
positions
);
cuContext
.
setPositions
(
positions
);
referenceContext
.
setPositions
(
positions
);
referenceContext
.
setPositions
(
positions
);
...
@@ -126,7 +127,7 @@ void testEwaldPME(bool includeExceptions) {
...
@@ -126,7 +127,7 @@ void testEwaldPME(bool includeExceptions) {
positions
[
i
]
=
Vec3
(
p
[
0
]
-
f
[
0
]
*
step
,
p
[
1
]
-
f
[
1
]
*
step
,
p
[
2
]
-
f
[
2
]
*
step
);
positions
[
i
]
=
Vec3
(
p
[
0
]
-
f
[
0
]
*
step
,
p
[
1
]
-
f
[
1
]
*
step
,
p
[
2
]
-
f
[
2
]
*
step
);
}
}
VerletIntegrator
integrator3
(
0.01
);
VerletIntegrator
integrator3
(
0.01
);
Context
cuContext2
(
system
,
integrator3
,
cu
);
Context
cuContext2
(
system
,
integrator3
,
platform
);
cuContext2
.
setPositions
(
positions
);
cuContext2
.
setPositions
(
positions
);
tol
=
1e-2
;
tol
=
1e-2
;
...
@@ -165,7 +166,7 @@ void testEwaldPME(bool includeExceptions) {
...
@@ -165,7 +166,7 @@ void testEwaldPME(bool includeExceptions) {
positions
[
i
]
=
Vec3
(
p
[
0
]
-
f
[
0
]
*
step
,
p
[
1
]
-
f
[
1
]
*
step
,
p
[
2
]
-
f
[
2
]
*
step
);
positions
[
i
]
=
Vec3
(
p
[
0
]
-
f
[
0
]
*
step
,
p
[
1
]
-
f
[
1
]
*
step
,
p
[
2
]
-
f
[
2
]
*
step
);
}
}
VerletIntegrator
integrator4
(
0.01
);
VerletIntegrator
integrator4
(
0.01
);
Context
cuContext3
(
system
,
integrator4
,
cu
);
Context
cuContext3
(
system
,
integrator4
,
platform
);
cuContext3
.
setPositions
(
positions
);
cuContext3
.
setPositions
(
positions
);
tol
=
1e-2
;
tol
=
1e-2
;
...
@@ -174,7 +175,6 @@ void testEwaldPME(bool includeExceptions) {
...
@@ -174,7 +175,6 @@ void testEwaldPME(bool includeExceptions) {
}
}
void
testEwald2Ions
()
{
void
testEwald2Ions
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
...
@@ -220,7 +220,6 @@ void testErrorTolerance(NonbondedForce::NonbondedMethod method) {
...
@@ -220,7 +220,6 @@ void testErrorTolerance(NonbondedForce::NonbondedMethod method) {
positions
[
i
]
=
Vec3
(
boxWidth
*
genrand_real2
(
sfmt
),
boxWidth
*
genrand_real2
(
sfmt
),
boxWidth
*
genrand_real2
(
sfmt
));
positions
[
i
]
=
Vec3
(
boxWidth
*
genrand_real2
(
sfmt
),
boxWidth
*
genrand_real2
(
sfmt
),
boxWidth
*
genrand_real2
(
sfmt
));
}
}
force
->
setNonbondedMethod
(
method
);
force
->
setNonbondedMethod
(
method
);
CudaPlatform
platform
;
// For various values of the cutoff and error tolerance, see if the actual error is reasonable.
// For various values of the cutoff and error tolerance, see if the actual error is reasonable.
...
@@ -253,13 +252,15 @@ void testErrorTolerance(NonbondedForce::NonbondedMethod method) {
...
@@ -253,13 +252,15 @@ void testErrorTolerance(NonbondedForce::NonbondedMethod method) {
}
}
}
}
int
main
()
{
int
main
(
int
argc
,
char
*
argv
[]
)
{
try
{
try
{
testEwaldPME
(
false
);
if
(
argc
>
1
)
testEwaldPME
(
true
);
platform
.
setPropertyDefaultValue
(
"CudaPrecision"
,
string
(
argv
[
1
]));
// testEwald2Ions();
testEwaldPME
(
false
);
testErrorTolerance
(
NonbondedForce
::
Ewald
);
testEwaldPME
(
true
);
testErrorTolerance
(
NonbondedForce
::
PME
);
// testEwald2Ions();
testErrorTolerance
(
NonbondedForce
::
Ewald
);
testErrorTolerance
(
NonbondedForce
::
PME
);
}
}
catch
(
const
exception
&
e
)
{
catch
(
const
exception
&
e
)
{
cout
<<
"exception: "
<<
e
.
what
()
<<
endl
;
cout
<<
"exception: "
<<
e
.
what
()
<<
endl
;
...
...
platforms/cuda/tests/TestCudaGBSAOBCForce.cpp
View file @
3c8adf0c
...
@@ -49,10 +49,11 @@
...
@@ -49,10 +49,11 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
CudaPlatform
platform
;
const
double
TOL
=
1e-5
;
const
double
TOL
=
1e-5
;
void
testSingleParticle
()
{
void
testSingleParticle
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
system
.
addParticle
(
2.0
);
system
.
addParticle
(
2.0
);
LangevinIntegrator
integrator
(
0
,
0.1
,
0.01
);
LangevinIntegrator
integrator
(
0
,
0.1
,
0.01
);
...
@@ -87,7 +88,6 @@ void testSingleParticle() {
...
@@ -87,7 +88,6 @@ void testSingleParticle() {
}
}
void
testCutoffAndPeriodic
()
{
void
testCutoffAndPeriodic
()
{
CudaPlatform
cl
;
System
system
;
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
...
@@ -113,7 +113,7 @@ void testCutoffAndPeriodic() {
...
@@ -113,7 +113,7 @@ void testCutoffAndPeriodic() {
nonbonded
->
setNonbondedMethod
(
NonbondedForce
::
CutoffNonPeriodic
);
nonbonded
->
setNonbondedMethod
(
NonbondedForce
::
CutoffNonPeriodic
);
gbsa
->
setNonbondedMethod
(
GBSAOBCForce
::
CutoffNonPeriodic
);
gbsa
->
setNonbondedMethod
(
GBSAOBCForce
::
CutoffNonPeriodic
);
Context
context
(
system
,
integrator
,
cl
);
Context
context
(
system
,
integrator
,
platform
);
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
State
state1
=
context
.
getState
(
State
::
Forces
);
State
state1
=
context
.
getState
(
State
::
Forces
);
nonbonded
->
setNonbondedMethod
(
NonbondedForce
::
CutoffPeriodic
);
nonbonded
->
setNonbondedMethod
(
NonbondedForce
::
CutoffPeriodic
);
...
@@ -144,7 +144,6 @@ void testCutoffAndPeriodic() {
...
@@ -144,7 +144,6 @@ void testCutoffAndPeriodic() {
}
}
void
testForce
(
int
numParticles
,
NonbondedForce
::
NonbondedMethod
method
,
GBSAOBCForce
::
NonbondedMethod
method2
)
{
void
testForce
(
int
numParticles
,
NonbondedForce
::
NonbondedMethod
method
,
GBSAOBCForce
::
NonbondedMethod
method2
)
{
CudaPlatform
cl
;
ReferencePlatform
reference
;
ReferencePlatform
reference
;
System
system
;
System
system
;
GBSAOBCForce
*
gbsa
=
new
GBSAOBCForce
();
GBSAOBCForce
*
gbsa
=
new
GBSAOBCForce
();
...
@@ -168,7 +167,7 @@ void testForce(int numParticles, NonbondedForce::NonbondedMethod method, GBSAOBC
...
@@ -168,7 +167,7 @@ void testForce(int numParticles, NonbondedForce::NonbondedMethod method, GBSAOBC
system
.
addForce
(
nonbonded
);
system
.
addForce
(
nonbonded
);
LangevinIntegrator
integrator1
(
0
,
0.1
,
0.01
);
LangevinIntegrator
integrator1
(
0
,
0.1
,
0.01
);
LangevinIntegrator
integrator2
(
0
,
0.1
,
0.01
);
LangevinIntegrator
integrator2
(
0
,
0.1
,
0.01
);
Context
context
(
system
,
integrator1
,
cl
);
Context
context
(
system
,
integrator1
,
platform
);
Context
refContext
(
system
,
integrator2
,
reference
);
Context
refContext
(
system
,
integrator2
,
reference
);
// Set random (but uniformly distributed) positions for all the particles.
// Set random (but uniformly distributed) positions for all the particles.
...
@@ -224,8 +223,10 @@ void testForce(int numParticles, NonbondedForce::NonbondedMethod method, GBSAOBC
...
@@ -224,8 +223,10 @@ void testForce(int numParticles, NonbondedForce::NonbondedMethod method, GBSAOBC
}
}
}
}
int
main
()
{
int
main
(
int
argc
,
char
*
argv
[]
)
{
try
{
try
{
if
(
argc
>
1
)
platform
.
setPropertyDefaultValue
(
"CudaPrecision"
,
string
(
argv
[
1
]));
testSingleParticle
();
testSingleParticle
();
testCutoffAndPeriodic
();
testCutoffAndPeriodic
();
for
(
int
i
=
5
;
i
<
11
;
i
++
)
{
for
(
int
i
=
5
;
i
<
11
;
i
++
)
{
...
...
platforms/cuda/tests/TestCudaHarmonicAngleForce.cpp
View file @
3c8adf0c
...
@@ -47,10 +47,11 @@
...
@@ -47,10 +47,11 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
CudaPlatform
platform
;
const
double
TOL
=
1e-5
;
const
double
TOL
=
1e-5
;
void
testAngles
()
{
void
testAngles
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
...
@@ -99,7 +100,6 @@ void testAngles() {
...
@@ -99,7 +100,6 @@ void testAngles() {
}
}
void
testParallelComputation
()
{
void
testParallelComputation
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
const
int
numParticles
=
200
;
const
int
numParticles
=
200
;
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
...
@@ -127,8 +127,10 @@ void testParallelComputation() {
...
@@ -127,8 +127,10 @@ void testParallelComputation() {
ASSERT_EQUAL_VEC
(
state1
.
getForces
()[
i
],
state2
.
getForces
()[
i
],
1e-5
);
ASSERT_EQUAL_VEC
(
state1
.
getForces
()[
i
],
state2
.
getForces
()[
i
],
1e-5
);
}
}
int
main
()
{
int
main
(
int
argc
,
char
*
argv
[]
)
{
try
{
try
{
if
(
argc
>
1
)
platform
.
setPropertyDefaultValue
(
"CudaPrecision"
,
string
(
argv
[
1
]));
testAngles
();
testAngles
();
testParallelComputation
();
testParallelComputation
();
}
}
...
...
platforms/cuda/tests/TestCudaHarmonicBondForce.cpp
View file @
3c8adf0c
...
@@ -46,10 +46,11 @@
...
@@ -46,10 +46,11 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
CudaPlatform
platform
;
const
double
TOL
=
1e-5
;
const
double
TOL
=
1e-5
;
void
testBonds
()
{
void
testBonds
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
...
@@ -90,7 +91,6 @@ void testBonds() {
...
@@ -90,7 +91,6 @@ void testBonds() {
}
}
void
testParallelComputation
()
{
void
testParallelComputation
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
const
int
numParticles
=
200
;
const
int
numParticles
=
200
;
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
...
@@ -118,8 +118,10 @@ void testParallelComputation() {
...
@@ -118,8 +118,10 @@ void testParallelComputation() {
ASSERT_EQUAL_VEC
(
state1
.
getForces
()[
i
],
state2
.
getForces
()[
i
],
1e-5
);
ASSERT_EQUAL_VEC
(
state1
.
getForces
()[
i
],
state2
.
getForces
()[
i
],
1e-5
);
}
}
int
main
()
{
int
main
(
int
argc
,
char
*
argv
[]
)
{
try
{
try
{
if
(
argc
>
1
)
platform
.
setPropertyDefaultValue
(
"CudaPrecision"
,
string
(
argv
[
1
]));
testBonds
();
testBonds
();
testParallelComputation
();
testParallelComputation
();
}
}
...
...
platforms/cuda/tests/TestCudaLangevinIntegrator.cpp
View file @
3c8adf0c
...
@@ -48,10 +48,11 @@
...
@@ -48,10 +48,11 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
CudaPlatform
platform
;
const
double
TOL
=
1e-5
;
const
double
TOL
=
1e-5
;
void
testSingleBond
()
{
void
testSingleBond
()
{
CudaPlatform
platform
;
System
system
;
System
system
;
system
.
addParticle
(
2.0
);
system
.
addParticle
(
2.0
);
system
.
addParticle
(
2.0
);
system
.
addParticle
(
2.0
);
...
@@ -97,7 +98,6 @@ void testSingleBond() {
...
@@ -97,7 +98,6 @@ void testSingleBond() {
void
testTemperature
()
{
void
testTemperature
()
{
const
int
numParticles
=
8
;
const
int
numParticles
=
8
;
const
double
temp
=
100.0
;
const
double
temp
=
100.0
;
CudaPlatform
platform
;
System
system
;
System
system
;
LangevinIntegrator
integrator
(
temp
,
2.0
,
0.01
);
LangevinIntegrator
integrator
(
temp
,
2.0
,
0.01
);
NonbondedForce
*
forceField
=
new
NonbondedForce
();
NonbondedForce
*
forceField
=
new
NonbondedForce
();
...
@@ -133,7 +133,6 @@ void testConstraints() {
...
@@ -133,7 +133,6 @@ void testConstraints() {
const
int
numParticles
=
8
;
const
int
numParticles
=
8
;
const
int
numConstraints
=
5
;
const
int
numConstraints
=
5
;
const
double
temp
=
100.0
;
const
double
temp
=
100.0
;
CudaPlatform
platform
;
System
system
;
System
system
;
LangevinIntegrator
integrator
(
temp
,
2.0
,
0.01
);
LangevinIntegrator
integrator
(
temp
,
2.0
,
0.01
);
integrator
.
setConstraintTolerance
(
1e-5
);
integrator
.
setConstraintTolerance
(
1e-5
);
...
@@ -181,7 +180,6 @@ void testConstraints() {
...
@@ -181,7 +180,6 @@ void testConstraints() {
void
testRandomSeed
()
{
void
testRandomSeed
()
{
const
int
numParticles
=
8
;
const
int
numParticles
=
8
;
const
double
temp
=
100.0
;
const
double
temp
=
100.0
;
CudaPlatform
platform
;
System
system
;
System
system
;
LangevinIntegrator
integrator
(
temp
,
2.0
,
0.01
);
LangevinIntegrator
integrator
(
temp
,
2.0
,
0.01
);
NonbondedForce
*
forceField
=
new
NonbondedForce
();
NonbondedForce
*
forceField
=
new
NonbondedForce
();
...
@@ -236,8 +234,10 @@ void testRandomSeed() {
...
@@ -236,8 +234,10 @@ void testRandomSeed() {
}
}
}
}
int
main
()
{
int
main
(
int
argc
,
char
*
argv
[]
)
{
try
{
try
{
if
(
argc
>
1
)
platform
.
setPropertyDefaultValue
(
"CudaPrecision"
,
string
(
argv
[
1
]));
testSingleBond
();
testSingleBond
();
testTemperature
();
testTemperature
();
testConstraints
();
testConstraints
();
...
...
Prev
1
2
3
4
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment