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
131 additions
and
127 deletions
+131
-127
platforms/opencl/tests/TestOpenCLCustomBondForce.cpp
platforms/opencl/tests/TestOpenCLCustomBondForce.cpp
+5
-4
platforms/opencl/tests/TestOpenCLCustomCompoundBondForce.cpp
platforms/opencl/tests/TestOpenCLCustomCompoundBondForce.cpp
+5
-5
platforms/opencl/tests/TestOpenCLCustomExternalForce.cpp
platforms/opencl/tests/TestOpenCLCustomExternalForce.cpp
+5
-4
platforms/opencl/tests/TestOpenCLCustomGBForce.cpp
platforms/opencl/tests/TestOpenCLCustomGBForce.cpp
+5
-7
platforms/opencl/tests/TestOpenCLCustomHbondForce.cpp
platforms/opencl/tests/TestOpenCLCustomHbondForce.cpp
+5
-6
platforms/opencl/tests/TestOpenCLCustomIntegrator.cpp
platforms/opencl/tests/TestOpenCLCustomIntegrator.cpp
+5
-13
platforms/opencl/tests/TestOpenCLCustomNonbondedForce.cpp
platforms/opencl/tests/TestOpenCLCustomNonbondedForce.cpp
+5
-10
platforms/opencl/tests/TestOpenCLCustomTorsionForce.cpp
platforms/opencl/tests/TestOpenCLCustomTorsionForce.cpp
+5
-5
platforms/opencl/tests/TestOpenCLEwald.cpp
platforms/opencl/tests/TestOpenCLEwald.cpp
+13
-12
platforms/opencl/tests/TestOpenCLFFT.cpp
platforms/opencl/tests/TestOpenCLFFT.cpp
+16
-8
platforms/opencl/tests/TestOpenCLGBSAOBCForce.cpp
platforms/opencl/tests/TestOpenCLGBSAOBCForce.cpp
+4
-5
platforms/opencl/tests/TestOpenCLGBSAOBCForce2.cpp
platforms/opencl/tests/TestOpenCLGBSAOBCForce2.cpp
+14
-6
platforms/opencl/tests/TestOpenCLHarmonicAngleForce.cpp
platforms/opencl/tests/TestOpenCLHarmonicAngleForce.cpp
+5
-3
platforms/opencl/tests/TestOpenCLHarmonicBondForce.cpp
platforms/opencl/tests/TestOpenCLHarmonicBondForce.cpp
+5
-3
platforms/opencl/tests/TestOpenCLLangevinIntegrator.cpp
platforms/opencl/tests/TestOpenCLLangevinIntegrator.cpp
+5
-6
platforms/opencl/tests/TestOpenCLLocalEnergyMinimizer.cpp
platforms/opencl/tests/TestOpenCLLocalEnergyMinimizer.cpp
+5
-4
platforms/opencl/tests/TestOpenCLMonteCarloBarostat.cpp
platforms/opencl/tests/TestOpenCLMonteCarloBarostat.cpp
+5
-5
platforms/opencl/tests/TestOpenCLMultipleForces.cpp
platforms/opencl/tests/TestOpenCLMultipleForces.cpp
+6
-3
platforms/opencl/tests/TestOpenCLNonbondedForce.cpp
platforms/opencl/tests/TestOpenCLNonbondedForce.cpp
+8
-15
platforms/opencl/tests/TestOpenCLPeriodicTorsionForce.cpp
platforms/opencl/tests/TestOpenCLPeriodicTorsionForce.cpp
+5
-3
No files found.
platforms/opencl/tests/TestOpenCLCustomBondForce.cpp
View file @
3c8adf0c
...
@@ -46,10 +46,11 @@
...
@@ -46,10 +46,11 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
OpenCLPlatform
platform
;
const
double
TOL
=
1e-5
;
const
double
TOL
=
1e-5
;
void
testBonds
()
{
void
testBonds
()
{
OpenCLPlatform
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
()
{
OpenCLPlatform
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
()
{
OpenCLPlatform
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
(
"OpenCLPrecision"
,
string
(
argv
[
1
]));
testBonds
();
testBonds
();
testManyParameters
();
testManyParameters
();
testParallelComputation
();
testParallelComputation
();
...
...
platforms/opencl/tests/TestOpenCLCustomCompoundBondForce.cpp
View file @
3c8adf0c
...
@@ -49,11 +49,11 @@
...
@@ -49,11 +49,11 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
OpenCLPlatform
platform
;
const
double
TOL
=
1e-5
;
const
double
TOL
=
1e-5
;
void
testBond
()
{
void
testBond
()
{
OpenCLPlatform
platform
;
// 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
()
{
OpenCLPlatform
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
()
{
OpenCLPlatform
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
(
"OpenCLPrecision"
,
string
(
argv
[
1
]));
testBond
();
testBond
();
testPositionDependence
();
testPositionDependence
();
testParallelComputation
();
testParallelComputation
();
...
...
platforms/opencl/tests/TestOpenCLCustomExternalForce.cpp
View file @
3c8adf0c
...
@@ -47,10 +47,11 @@
...
@@ -47,10 +47,11 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
OpenCLPlatform
platform
;
const
double
TOL
=
1e-5
;
const
double
TOL
=
1e-5
;
void
testForce
()
{
void
testForce
()
{
OpenCLPlatform
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
()
{
OpenCLPlatform
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
()
{
OpenCLPlatform
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
(
"OpenCLPrecision"
,
string
(
argv
[
1
]));
testForce
();
testForce
();
testManyParameters
();
testManyParameters
();
testParallelComputation
();
testParallelComputation
();
...
...
platforms/opencl/tests/TestOpenCLCustomGBForce.cpp
View file @
3c8adf0c
...
@@ -48,13 +48,14 @@
...
@@ -48,13 +48,14 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
OpenCLPlatform
platform
;
const
double
TOL
=
1e-5
;
const
double
TOL
=
1e-5
;
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
;
OpenCLPlatform
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
;
OpenCLPlatform
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
()
{
OpenCLPlatform
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
()
{
OpenCLPlatform
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
()
{
OpenCLPlatform
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
()
{
OpenCLPlatform
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
(
"OpenCLPrecision"
,
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/opencl/tests/TestOpenCLCustomHbondForce.cpp
View file @
3c8adf0c
...
@@ -49,11 +49,11 @@
...
@@ -49,11 +49,11 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
OpenCLPlatform
platform
;
const
double
TOL
=
1e-5
;
const
double
TOL
=
1e-5
;
void
testHbond
()
{
void
testHbond
()
{
OpenCLPlatform
platform
;
// 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
()
{
OpenCLPlatform
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
()
{
OpenCLPlatform
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
()
{
OpenCLPlatform
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
(
"OpenCLPrecision"
,
string
(
argv
[
1
]));
testHbond
();
testHbond
();
testExclusions
();
testExclusions
();
testCutoff
();
testCutoff
();
...
...
platforms/opencl/tests/TestOpenCLCustomIntegrator.cpp
View file @
3c8adf0c
...
@@ -49,13 +49,14 @@
...
@@ -49,13 +49,14 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
OpenCLPlatform
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
()
{
OpenCLPlatform
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
;
OpenCLPlatform
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
;
OpenCLPlatform
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
;
OpenCLPlatform
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
()
{
OpenCLPlatform
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
;
OpenCLPlatform
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
()
{
OpenCLPlatform
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
;
OpenCLPlatform
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
;
OpenCLPlatform
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
()
{
OpenCLPlatform
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
;
OpenCLPlatform
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
(
"OpenCLPrecision"
,
string
(
argv
[
1
]));
testSingleBond
();
testSingleBond
();
testConstraints
();
testConstraints
();
testVelocityConstraints
();
testVelocityConstraints
();
...
...
platforms/opencl/tests/TestOpenCLCustomNonbondedForce.cpp
View file @
3c8adf0c
...
@@ -48,10 +48,11 @@
...
@@ -48,10 +48,11 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
OpenCLPlatform
platform
;
const
double
TOL
=
1e-5
;
const
double
TOL
=
1e-5
;
void
testSimpleExpression
()
{
void
testSimpleExpression
()
{
OpenCLPlatform
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
()
{
OpenCLPlatform
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
()
{
OpenCLPlatform
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
()
{
OpenCLPlatform
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
()
{
OpenCLPlatform
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
()
{
OpenCLPlatform
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
()
{
OpenCLPlatform
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
;
OpenCLPlatform
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
()
{
OpenCLPlatform
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
(
"OpenCLPrecision"
,
string
(
argv
[
1
]));
testSimpleExpression
();
testSimpleExpression
();
testParameters
();
testParameters
();
testManyParameters
();
testManyParameters
();
...
...
platforms/opencl/tests/TestOpenCLCustomTorsionForce.cpp
View file @
3c8adf0c
...
@@ -50,11 +50,11 @@
...
@@ -50,11 +50,11 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
OpenCLPlatform
platform
;
const
double
TOL
=
1e-5
;
const
double
TOL
=
1e-5
;
void
testTorsions
()
{
void
testTorsions
()
{
OpenCLPlatform
platform
;
// Create a system using a CustomTorsionForce.
// Create a system using a CustomTorsionForce.
System
customSystem
;
System
customSystem
;
...
@@ -139,7 +139,6 @@ void testTorsions() {
...
@@ -139,7 +139,6 @@ void testTorsions() {
}
}
void
testRange
()
{
void
testRange
()
{
OpenCLPlatform
platform
;
System
system
;
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
...
@@ -173,7 +172,6 @@ void testRange() {
...
@@ -173,7 +172,6 @@ void testRange() {
}
}
void
testParallelComputation
()
{
void
testParallelComputation
()
{
OpenCLPlatform
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
++
)
...
@@ -202,8 +200,10 @@ void testParallelComputation() {
...
@@ -202,8 +200,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
(
"OpenCLPrecision"
,
string
(
argv
[
1
]));
testTorsions
();
testTorsions
();
testRange
();
testRange
();
testParallelComputation
();
testParallelComputation
();
...
...
platforms/opencl/tests/TestOpenCLEwald.cpp
View file @
3c8adf0c
...
@@ -50,6 +50,8 @@
...
@@ -50,6 +50,8 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
OpenCLPlatform
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
;
OpenCLPlatform
cl
;
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
clContext
(
system
,
integrator1
,
cl
);
Context
clContext
(
system
,
integrator1
,
platform
);
Context
referenceContext
(
system
,
integrator2
,
reference
);
Context
referenceContext
(
system
,
integrator2
,
reference
);
clContext
.
setPositions
(
positions
);
clContext
.
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
clContext2
(
system
,
integrator3
,
cl
);
Context
clContext2
(
system
,
integrator3
,
platform
);
clContext2
.
setPositions
(
positions
);
clContext2
.
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
clContext3
(
system
,
integrator4
,
cl
);
Context
clContext3
(
system
,
integrator4
,
platform
);
clContext3
.
setPositions
(
positions
);
clContext3
.
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
()
{
OpenCLPlatform
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
);
OpenCLPlatform
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
(
"OpenCLPrecision"
,
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/opencl/tests/TestOpenCLFFT.cpp
View file @
3c8adf0c
...
@@ -48,31 +48,34 @@
...
@@ -48,31 +48,34 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
OpenCLPlatform
platform
;
template
<
class
Real2
>
void
testTransform
()
{
void
testTransform
()
{
System
system
;
System
system
;
system
.
addParticle
(
0.0
);
system
.
addParticle
(
0.0
);
OpenCLPlatform
::
PlatformData
platformData
(
system
,
""
,
""
,
"single"
);
OpenCLPlatform
::
PlatformData
platformData
(
system
,
""
,
""
,
platform
.
getPropertyDefaultValue
(
"OpenCLPrecision"
)
);
OpenCLContext
&
context
=
*
platformData
.
contexts
[
0
];
OpenCLContext
&
context
=
*
platformData
.
contexts
[
0
];
context
.
initialize
();
context
.
initialize
();
OpenMM_SFMT
::
SFMT
sfmt
;
OpenMM_SFMT
::
SFMT
sfmt
;
init_gen_rand
(
0
,
sfmt
);
init_gen_rand
(
0
,
sfmt
);
int
xsize
=
32
,
ysize
=
25
,
zsize
=
30
;
int
xsize
=
32
,
ysize
=
25
,
zsize
=
30
;
vector
<
mm_float
2
>
original
(
xsize
*
ysize
*
zsize
);
vector
<
Real
2
>
original
(
xsize
*
ysize
*
zsize
);
vector
<
t_complex
>
reference
(
original
.
size
());
vector
<
t_complex
>
reference
(
original
.
size
());
for
(
int
i
=
0
;
i
<
(
int
)
original
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
original
.
size
();
i
++
)
{
mm_float
2
value
=
mm_float
2
((
cl_float
)
genrand_real2
(
sfmt
),
(
cl_float
)
genrand_real2
(
sfmt
));
Real
2
value
=
Real
2
((
cl_float
)
genrand_real2
(
sfmt
),
(
cl_float
)
genrand_real2
(
sfmt
));
original
[
i
]
=
value
;
original
[
i
]
=
value
;
reference
[
i
]
=
t_complex
(
value
.
x
,
value
.
y
);
reference
[
i
]
=
t_complex
(
value
.
x
,
value
.
y
);
}
}
OpenCLArray
grid1
(
context
,
original
.
size
(),
sizeof
(
mm_float
2
),
"grid1"
);
OpenCLArray
grid1
(
context
,
original
.
size
(),
sizeof
(
Real
2
),
"grid1"
);
OpenCLArray
grid2
(
context
,
original
.
size
(),
sizeof
(
mm_float
2
),
"grid2"
);
OpenCLArray
grid2
(
context
,
original
.
size
(),
sizeof
(
Real
2
),
"grid2"
);
grid1
.
upload
(
original
);
grid1
.
upload
(
original
);
OpenCLFFT3D
fft
(
context
,
xsize
,
ysize
,
zsize
);
OpenCLFFT3D
fft
(
context
,
xsize
,
ysize
,
zsize
);
// Perform a forward FFT, then verify the result is correct.
// Perform a forward FFT, then verify the result is correct.
fft
.
execFFT
(
grid1
,
grid2
,
true
);
fft
.
execFFT
(
grid1
,
grid2
,
true
);
vector
<
mm_float
2
>
result
;
vector
<
Real
2
>
result
;
grid2
.
download
(
result
);
grid2
.
download
(
result
);
fftpack_t
plan
;
fftpack_t
plan
;
fftpack_init_3d
(
&
plan
,
xsize
,
ysize
,
zsize
);
fftpack_init_3d
(
&
plan
,
xsize
,
ysize
,
zsize
);
...
@@ -94,9 +97,14 @@ void testTransform() {
...
@@ -94,9 +97,14 @@ void testTransform() {
}
}
}
}
int
main
()
{
int
main
(
int
argc
,
char
*
argv
[]
)
{
try
{
try
{
testTransform
();
if
(
argc
>
1
)
platform
.
setPropertyDefaultValue
(
"OpenCLPrecision"
,
string
(
argv
[
1
]));
if
(
platform
.
getPropertyDefaultValue
(
"OpenCLPrecision"
)
==
"double"
)
testTransform
<
mm_double2
>
();
else
testTransform
<
mm_float2
>
();
}
}
catch
(
const
exception
&
e
)
{
catch
(
const
exception
&
e
)
{
cout
<<
"exception: "
<<
e
.
what
()
<<
endl
;
cout
<<
"exception: "
<<
e
.
what
()
<<
endl
;
...
...
platforms/opencl/tests/TestOpenCLGBSAOBCForce.cpp
View file @
3c8adf0c
...
@@ -49,10 +49,11 @@
...
@@ -49,10 +49,11 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
OpenCLPlatform
platform
;
const
double
TOL
=
1e-5
;
const
double
TOL
=
1e-5
;
void
testSingleParticle
()
{
void
testSingleParticle
()
{
OpenCLPlatform
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
()
{
OpenCLPlatform
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
)
{
OpenCLPlatform
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.
...
...
platforms/opencl/tests/TestOpenCLGBSAOBCForce2.cpp
View file @
3c8adf0c
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
* -------------------------------------------------------------------------- */
* -------------------------------------------------------------------------- */
/**
/**
* This tests the
Cuda
implementations of GBVIForce, GBSAOBCForce and the softcore versions of
* This tests the
OpenCL
implementations of GBVIForce, GBSAOBCForce and the softcore versions of
* these forces.
* these forces.
*/
*/
...
@@ -2850,7 +2850,7 @@ static int checkRequiredLibsAreAvailable( const StringVector& requiredLibs, cons
...
@@ -2850,7 +2850,7 @@ static int checkRequiredLibsAreAvailable( const StringVector& requiredLibs, cons
void
runSystemComparisonTest
(
System
&
system1
,
System
&
system2
,
void
runSystemComparisonTest
(
System
&
system1
,
System
&
system2
,
const
std
::
vector
<
Vec3
>&
positions
,
MapStringToDouble
&
inputArgumentMap
,
const
std
::
vector
<
Vec3
>&
positions
,
MapStringToDouble
&
inputArgumentMap
,
const
std
::
string
&
idString
,
FILE
*
log
){
const
std
::
string
&
idString
,
const
std
::
string
&
precision
,
FILE
*
log
){
int
applyAssert
=
0
;
int
applyAssert
=
0
;
int
platformId1
=
0
;
int
platformId1
=
0
;
...
@@ -2914,9 +2914,11 @@ void runSystemComparisonTest( System& system1, System& system2,
...
@@ -2914,9 +2914,11 @@ void runSystemComparisonTest( System& system1, System& system2,
#if TEST_PLATFORM == TEST_OPENCL_PLATFORM
#if TEST_PLATFORM == TEST_OPENCL_PLATFORM
ReferencePlatform
platform1
;
ReferencePlatform
platform1
;
OpenCLPlatform
platform2
;
OpenCLPlatform
platform2
;
platform2
.
setPropertyDefaultValue
(
"OpenCLPrecision"
,
precision
);
#elif TEST_PLATFORM == TEST_CUDA_PLATFORM
#elif TEST_PLATFORM == TEST_CUDA_PLATFORM
ReferencePlatform
platform1
;
ReferencePlatform
platform1
;
CudaPlatform
platform2
;
CudaPlatform
platform2
;
platform2
.
setPropertyDefaultValue
(
"CudaPrecision"
,
precision
);
#else
#else
Platform
&
platform1
=
Platform
::
getPlatformByName
(
platformName1
);
Platform
&
platform1
=
Platform
::
getPlatformByName
(
platformName1
);
if
(
deviceId1
){
if
(
deviceId1
){
...
@@ -3059,7 +3061,7 @@ void serializeSystemAndPositions( System& system, const std::vector<Vec3>& posit
...
@@ -3059,7 +3061,7 @@ void serializeSystemAndPositions( System& system, const std::vector<Vec3>& posit
return
;
return
;
}
}
void
runTests
(
MapStringToDouble
&
inputArgumentMap
,
FILE
*
log
){
void
runTests
(
MapStringToDouble
&
inputArgumentMap
,
const
std
::
string
&
precision
,
FILE
*
log
){
double
lambda1
=
1.0
;
double
lambda1
=
1.0
;
double
lambda2
=
1.0
;
double
lambda2
=
1.0
;
...
@@ -3327,12 +3329,18 @@ void runTests( MapStringToDouble& inputArgumentMap, FILE* log ){
...
@@ -3327,12 +3329,18 @@ void runTests( MapStringToDouble& inputArgumentMap, FILE* log ){
std
::
stringstream
idString
;
std
::
stringstream
idString
;
idString
<<
"Nb "
<<
nonbondedMethod
<<
" l2 "
<<
std
::
fixed
<<
setprecision
(
2
)
<<
lambda2
;
idString
<<
"Nb "
<<
nonbondedMethod
<<
" l2 "
<<
std
::
fixed
<<
setprecision
(
2
)
<<
lambda2
;
runSystemComparisonTest
(
standardSystem
,
systemCopy
,
positions
,
inputArgumentMap
,
idString
.
str
(),
log
);
runSystemComparisonTest
(
standardSystem
,
systemCopy
,
positions
,
inputArgumentMap
,
idString
.
str
(),
precision
,
log
);
}
}
int
main
()
{
int
main
(
int
argc
,
char
*
argv
[]
)
{
std
::
string
precision
;
if
(
argc
>
1
)
precision
=
std
::
string
(
argv
[
1
]);
else
precision
=
"single"
;
try
{
try
{
#ifdef USE_SOFTCORE
#ifdef USE_SOFTCORE
...
@@ -3503,7 +3511,7 @@ int main() {
...
@@ -3503,7 +3511,7 @@ int main() {
int
wasException
=
0
;
int
wasException
=
0
;
for
(
unsigned
int
kk
=
0
;
kk
<
vectorOfMapStringToDouble
.
size
()
&&
wasException
<
3
;
kk
++
){
for
(
unsigned
int
kk
=
0
;
kk
<
vectorOfMapStringToDouble
.
size
()
&&
wasException
<
3
;
kk
++
){
try
{
try
{
runTests
(
vectorOfMapStringToDouble
[
kk
],
log
);
runTests
(
vectorOfMapStringToDouble
[
kk
],
precision
,
log
);
}
catch
(
const
exception
&
e
)
{
}
catch
(
const
exception
&
e
)
{
std
::
stringstream
msg
;
std
::
stringstream
msg
;
#if IMPLICIT_SOLVENT == TEST_NONBONDED
#if IMPLICIT_SOLVENT == TEST_NONBONDED
...
...
platforms/opencl/tests/TestOpenCLHarmonicAngleForce.cpp
View file @
3c8adf0c
...
@@ -47,10 +47,11 @@
...
@@ -47,10 +47,11 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
OpenCLPlatform
platform
;
const
double
TOL
=
1e-5
;
const
double
TOL
=
1e-5
;
void
testAngles
()
{
void
testAngles
()
{
OpenCLPlatform
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
()
{
OpenCLPlatform
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
(
"OpenCLPrecision"
,
string
(
argv
[
1
]));
testAngles
();
testAngles
();
testParallelComputation
();
testParallelComputation
();
}
}
...
...
platforms/opencl/tests/TestOpenCLHarmonicBondForce.cpp
View file @
3c8adf0c
...
@@ -46,10 +46,11 @@
...
@@ -46,10 +46,11 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
OpenCLPlatform
platform
;
const
double
TOL
=
1e-5
;
const
double
TOL
=
1e-5
;
void
testBonds
()
{
void
testBonds
()
{
OpenCLPlatform
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
()
{
OpenCLPlatform
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
(
"OpenCLPrecision"
,
string
(
argv
[
1
]));
testBonds
();
testBonds
();
testParallelComputation
();
testParallelComputation
();
}
}
...
...
platforms/opencl/tests/TestOpenCLLangevinIntegrator.cpp
View file @
3c8adf0c
...
@@ -48,10 +48,11 @@
...
@@ -48,10 +48,11 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
OpenCLPlatform
platform
;
const
double
TOL
=
1e-5
;
const
double
TOL
=
1e-5
;
void
testSingleBond
()
{
void
testSingleBond
()
{
OpenCLPlatform
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
;
OpenCLPlatform
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
;
OpenCLPlatform
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,8 +180,6 @@ void testConstraints() {
...
@@ -181,8 +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
;
const
double
collisionFreq
=
10.0
;
OpenCLPlatform
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
();
...
@@ -237,8 +234,10 @@ void testRandomSeed() {
...
@@ -237,8 +234,10 @@ void testRandomSeed() {
}
}
}
}
int
main
()
{
int
main
(
int
argc
,
char
*
argv
[]
)
{
try
{
try
{
if
(
argc
>
1
)
platform
.
setPropertyDefaultValue
(
"OpenCLPrecision"
,
string
(
argv
[
1
]));
testSingleBond
();
testSingleBond
();
testTemperature
();
testTemperature
();
testConstraints
();
testConstraints
();
...
...
platforms/opencl/tests/TestOpenCLLocalEnergyMinimizer.cpp
View file @
3c8adf0c
...
@@ -45,6 +45,8 @@
...
@@ -45,6 +45,8 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
OpenCLPlatform
platform
;
void
testHarmonicBonds
()
{
void
testHarmonicBonds
()
{
const
int
numParticles
=
10
;
const
int
numParticles
=
10
;
System
system
;
System
system
;
...
@@ -64,7 +66,6 @@ void testHarmonicBonds() {
...
@@ -64,7 +66,6 @@ void testHarmonicBonds() {
// Minimize it and check that all bonds are at their equilibrium distances.
// Minimize it and check that all bonds are at their equilibrium distances.
VerletIntegrator
integrator
(
0.01
);
VerletIntegrator
integrator
(
0.01
);
OpenCLPlatform
platform
;
Context
context
(
system
,
integrator
,
platform
);
Context
context
(
system
,
integrator
,
platform
);
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
LocalEnergyMinimizer
::
minimize
(
context
,
1e-5
);
LocalEnergyMinimizer
::
minimize
(
context
,
1e-5
);
...
@@ -105,7 +106,6 @@ void testLargeSystem() {
...
@@ -105,7 +106,6 @@ void testLargeSystem() {
// Minimize it and verify that the energy has decreased.
// Minimize it and verify that the energy has decreased.
OpenCLPlatform
platform
;
VerletIntegrator
integrator
(
0.01
);
VerletIntegrator
integrator
(
0.01
);
Context
context
(
system
,
integrator
,
platform
);
Context
context
(
system
,
integrator
,
platform
);
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
...
@@ -167,7 +167,6 @@ void testVirtualSites() {
...
@@ -167,7 +167,6 @@ void testVirtualSites() {
// Minimize it and verify that the energy has decreased.
// Minimize it and verify that the energy has decreased.
OpenCLPlatform
platform
;
VerletIntegrator
integrator
(
0.01
);
VerletIntegrator
integrator
(
0.01
);
Context
context
(
system
,
integrator
,
platform
);
Context
context
(
system
,
integrator
,
platform
);
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
...
@@ -199,8 +198,10 @@ void testVirtualSites() {
...
@@ -199,8 +198,10 @@ void testVirtualSites() {
ASSERT
(
forceNorm
<
3
*
tolerance
);
ASSERT
(
forceNorm
<
3
*
tolerance
);
}
}
int
main
()
{
int
main
(
int
argc
,
char
*
argv
[]
)
{
try
{
try
{
if
(
argc
>
1
)
platform
.
setPropertyDefaultValue
(
"OpenCLPrecision"
,
string
(
argv
[
1
]));
testHarmonicBonds
();
testHarmonicBonds
();
testLargeSystem
();
testLargeSystem
();
testVirtualSites
();
testVirtualSites
();
...
...
platforms/opencl/tests/TestOpenCLMonteCarloBarostat.cpp
View file @
3c8adf0c
...
@@ -49,8 +49,9 @@
...
@@ -49,8 +49,9 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
OpenCLPlatform
platform
;
void
testChangingBoxSize
()
{
void
testChangingBoxSize
()
{
OpenCLPlatform
platform
;
System
system
;
System
system
;
system
.
setDefaultPeriodicBoxVectors
(
Vec3
(
4
,
0
,
0
),
Vec3
(
0
,
5
,
0
),
Vec3
(
0
,
0
,
6
));
system
.
setDefaultPeriodicBoxVectors
(
Vec3
(
4
,
0
,
0
),
Vec3
(
0
,
5
,
0
),
Vec3
(
0
,
0
,
6
));
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
...
@@ -100,7 +101,6 @@ void testIdealGas() {
...
@@ -100,7 +101,6 @@ void testIdealGas() {
// Create a gas of noninteracting particles.
// Create a gas of noninteracting particles.
OpenCLPlatform
platform
;
System
system
;
System
system
;
system
.
setDefaultPeriodicBoxVectors
(
Vec3
(
initialLength
,
0
,
0
),
Vec3
(
0
,
0.5
*
initialLength
,
0
),
Vec3
(
0
,
0
,
2
*
initialLength
));
system
.
setDefaultPeriodicBoxVectors
(
Vec3
(
initialLength
,
0
,
0
),
Vec3
(
0
,
0.5
*
initialLength
,
0
),
Vec3
(
0
,
0
,
2
*
initialLength
));
vector
<
Vec3
>
positions
(
numParticles
);
vector
<
Vec3
>
positions
(
numParticles
);
...
@@ -146,7 +146,6 @@ void testRandomSeed() {
...
@@ -146,7 +146,6 @@ void testRandomSeed() {
const
int
numParticles
=
8
;
const
int
numParticles
=
8
;
const
double
temp
=
100.0
;
const
double
temp
=
100.0
;
const
double
pressure
=
1.5
;
const
double
pressure
=
1.5
;
OpenCLPlatform
platform
;
System
system
;
System
system
;
system
.
setDefaultPeriodicBoxVectors
(
Vec3
(
8
,
0
,
0
),
Vec3
(
0
,
8
,
0
),
Vec3
(
0
,
0
,
8
));
system
.
setDefaultPeriodicBoxVectors
(
Vec3
(
8
,
0
,
0
),
Vec3
(
0
,
8
,
0
),
Vec3
(
0
,
0
,
8
));
VerletIntegrator
integrator
(
0.01
);
VerletIntegrator
integrator
(
0.01
);
...
@@ -219,7 +218,6 @@ void testWater() {
...
@@ -219,7 +218,6 @@ void testWater() {
// Create a box of SPC water molecules.
// Create a box of SPC water molecules.
OpenCLPlatform
platform
;
System
system
;
System
system
;
system
.
setDefaultPeriodicBoxVectors
(
Vec3
(
gridSize
*
spacing
,
0
,
0
),
Vec3
(
0
,
gridSize
*
spacing
,
0
),
Vec3
(
0
,
0
,
gridSize
*
spacing
));
system
.
setDefaultPeriodicBoxVectors
(
Vec3
(
gridSize
*
spacing
,
0
,
0
),
Vec3
(
0
,
gridSize
*
spacing
,
0
),
Vec3
(
0
,
0
,
gridSize
*
spacing
));
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
...
@@ -273,8 +271,10 @@ void testWater() {
...
@@ -273,8 +271,10 @@ void testWater() {
ASSERT_USUALLY_EQUAL_TOL
(
1.0
,
density
,
0.02
);
ASSERT_USUALLY_EQUAL_TOL
(
1.0
,
density
,
0.02
);
}
}
int
main
()
{
int
main
(
int
argc
,
char
*
argv
[]
)
{
try
{
try
{
if
(
argc
>
1
)
platform
.
setPropertyDefaultValue
(
"OpenCLPrecision"
,
string
(
argv
[
1
]));
testChangingBoxSize
();
testChangingBoxSize
();
testIdealGas
();
testIdealGas
();
testRandomSeed
();
testRandomSeed
();
...
...
platforms/opencl/tests/TestOpenCLMultipleForces.cpp
View file @
3c8adf0c
...
@@ -52,6 +52,8 @@
...
@@ -52,6 +52,8 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
OpenCLPlatform
platform
;
const
double
TOL
=
1e-5
;
const
double
TOL
=
1e-5
;
void
testForces
()
{
void
testForces
()
{
...
@@ -78,9 +80,8 @@ void testForces() {
...
@@ -78,9 +80,8 @@ void testForces() {
ReferencePlatform
ref
;
ReferencePlatform
ref
;
VerletIntegrator
integrator1
(
0.01
);
VerletIntegrator
integrator1
(
0.01
);
Context
context1
(
system
,
integrator1
,
ref
);
Context
context1
(
system
,
integrator1
,
ref
);
OpenCLPlatform
cl
;
VerletIntegrator
integrator2
(
0.01
);
VerletIntegrator
integrator2
(
0.01
);
Context
context2
(
system
,
integrator2
,
cl
);
Context
context2
(
system
,
integrator2
,
platform
);
OpenMM_SFMT
::
SFMT
sfmt
;
OpenMM_SFMT
::
SFMT
sfmt
;
init_gen_rand
(
0
,
sfmt
);
init_gen_rand
(
0
,
sfmt
);
vector
<
Vec3
>
positions
(
numParticles
);
vector
<
Vec3
>
positions
(
numParticles
);
...
@@ -97,8 +98,10 @@ void testForces() {
...
@@ -97,8 +98,10 @@ void testForces() {
ASSERT_EQUAL_TOL
(
state1
.
getPotentialEnergy
(),
state2
.
getPotentialEnergy
(),
TOL
);
ASSERT_EQUAL_TOL
(
state1
.
getPotentialEnergy
(),
state2
.
getPotentialEnergy
(),
TOL
);
}
}
int
main
()
{
int
main
(
int
argc
,
char
*
argv
[]
)
{
try
{
try
{
if
(
argc
>
1
)
platform
.
setPropertyDefaultValue
(
"OpenCLPrecision"
,
string
(
argv
[
1
]));
testForces
();
testForces
();
}
}
catch
(
const
exception
&
e
)
{
catch
(
const
exception
&
e
)
{
...
...
platforms/opencl/tests/TestOpenCLNonbondedForce.cpp
View file @
3c8adf0c
...
@@ -53,10 +53,11 @@
...
@@ -53,10 +53,11 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
OpenCLPlatform
platform
;
const
double
TOL
=
1e-5
;
const
double
TOL
=
1e-5
;
void
testCoulomb
()
{
void
testCoulomb
()
{
OpenCLPlatform
platform
;
System
system
;
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
...
@@ -79,7 +80,6 @@ void testCoulomb() {
...
@@ -79,7 +80,6 @@ void testCoulomb() {
}
}
void
testLJ
()
{
void
testLJ
()
{
OpenCLPlatform
platform
;
System
system
;
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
...
@@ -104,7 +104,6 @@ void testLJ() {
...
@@ -104,7 +104,6 @@ void testLJ() {
}
}
void
testExclusionsAnd14
()
{
void
testExclusionsAnd14
()
{
OpenCLPlatform
platform
;
System
system
;
System
system
;
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
...
@@ -192,7 +191,6 @@ void testExclusionsAnd14() {
...
@@ -192,7 +191,6 @@ void testExclusionsAnd14() {
}
}
void
testCutoff
()
{
void
testCutoff
()
{
OpenCLPlatform
platform
;
System
system
;
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
...
@@ -229,7 +227,6 @@ void testCutoff() {
...
@@ -229,7 +227,6 @@ void testCutoff() {
}
}
void
testCutoff14
()
{
void
testCutoff14
()
{
OpenCLPlatform
platform
;
System
system
;
System
system
;
LangevinIntegrator
integrator
(
0.0
,
0.1
,
0.01
);
LangevinIntegrator
integrator
(
0.0
,
0.1
,
0.01
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
...
@@ -325,7 +322,6 @@ void testCutoff14() {
...
@@ -325,7 +322,6 @@ void testCutoff14() {
}
}
void
testPeriodic
()
{
void
testPeriodic
()
{
OpenCLPlatform
platform
;
System
system
;
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
...
@@ -366,7 +362,6 @@ void testLargeSystem() {
...
@@ -366,7 +362,6 @@ void testLargeSystem() {
const
double
cutoff
=
2.0
;
const
double
cutoff
=
2.0
;
const
double
boxSize
=
20.0
;
const
double
boxSize
=
20.0
;
const
double
tol
=
2e-3
;
const
double
tol
=
2e-3
;
OpenCLPlatform
cl
;
ReferencePlatform
reference
;
ReferencePlatform
reference
;
System
system
;
System
system
;
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
...
@@ -404,7 +399,7 @@ void testLargeSystem() {
...
@@ -404,7 +399,7 @@ void testLargeSystem() {
system
.
addForce
(
bonds
);
system
.
addForce
(
bonds
);
VerletIntegrator
integrator1
(
0.01
);
VerletIntegrator
integrator1
(
0.01
);
VerletIntegrator
integrator2
(
0.01
);
VerletIntegrator
integrator2
(
0.01
);
Context
clContext
(
system
,
integrator1
,
cl
);
Context
clContext
(
system
,
integrator1
,
platform
);
Context
referenceContext
(
system
,
integrator2
,
reference
);
Context
referenceContext
(
system
,
integrator2
,
reference
);
clContext
.
setPositions
(
positions
);
clContext
.
setPositions
(
positions
);
clContext
.
setVelocities
(
velocities
);
clContext
.
setVelocities
(
velocities
);
...
@@ -450,7 +445,6 @@ void testBlockInteractions(bool periodic) {
...
@@ -450,7 +445,6 @@ void testBlockInteractions(bool periodic) {
const
int
numParticles
=
blockSize
*
numBlocks
;
const
int
numParticles
=
blockSize
*
numBlocks
;
const
double
cutoff
=
1.0
;
const
double
cutoff
=
1.0
;
const
double
boxSize
=
(
periodic
?
5.1
:
1.1
);
const
double
boxSize
=
(
periodic
?
5.1
:
1.1
);
OpenCLPlatform
cl
;
System
system
;
System
system
;
VerletIntegrator
integrator
(
0.01
);
VerletIntegrator
integrator
(
0.01
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
...
@@ -467,7 +461,7 @@ void testBlockInteractions(bool periodic) {
...
@@ -467,7 +461,7 @@ void testBlockInteractions(bool periodic) {
nonbonded
->
setCutoffDistance
(
cutoff
);
nonbonded
->
setCutoffDistance
(
cutoff
);
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
));
system
.
addForce
(
nonbonded
);
system
.
addForce
(
nonbonded
);
Context
context
(
system
,
integrator
,
cl
);
Context
context
(
system
,
integrator
,
platform
);
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
ContextImpl
*
contextImpl
=
*
reinterpret_cast
<
ContextImpl
**>
(
&
context
);
ContextImpl
*
contextImpl
=
*
reinterpret_cast
<
ContextImpl
**>
(
&
context
);
OpenCLPlatform
::
PlatformData
&
data
=
*
static_cast
<
OpenCLPlatform
::
PlatformData
*>
(
contextImpl
->
getPlatformData
());
OpenCLPlatform
::
PlatformData
&
data
=
*
static_cast
<
OpenCLPlatform
::
PlatformData
*>
(
contextImpl
->
getPlatformData
());
...
@@ -617,7 +611,6 @@ void testDispersionCorrection() {
...
@@ -617,7 +611,6 @@ void testDispersionCorrection() {
int
numParticles
=
gridSize
*
gridSize
*
gridSize
;
int
numParticles
=
gridSize
*
gridSize
*
gridSize
;
double
boxSize
=
gridSize
*
0.5
;
double
boxSize
=
gridSize
*
0.5
;
double
cutoff
=
boxSize
/
3
;
double
cutoff
=
boxSize
/
3
;
OpenCLPlatform
platform
;
System
system
;
System
system
;
VerletIntegrator
integrator
(
0.01
);
VerletIntegrator
integrator
(
0.01
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
...
@@ -684,7 +677,6 @@ void testChangingParameters() {
...
@@ -684,7 +677,6 @@ void testChangingParameters() {
const
double
cutoff
=
2.0
;
const
double
cutoff
=
2.0
;
const
double
boxSize
=
20.0
;
const
double
boxSize
=
20.0
;
const
double
tol
=
2e-3
;
const
double
tol
=
2e-3
;
OpenCLPlatform
cl
;
ReferencePlatform
reference
;
ReferencePlatform
reference
;
System
system
;
System
system
;
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
...
@@ -717,7 +709,7 @@ void testChangingParameters() {
...
@@ -717,7 +709,7 @@ void testChangingParameters() {
VerletIntegrator
integrator1
(
0.01
);
VerletIntegrator
integrator1
(
0.01
);
VerletIntegrator
integrator2
(
0.01
);
VerletIntegrator
integrator2
(
0.01
);
Context
clContext
(
system
,
integrator1
,
cl
);
Context
clContext
(
system
,
integrator1
,
platform
);
Context
referenceContext
(
system
,
integrator2
,
reference
);
Context
referenceContext
(
system
,
integrator2
,
reference
);
clContext
.
setPositions
(
positions
);
clContext
.
setPositions
(
positions
);
referenceContext
.
setPositions
(
positions
);
referenceContext
.
setPositions
(
positions
);
...
@@ -750,7 +742,6 @@ void testChangingParameters() {
...
@@ -750,7 +742,6 @@ void testChangingParameters() {
}
}
void
testParallelComputation
(
bool
useCutoff
)
{
void
testParallelComputation
(
bool
useCutoff
)
{
OpenCLPlatform
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
++
)
...
@@ -809,8 +800,10 @@ void testParallelComputation(bool useCutoff) {
...
@@ -809,8 +800,10 @@ void testParallelComputation(bool useCutoff) {
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
(
"OpenCLPrecision"
,
string
(
argv
[
1
]));
testCoulomb
();
testCoulomb
();
testLJ
();
testLJ
();
testExclusionsAnd14
();
testExclusionsAnd14
();
...
...
platforms/opencl/tests/TestOpenCLPeriodicTorsionForce.cpp
View file @
3c8adf0c
...
@@ -46,10 +46,11 @@
...
@@ -46,10 +46,11 @@
using
namespace
OpenMM
;
using
namespace
OpenMM
;
using
namespace
std
;
using
namespace
std
;
OpenCLPlatform
platform
;
const
double
TOL
=
1e-5
;
const
double
TOL
=
1e-5
;
void
testPeriodicTorsions
()
{
void
testPeriodicTorsions
()
{
OpenCLPlatform
platform
;
System
system
;
System
system
;
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
...
@@ -93,7 +94,6 @@ void testPeriodicTorsions() {
...
@@ -93,7 +94,6 @@ void testPeriodicTorsions() {
}
}
void
testParallelComputation
()
{
void
testParallelComputation
()
{
OpenCLPlatform
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
++
)
...
@@ -121,8 +121,10 @@ void testParallelComputation() {
...
@@ -121,8 +121,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
(
"OpenCLPrecision"
,
string
(
argv
[
1
]));
testPeriodicTorsions
();
testPeriodicTorsions
();
testParallelComputation
();
testParallelComputation
();
}
}
...
...
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