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
6ed5bc4e
"...tests/TestReferenceMonteCarloAnisotropicBarostat.cpp" did not exist on "b06fc4a7a47478beacbaf5cc108f755653bc7abb"
Commit
6ed5bc4e
authored
Apr 20, 2017
by
Rafal Wiewiora
Committed by
GitHub
Apr 20, 2017
Browse files
Merge branch 'master' into master
parents
656d0e3b
fbf193fe
Changes
121
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
437 additions
and
429 deletions
+437
-429
openmmapi/src/CustomManyParticleForceImpl.cpp
openmmapi/src/CustomManyParticleForceImpl.cpp
+5
-5
openmmapi/src/CustomNonbondedForce.cpp
openmmapi/src/CustomNonbondedForce.cpp
+15
-14
openmmapi/src/Force.cpp
openmmapi/src/Force.cpp
+6
-8
openmmapi/src/GBSAOBCForce.cpp
openmmapi/src/GBSAOBCForce.cpp
+2
-0
openmmapi/src/GayBerneForce.cpp
openmmapi/src/GayBerneForce.cpp
+2
-0
openmmapi/src/NonbondedForce.cpp
openmmapi/src/NonbondedForce.cpp
+18
-15
openmmapi/src/System.cpp
openmmapi/src/System.cpp
+4
-4
openmmapi/src/ThreadPool.cpp
openmmapi/src/ThreadPool.cpp
+4
-4
platforms/cpu/src/CpuBondForce.cpp
platforms/cpu/src/CpuBondForce.cpp
+2
-2
platforms/cpu/src/CpuCustomGBForce.cpp
platforms/cpu/src/CpuCustomGBForce.cpp
+50
-50
platforms/cpu/src/CpuCustomManyParticleForce.cpp
platforms/cpu/src/CpuCustomManyParticleForce.cpp
+26
-35
platforms/cpu/src/CpuCustomNonbondedForce.cpp
platforms/cpu/src/CpuCustomNonbondedForce.cpp
+12
-12
platforms/cpu/src/CpuKernels.cpp
platforms/cpu/src/CpuKernels.cpp
+14
-14
platforms/cpu/src/CpuNeighborList.cpp
platforms/cpu/src/CpuNeighborList.cpp
+3
-3
platforms/cpu/src/CpuNonbondedForce.cpp
platforms/cpu/src/CpuNonbondedForce.cpp
+3
-3
platforms/cpu/src/CpuRandom.cpp
platforms/cpu/src/CpuRandom.cpp
+2
-2
platforms/cpu/src/CpuSETTLE.cpp
platforms/cpu/src/CpuSETTLE.cpp
+2
-2
platforms/cuda/src/CudaContext.cpp
platforms/cuda/src/CudaContext.cpp
+32
-33
platforms/cuda/src/CudaExpressionUtilities.cpp
platforms/cuda/src/CudaExpressionUtilities.cpp
+4
-4
platforms/cuda/src/CudaKernels.cpp
platforms/cuda/src/CudaKernels.cpp
+231
-219
No files found.
openmmapi/src/CustomManyParticleForceImpl.cpp
View file @
6ed5bc4e
...
@@ -197,8 +197,8 @@ ExpressionTreeNode CustomManyParticleForceImpl::replaceFunctions(const Expressio
...
@@ -197,8 +197,8 @@ ExpressionTreeNode CustomManyParticleForceImpl::replaceFunctions(const Expressio
// This is not an angle or dihedral, so process its children.
// This is not an angle or dihedral, so process its children.
vector
<
ExpressionTreeNode
>
children
;
vector
<
ExpressionTreeNode
>
children
;
for
(
int
i
=
0
;
i
<
(
int
)
node
.
getChildren
()
.
size
();
i
++
)
for
(
auto
&
child
:
node
.
getChildren
())
children
.
push_back
(
replaceFunctions
(
node
.
getChildren
()[
i
]
,
atoms
,
distances
,
angles
,
dihedrals
,
variables
));
children
.
push_back
(
replaceFunctions
(
child
,
atoms
,
distances
,
angles
,
dihedrals
,
variables
));
return
ExpressionTreeNode
(
op
.
clone
(),
children
);
return
ExpressionTreeNode
(
op
.
clone
(),
children
);
}
}
const
Operation
::
Custom
&
custom
=
static_cast
<
const
Operation
::
Custom
&>
(
op
);
const
Operation
::
Custom
&
custom
=
static_cast
<
const
Operation
::
Custom
&>
(
op
);
...
@@ -280,9 +280,9 @@ void CustomManyParticleForceImpl::buildFilterArrays(const CustomManyParticleForc
...
@@ -280,9 +280,9 @@ void CustomManyParticleForceImpl::buildFilterArrays(const CustomManyParticleForc
for
(
int
j
=
0
;
j
<
numTypes
;
j
++
)
for
(
int
j
=
0
;
j
<
numTypes
;
j
++
)
allowedTypes
[
i
].
insert
(
j
);
allowedTypes
[
i
].
insert
(
j
);
else
{
else
{
for
(
set
<
int
>::
const_iterator
iter
=
types
.
begin
();
iter
!=
types
.
end
();
++
iter
)
for
(
int
type
:
types
)
if
(
typeMap
.
find
(
*
iter
)
!=
typeMap
.
end
())
if
(
typeMap
.
find
(
type
)
!=
typeMap
.
end
())
allowedTypes
[
i
].
insert
(
typeMap
[
*
iter
]);
allowedTypes
[
i
].
insert
(
typeMap
[
type
]);
if
(
allowedTypes
[
i
].
size
()
<
numTypes
)
if
(
allowedTypes
[
i
].
size
()
<
numTypes
)
anyFilters
=
true
;
anyFilters
=
true
;
}
}
...
...
openmmapi/src/CustomNonbondedForce.cpp
View file @
6ed5bc4e
...
@@ -70,8 +70,8 @@ CustomNonbondedForce::CustomNonbondedForce(const CustomNonbondedForce& rhs) {
...
@@ -70,8 +70,8 @@ CustomNonbondedForce::CustomNonbondedForce(const CustomNonbondedForce& rhs) {
}
}
CustomNonbondedForce
::~
CustomNonbondedForce
()
{
CustomNonbondedForce
::~
CustomNonbondedForce
()
{
for
(
int
i
=
0
;
i
<
(
int
)
functions
.
size
();
i
++
)
for
(
auto
function
:
functions
)
delete
function
s
[
i
]
.
function
;
delete
function
.
function
;
}
}
const
string
&
CustomNonbondedForce
::
getEnergyFunction
()
const
{
const
string
&
CustomNonbondedForce
::
getEnergyFunction
()
const
{
...
@@ -87,6 +87,8 @@ CustomNonbondedForce::NonbondedMethod CustomNonbondedForce::getNonbondedMethod()
...
@@ -87,6 +87,8 @@ CustomNonbondedForce::NonbondedMethod CustomNonbondedForce::getNonbondedMethod()
}
}
void
CustomNonbondedForce
::
setNonbondedMethod
(
NonbondedMethod
method
)
{
void
CustomNonbondedForce
::
setNonbondedMethod
(
NonbondedMethod
method
)
{
if
(
method
<
0
||
method
>
2
)
throw
OpenMMException
(
"CustomNonbondedForce: Illegal value for nonbonded method"
);
nonbondedMethod
=
method
;
nonbondedMethod
=
method
;
}
}
...
@@ -210,14 +212,14 @@ void CustomNonbondedForce::setExclusionParticles(int index, int particle1, int p
...
@@ -210,14 +212,14 @@ void CustomNonbondedForce::setExclusionParticles(int index, int particle1, int p
void
CustomNonbondedForce
::
createExclusionsFromBonds
(
const
vector
<
pair
<
int
,
int
>
>&
bonds
,
int
bondCutoff
)
{
void
CustomNonbondedForce
::
createExclusionsFromBonds
(
const
vector
<
pair
<
int
,
int
>
>&
bonds
,
int
bondCutoff
)
{
if
(
bondCutoff
<
1
)
if
(
bondCutoff
<
1
)
return
;
return
;
for
(
int
i
=
0
;
i
<
(
int
)
bonds
.
size
();
++
i
)
for
(
auto
&
bond
:
bonds
)
if
(
bond
s
[
i
]
.
first
<
0
||
bond
s
[
i
]
.
second
<
0
||
bond
s
[
i
]
.
first
>=
particles
.
size
()
||
bond
s
[
i
]
.
second
>=
particles
.
size
())
if
(
bond
.
first
<
0
||
bond
.
second
<
0
||
bond
.
first
>=
particles
.
size
()
||
bond
.
second
>=
particles
.
size
())
throw
OpenMMException
(
"createExclusionsFromBonds: Illegal particle index in list of bonds"
);
throw
OpenMMException
(
"createExclusionsFromBonds: Illegal particle index in list of bonds"
);
vector
<
set
<
int
>
>
exclusions
(
particles
.
size
());
vector
<
set
<
int
>
>
exclusions
(
particles
.
size
());
vector
<
set
<
int
>
>
bonded12
(
exclusions
.
size
());
vector
<
set
<
int
>
>
bonded12
(
exclusions
.
size
());
for
(
int
i
=
0
;
i
<
(
int
)
bonds
.
size
();
++
i
)
{
for
(
auto
&
bond
:
bonds
)
{
int
p1
=
bond
s
[
i
]
.
first
;
int
p1
=
bond
.
first
;
int
p2
=
bond
s
[
i
]
.
second
;
int
p2
=
bond
.
second
;
exclusions
[
p1
].
insert
(
p2
);
exclusions
[
p1
].
insert
(
p2
);
exclusions
[
p2
].
insert
(
p1
);
exclusions
[
p2
].
insert
(
p1
);
bonded12
[
p1
].
insert
(
p2
);
bonded12
[
p1
].
insert
(
p2
);
...
@@ -225,15 +227,14 @@ void CustomNonbondedForce::createExclusionsFromBonds(const vector<pair<int, int>
...
@@ -225,15 +227,14 @@ void CustomNonbondedForce::createExclusionsFromBonds(const vector<pair<int, int>
}
}
for
(
int
level
=
0
;
level
<
bondCutoff
-
1
;
level
++
)
{
for
(
int
level
=
0
;
level
<
bondCutoff
-
1
;
level
++
)
{
vector
<
set
<
int
>
>
currentExclusions
=
exclusions
;
vector
<
set
<
int
>
>
currentExclusions
=
exclusions
;
for
(
int
i
=
0
;
i
<
(
int
)
particles
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
particles
.
size
();
i
++
)
for
(
set
<
int
>::
const_iterator
iter
=
currentExclusions
[
i
].
begin
();
iter
!=
currentExclusions
[
i
].
end
();
++
iter
)
for
(
int
j
:
currentExclusions
[
i
])
exclusions
[
*
iter
].
insert
(
bonded12
[
i
].
begin
(),
bonded12
[
i
].
end
());
exclusions
[
j
].
insert
(
bonded12
[
i
].
begin
(),
bonded12
[
i
].
end
());
}
}
}
for
(
int
i
=
0
;
i
<
(
int
)
exclusions
.
size
();
++
i
)
for
(
int
i
=
0
;
i
<
(
int
)
exclusions
.
size
();
++
i
)
for
(
set
<
int
>::
const_iterator
iter
=
exclusions
[
i
].
begin
();
iter
!=
exclusions
[
i
].
end
();
++
iter
)
for
(
int
j
:
exclusions
[
i
]
)
if
(
*
iter
<
i
)
if
(
j
<
i
)
addExclusion
(
*
iter
,
i
);
addExclusion
(
j
,
i
);
}
}
int
CustomNonbondedForce
::
addTabulatedFunction
(
const
std
::
string
&
name
,
TabulatedFunction
*
function
)
{
int
CustomNonbondedForce
::
addTabulatedFunction
(
const
std
::
string
&
name
,
TabulatedFunction
*
function
)
{
...
...
openmmapi/src/Force.cpp
View file @
6ed5bc4e
...
@@ -54,18 +54,16 @@ bool Force::usesPeriodicBoundaryConditions() const {
...
@@ -54,18 +54,16 @@ bool Force::usesPeriodicBoundaryConditions() const {
}
}
ForceImpl
&
Force
::
getImplInContext
(
Context
&
context
)
{
ForceImpl
&
Force
::
getImplInContext
(
Context
&
context
)
{
const
vector
<
ForceImpl
*>&
impls
=
context
.
getImpl
().
getForceImpls
();
for
(
auto
impl
:
context
.
getImpl
().
getForceImpls
())
for
(
int
i
=
0
;
i
<
(
int
)
impls
.
size
();
i
++
)
if
(
&
impl
->
getOwner
()
==
this
)
if
(
&
impls
[
i
]
->
getOwner
()
==
this
)
return
*
impl
;
return
*
impls
[
i
];
throw
OpenMMException
(
"getImplInContext: This Force is not present in the Context"
);
throw
OpenMMException
(
"getImplInContext: This Force is not present in the Context"
);
}
}
const
ForceImpl
&
Force
::
getImplInContext
(
const
Context
&
context
)
const
{
const
ForceImpl
&
Force
::
getImplInContext
(
const
Context
&
context
)
const
{
const
vector
<
ForceImpl
*>&
impls
=
context
.
getImpl
().
getForceImpls
();
for
(
auto
impl
:
context
.
getImpl
().
getForceImpls
())
for
(
int
i
=
0
;
i
<
(
int
)
impls
.
size
();
i
++
)
if
(
&
impl
->
getOwner
()
==
this
)
if
(
&
impls
[
i
]
->
getOwner
()
==
this
)
return
*
impl
;
return
*
impls
[
i
];
throw
OpenMMException
(
"getImplInContext: This Force is not present in the Context"
);
throw
OpenMMException
(
"getImplInContext: This Force is not present in the Context"
);
}
}
...
...
openmmapi/src/GBSAOBCForce.cpp
View file @
6ed5bc4e
...
@@ -64,6 +64,8 @@ GBSAOBCForce::NonbondedMethod GBSAOBCForce::getNonbondedMethod() const {
...
@@ -64,6 +64,8 @@ GBSAOBCForce::NonbondedMethod GBSAOBCForce::getNonbondedMethod() const {
}
}
void
GBSAOBCForce
::
setNonbondedMethod
(
NonbondedMethod
method
)
{
void
GBSAOBCForce
::
setNonbondedMethod
(
NonbondedMethod
method
)
{
if
(
method
<
0
||
method
>
2
)
throw
OpenMMException
(
"GBSAOBCForce: Illegal value for nonbonded method"
);
nonbondedMethod
=
method
;
nonbondedMethod
=
method
;
}
}
...
...
openmmapi/src/GayBerneForce.cpp
View file @
6ed5bc4e
...
@@ -55,6 +55,8 @@ GayBerneForce::NonbondedMethod GayBerneForce::getNonbondedMethod() const {
...
@@ -55,6 +55,8 @@ GayBerneForce::NonbondedMethod GayBerneForce::getNonbondedMethod() const {
}
}
void
GayBerneForce
::
setNonbondedMethod
(
NonbondedMethod
method
)
{
void
GayBerneForce
::
setNonbondedMethod
(
NonbondedMethod
method
)
{
if
(
method
<
0
||
method
>
2
)
throw
OpenMMException
(
"GayBerneForce: Illegal value for nonbonded method"
);
nonbondedMethod
=
method
;
nonbondedMethod
=
method
;
}
}
...
...
openmmapi/src/NonbondedForce.cpp
View file @
6ed5bc4e
...
@@ -57,6 +57,8 @@ NonbondedForce::NonbondedMethod NonbondedForce::getNonbondedMethod() const {
...
@@ -57,6 +57,8 @@ NonbondedForce::NonbondedMethod NonbondedForce::getNonbondedMethod() const {
}
}
void
NonbondedForce
::
setNonbondedMethod
(
NonbondedMethod
method
)
{
void
NonbondedForce
::
setNonbondedMethod
(
NonbondedMethod
method
)
{
if
(
method
<
0
||
method
>
5
)
throw
OpenMMException
(
"NonbondedForce: Illegal value for nonbonded method"
);
nonbondedMethod
=
method
;
nonbondedMethod
=
method
;
}
}
...
@@ -203,17 +205,17 @@ ForceImpl* NonbondedForce::createImpl() const {
...
@@ -203,17 +205,17 @@ ForceImpl* NonbondedForce::createImpl() const {
}
}
void
NonbondedForce
::
createExceptionsFromBonds
(
const
vector
<
pair
<
int
,
int
>
>&
bonds
,
double
coulomb14Scale
,
double
lj14Scale
)
{
void
NonbondedForce
::
createExceptionsFromBonds
(
const
vector
<
pair
<
int
,
int
>
>&
bonds
,
double
coulomb14Scale
,
double
lj14Scale
)
{
for
(
int
i
=
0
;
i
<
(
int
)
bonds
.
size
();
++
i
)
for
(
auto
&
bond
:
bonds
)
if
(
bond
s
[
i
]
.
first
<
0
||
bond
s
[
i
]
.
second
<
0
||
bond
s
[
i
]
.
first
>=
particles
.
size
()
||
bond
s
[
i
]
.
second
>=
particles
.
size
())
if
(
bond
.
first
<
0
||
bond
.
second
<
0
||
bond
.
first
>=
particles
.
size
()
||
bond
.
second
>=
particles
.
size
())
throw
OpenMMException
(
"createExceptionsFromBonds: Illegal particle index in list of bonds"
);
throw
OpenMMException
(
"createExceptionsFromBonds: Illegal particle index in list of bonds"
);
// Find particles separated by 1, 2, or 3 bonds.
// Find particles separated by 1, 2, or 3 bonds.
vector
<
set
<
int
>
>
exclusions
(
particles
.
size
());
vector
<
set
<
int
>
>
exclusions
(
particles
.
size
());
vector
<
set
<
int
>
>
bonded12
(
exclusions
.
size
());
vector
<
set
<
int
>
>
bonded12
(
exclusions
.
size
());
for
(
int
i
=
0
;
i
<
(
int
)
bonds
.
size
();
++
i
)
{
for
(
auto
&
bond
:
bonds
)
{
bonded12
[
bond
s
[
i
]
.
first
].
insert
(
bond
s
[
i
]
.
second
);
bonded12
[
bond
.
first
].
insert
(
bond
.
second
);
bonded12
[
bond
s
[
i
]
.
second
].
insert
(
bond
s
[
i
]
.
first
);
bonded12
[
bond
.
second
].
insert
(
bond
.
first
);
}
}
for
(
int
i
=
0
;
i
<
(
int
)
exclusions
.
size
();
++
i
)
for
(
int
i
=
0
;
i
<
(
int
)
exclusions
.
size
();
++
i
)
addExclusionsToSet
(
bonded12
,
exclusions
[
i
],
i
,
i
,
2
);
addExclusionsToSet
(
bonded12
,
exclusions
[
i
],
i
,
i
,
2
);
...
@@ -223,33 +225,34 @@ void NonbondedForce::createExceptionsFromBonds(const vector<pair<int, int> >& bo
...
@@ -223,33 +225,34 @@ void NonbondedForce::createExceptionsFromBonds(const vector<pair<int, int> >& bo
for
(
int
i
=
0
;
i
<
(
int
)
exclusions
.
size
();
++
i
)
{
for
(
int
i
=
0
;
i
<
(
int
)
exclusions
.
size
();
++
i
)
{
set
<
int
>
bonded13
;
set
<
int
>
bonded13
;
addExclusionsToSet
(
bonded12
,
bonded13
,
i
,
i
,
1
);
addExclusionsToSet
(
bonded12
,
bonded13
,
i
,
i
,
1
);
for
(
set
<
int
>::
const_iterator
iter
=
exclusions
[
i
].
begin
();
iter
!=
exclusions
[
i
].
end
();
++
iter
)
for
(
int
j
:
exclusions
[
i
])
{
if
(
*
iter
<
i
)
{
if
(
j
<
i
)
{
if
(
bonded13
.
find
(
*
iter
)
==
bonded13
.
end
())
{
if
(
bonded13
.
find
(
j
)
==
bonded13
.
end
())
{
// This is a 1-4 interaction.
// This is a 1-4 interaction.
const
ParticleInfo
&
particle1
=
particles
[
*
iter
];
const
ParticleInfo
&
particle1
=
particles
[
j
];
const
ParticleInfo
&
particle2
=
particles
[
i
];
const
ParticleInfo
&
particle2
=
particles
[
i
];
const
double
chargeProd
=
coulomb14Scale
*
particle1
.
charge
*
particle2
.
charge
;
const
double
chargeProd
=
coulomb14Scale
*
particle1
.
charge
*
particle2
.
charge
;
const
double
sigma
=
0.5
*
(
particle1
.
sigma
+
particle2
.
sigma
);
const
double
sigma
=
0.5
*
(
particle1
.
sigma
+
particle2
.
sigma
);
const
double
epsilon
=
lj14Scale
*
std
::
sqrt
(
particle1
.
epsilon
*
particle2
.
epsilon
);
const
double
epsilon
=
lj14Scale
*
std
::
sqrt
(
particle1
.
epsilon
*
particle2
.
epsilon
);
addException
(
*
iter
,
i
,
chargeProd
,
sigma
,
epsilon
);
addException
(
j
,
i
,
chargeProd
,
sigma
,
epsilon
);
}
}
else
{
else
{
// This interaction should be completely excluded.
// This interaction should be completely excluded.
addException
(
*
iter
,
i
,
0.0
,
1.0
,
0.0
);
addException
(
j
,
i
,
0.0
,
1.0
,
0.0
);
}
}
}
}
}
}
}
}
}
void
NonbondedForce
::
addExclusionsToSet
(
const
vector
<
set
<
int
>
>&
bonded12
,
set
<
int
>&
exclusions
,
int
baseParticle
,
int
fromParticle
,
int
currentLevel
)
const
{
void
NonbondedForce
::
addExclusionsToSet
(
const
vector
<
set
<
int
>
>&
bonded12
,
set
<
int
>&
exclusions
,
int
baseParticle
,
int
fromParticle
,
int
currentLevel
)
const
{
for
(
set
<
int
>::
const_iterator
iter
=
bonded12
[
fromParticle
].
begin
();
iter
!=
bonded12
[
fromParticle
]
.
end
();
++
iter
)
{
for
(
int
i
:
bonded12
[
fromParticle
])
{
if
(
*
iter
!=
baseParticle
)
if
(
i
!=
baseParticle
)
exclusions
.
insert
(
*
iter
);
exclusions
.
insert
(
i
);
if
(
currentLevel
>
0
)
if
(
currentLevel
>
0
)
addExclusionsToSet
(
bonded12
,
exclusions
,
baseParticle
,
*
iter
,
currentLevel
-
1
);
addExclusionsToSet
(
bonded12
,
exclusions
,
baseParticle
,
i
,
currentLevel
-
1
);
}
}
}
}
...
...
openmmapi/src/System.cpp
View file @
6ed5bc4e
...
@@ -45,10 +45,10 @@ System::System() {
...
@@ -45,10 +45,10 @@ System::System() {
}
}
System
::~
System
()
{
System
::~
System
()
{
for
(
int
i
=
0
;
i
<
(
int
)
forces
.
size
();
++
i
)
for
(
auto
force
:
forces
)
delete
force
s
[
i
]
;
delete
force
;
for
(
int
i
=
0
;
i
<
(
int
)
virtualSites
.
size
();
++
i
)
for
(
auto
site
:
virtualSites
)
delete
virtualSites
[
i
]
;
delete
site
;
}
}
double
System
::
getParticleMass
(
int
index
)
const
{
double
System
::
getParticleMass
(
int
index
)
const
{
...
...
openmmapi/src/ThreadPool.cpp
View file @
6ed5bc4e
...
@@ -89,13 +89,13 @@ ThreadPool::ThreadPool(int numThreads) : currentTask(NULL) {
...
@@ -89,13 +89,13 @@ ThreadPool::ThreadPool(int numThreads) : currentTask(NULL) {
}
}
ThreadPool
::~
ThreadPool
()
{
ThreadPool
::~
ThreadPool
()
{
for
(
int
i
=
0
;
i
<
(
int
)
threadData
.
size
();
i
++
)
for
(
auto
data
:
threadData
)
threadData
[
i
]
->
isDeleted
=
true
;
data
->
isDeleted
=
true
;
pthread_mutex_lock
(
&
lock
);
pthread_mutex_lock
(
&
lock
);
pthread_cond_broadcast
(
&
startCondition
);
pthread_cond_broadcast
(
&
startCondition
);
pthread_mutex_unlock
(
&
lock
);
pthread_mutex_unlock
(
&
lock
);
for
(
int
i
=
0
;
i
<
(
int
)
thread
.
size
();
i
++
)
for
(
auto
t
:
thread
)
pthread_join
(
t
hread
[
i
]
,
NULL
);
pthread_join
(
t
,
NULL
);
pthread_mutex_destroy
(
&
lock
);
pthread_mutex_destroy
(
&
lock
);
pthread_cond_destroy
(
&
startCondition
);
pthread_cond_destroy
(
&
startCondition
);
pthread_cond_destroy
(
&
endCondition
);
pthread_cond_destroy
(
&
endCondition
);
...
...
platforms/cpu/src/CpuBondForce.cpp
View file @
6ed5bc4e
...
@@ -159,8 +159,8 @@ void CpuBondForce::assignBond(int bond, int thread, vector<int>& atomThread, vec
...
@@ -159,8 +159,8 @@ void CpuBondForce::assignBond(int bond, int thread, vector<int>& atomThread, vec
if
(
atom
!=
-
1
)
if
(
atom
!=
-
1
)
throw
OpenMMException
(
"CpuBondForce: Internal error: atoms assigned to threads incorrectly"
);
throw
OpenMMException
(
"CpuBondForce: Internal error: atoms assigned to threads incorrectly"
);
atom
=
thread
;
atom
=
thread
;
for
(
set
<
int
>::
const_iterator
iter
=
atomBonds
[
atom
].
begin
();
iter
!=
atomBonds
[
atom
]
.
end
();
++
iter
)
for
(
int
bond
:
atomBonds
[
atom
])
candidateBonds
.
push_back
(
*
iter
);
candidateBonds
.
push_back
(
bond
);
}
}
}
}
...
...
platforms/cpu/src/CpuCustomGBForce.cpp
View file @
6ed5bc4e
...
@@ -74,48 +74,48 @@ CpuCustomGBForce::ThreadData::ThreadData(int numAtoms, int numThreads, int threa
...
@@ -74,48 +74,48 @@ CpuCustomGBForce::ThreadData::ThreadData(int numAtoms, int numThreads, int threa
variableLocations
[
name
.
str
()]
=
&
particleValue
[
2
*
i
+
j
];
variableLocations
[
name
.
str
()]
=
&
particleValue
[
2
*
i
+
j
];
}
}
}
}
for
(
int
i
=
0
;
i
<
(
int
)
valueExpressions
.
size
();
i
++
)
{
for
(
auto
&
expression
:
this
->
valueExpressions
)
{
this
->
valueE
xpression
s
[
i
]
.
setVariableLocations
(
variableLocations
);
e
xpression
.
setVariableLocations
(
variableLocations
);
expressionSet
.
registerExpression
(
this
->
valueE
xpression
s
[
i
]
);
expressionSet
.
registerExpression
(
e
xpression
);
}
}
for
(
int
i
=
0
;
i
<
(
int
)
valueDerivExpressions
.
size
();
i
++
)
for
(
auto
&
expressions
:
this
->
valueDerivExpressions
)
for
(
int
j
=
0
;
j
<
(
int
)
valueDerivExpressions
[
i
].
size
();
j
++
)
{
for
(
auto
&
expression
:
expressions
)
{
this
->
valueDerivE
xpression
s
[
i
][
j
]
.
setVariableLocations
(
variableLocations
);
e
xpression
.
setVariableLocations
(
variableLocations
);
expressionSet
.
registerExpression
(
this
->
valueDerivE
xpression
s
[
i
][
j
]
);
expressionSet
.
registerExpression
(
e
xpression
);
}
}
for
(
int
i
=
0
;
i
<
(
int
)
valueGradientExpressions
.
size
();
i
++
)
for
(
auto
&
expressions
:
this
->
valueGradientExpressions
)
for
(
int
j
=
0
;
j
<
(
int
)
valueGradientExpressions
[
i
].
size
();
j
++
)
{
for
(
auto
&
expression
:
expressions
)
{
this
->
valueGradientE
xpression
s
[
i
][
j
]
.
setVariableLocations
(
variableLocations
);
e
xpression
.
setVariableLocations
(
variableLocations
);
expressionSet
.
registerExpression
(
this
->
valueGradientE
xpression
s
[
i
][
j
]
);
expressionSet
.
registerExpression
(
e
xpression
);
}
}
for
(
int
i
=
0
;
i
<
(
int
)
valueParamDerivExpressions
.
size
();
i
++
)
for
(
auto
&
expressions
:
this
->
valueParamDerivExpressions
)
for
(
int
j
=
0
;
j
<
(
int
)
valueParamDerivExpressions
[
i
].
size
();
j
++
)
{
for
(
auto
&
expression
:
expressions
)
{
this
->
valueParamDerivE
xpression
s
[
i
][
j
]
.
setVariableLocations
(
variableLocations
);
e
xpression
.
setVariableLocations
(
variableLocations
);
expressionSet
.
registerExpression
(
this
->
valueParamDerivE
xpression
s
[
i
][
j
]
);
expressionSet
.
registerExpression
(
e
xpression
);
}
}
for
(
int
i
=
0
;
i
<
(
int
)
energyExpressions
.
size
();
i
++
)
{
for
(
auto
&
expression
:
this
->
energyExpressions
)
{
this
->
energyE
xpression
s
[
i
]
.
setVariableLocations
(
variableLocations
);
e
xpression
.
setVariableLocations
(
variableLocations
);
expressionSet
.
registerExpression
(
this
->
energyE
xpression
s
[
i
]
);
expressionSet
.
registerExpression
(
e
xpression
);
}
}
for
(
int
i
=
0
;
i
<
(
int
)
energyDerivExpressions
.
size
();
i
++
)
for
(
auto
&
expressions
:
this
->
energyDerivExpressions
)
for
(
int
j
=
0
;
j
<
(
int
)
energyDerivExpressions
[
i
].
size
();
j
++
)
{
for
(
auto
&
expression
:
expressions
)
{
this
->
energyDerivE
xpression
s
[
i
][
j
]
.
setVariableLocations
(
variableLocations
);
e
xpression
.
setVariableLocations
(
variableLocations
);
expressionSet
.
registerExpression
(
this
->
energyDerivE
xpression
s
[
i
][
j
]
);
expressionSet
.
registerExpression
(
e
xpression
);
}
}
for
(
int
i
=
0
;
i
<
(
int
)
energyGradientExpressions
.
size
();
i
++
)
for
(
auto
&
expressions
:
this
->
energyGradientExpressions
)
for
(
int
j
=
0
;
j
<
(
int
)
energyGradientExpressions
[
i
].
size
();
j
++
)
{
for
(
auto
&
expression
:
expressions
)
{
this
->
energyGradientE
xpression
s
[
i
][
j
]
.
setVariableLocations
(
variableLocations
);
e
xpression
.
setVariableLocations
(
variableLocations
);
expressionSet
.
registerExpression
(
this
->
energyGradientE
xpression
s
[
i
][
j
]
);
expressionSet
.
registerExpression
(
e
xpression
);
}
}
for
(
int
i
=
0
;
i
<
(
int
)
energyParamDerivExpressions
.
size
();
i
++
)
for
(
auto
&
expressions
:
this
->
energyParamDerivExpressions
)
for
(
int
j
=
0
;
j
<
(
int
)
energyParamDerivExpressions
[
i
].
size
();
j
++
)
{
for
(
auto
&
expression
:
expressions
)
{
this
->
energyParamDerivE
xpression
s
[
i
][
j
]
.
setVariableLocations
(
variableLocations
);
e
xpression
.
setVariableLocations
(
variableLocations
);
expressionSet
.
registerExpression
(
this
->
energyParamDerivE
xpression
s
[
i
][
j
]
);
expressionSet
.
registerExpression
(
e
xpression
);
}
}
value0
.
resize
(
numAtoms
);
value0
.
resize
(
numAtoms
);
dEdV
.
resize
(
valueNames
.
size
());
dEdV
.
resize
(
valueNames
.
size
());
for
(
int
i
=
0
;
i
<
(
int
)
dEdV
.
size
();
i
++
)
for
(
auto
&
v
:
dEdV
)
dEdV
[
i
]
.
resize
(
numAtoms
);
v
.
resize
(
numAtoms
);
dVdX
.
resize
(
valueDerivExpressions
.
size
());
dVdX
.
resize
(
valueDerivExpressions
.
size
());
dVdY
.
resize
(
valueDerivExpressions
.
size
());
dVdY
.
resize
(
valueDerivExpressions
.
size
());
dVdZ
.
resize
(
valueDerivExpressions
.
size
());
dVdZ
.
resize
(
valueDerivExpressions
.
size
());
...
@@ -155,8 +155,8 @@ CpuCustomGBForce::CpuCustomGBForce(int numAtoms, const std::vector<std::set<int>
...
@@ -155,8 +155,8 @@ CpuCustomGBForce::CpuCustomGBForce(int numAtoms, const std::vector<std::set<int>
}
}
CpuCustomGBForce
::~
CpuCustomGBForce
()
{
CpuCustomGBForce
::~
CpuCustomGBForce
()
{
for
(
int
i
=
0
;
i
<
(
int
)
threadData
.
size
();
i
++
)
for
(
auto
data
:
threadData
)
delete
threadData
[
i
]
;
delete
data
;
}
}
void
CpuCustomGBForce
::
setUseCutoff
(
float
distance
,
const
CpuNeighborList
&
neighbors
)
{
void
CpuCustomGBForce
::
setUseCutoff
(
float
distance
,
const
CpuNeighborList
&
neighbors
)
{
...
@@ -256,16 +256,16 @@ void CpuCustomGBForce::threadComputeForce(ThreadPool& threads, int threadIndex)
...
@@ -256,16 +256,16 @@ void CpuCustomGBForce::threadComputeForce(ThreadPool& threads, int threadIndex)
ThreadData
&
data
=
*
threadData
[
threadIndex
];
ThreadData
&
data
=
*
threadData
[
threadIndex
];
fvec4
boxSize
(
periodicBoxSize
[
0
],
periodicBoxSize
[
1
],
periodicBoxSize
[
2
],
0
);
fvec4
boxSize
(
periodicBoxSize
[
0
],
periodicBoxSize
[
1
],
periodicBoxSize
[
2
],
0
);
fvec4
invBoxSize
((
1
/
periodicBoxSize
[
0
]),
(
1
/
periodicBoxSize
[
1
]),
(
1
/
periodicBoxSize
[
2
]),
0
);
fvec4
invBoxSize
((
1
/
periodicBoxSize
[
0
]),
(
1
/
periodicBoxSize
[
1
]),
(
1
/
periodicBoxSize
[
2
]),
0
);
for
(
map
<
string
,
double
>::
const_iterator
iter
=
globalParameters
->
begin
();
iter
!=
globalParameters
->
end
();
++
iter
)
for
(
auto
&
param
:
*
globalParameters
)
data
.
expressionSet
.
setVariable
(
data
.
expressionSet
.
getVariableIndex
(
iter
->
first
),
iter
->
second
);
data
.
expressionSet
.
setVariable
(
data
.
expressionSet
.
getVariableIndex
(
param
.
first
),
param
.
second
);
// Calculate the first computed value.
// Calculate the first computed value.
for
(
int
i
=
0
;
i
<
(
int
)
data
.
value0
.
size
();
i
++
)
for
(
auto
&
v
:
data
.
value0
)
data
.
value0
[
i
]
=
0.0
f
;
v
=
0.0
f
;
for
(
int
i
=
0
;
i
<
(
int
)
data
.
dValue0dParam
.
size
();
i
++
)
for
(
auto
&
vals
:
data
.
dValue0dParam
)
for
(
int
j
=
0
;
j
<
(
int
)
data
.
dValue0dParam
[
i
].
size
();
j
++
)
for
(
auto
&
v
:
vals
)
data
.
dValue0dParam
[
i
][
j
]
=
0.0
;
v
=
0.0
f
;
if
(
valueTypes
[
0
]
==
CustomGBForce
::
ParticlePair
)
if
(
valueTypes
[
0
]
==
CustomGBForce
::
ParticlePair
)
calculateParticlePairValue
(
0
,
data
,
numberOfAtoms
,
posq
,
atomParameters
,
true
,
boxSize
,
invBoxSize
);
calculateParticlePairValue
(
0
,
data
,
numberOfAtoms
,
posq
,
atomParameters
,
true
,
boxSize
,
invBoxSize
);
else
else
...
@@ -291,8 +291,8 @@ void CpuCustomGBForce::threadComputeForce(ThreadPool& threads, int threadIndex)
...
@@ -291,8 +291,8 @@ void CpuCustomGBForce::threadComputeForce(ThreadPool& threads, int threadIndex)
int
numValues
=
valueTypes
.
size
();
int
numValues
=
valueTypes
.
size
();
for
(
int
atom
=
data
.
firstAtom
;
atom
<
data
.
lastAtom
;
atom
++
)
{
for
(
int
atom
=
data
.
firstAtom
;
atom
<
data
.
lastAtom
;
atom
++
)
{
float
sum
=
0.0
f
;
float
sum
=
0.0
f
;
for
(
int
j
=
0
;
j
<
(
int
)
threadData
.
size
();
j
++
)
for
(
auto
&
data
:
threadData
)
sum
+=
threadData
[
j
]
->
value0
[
atom
];
sum
+=
data
->
value0
[
atom
];
values
[
0
][
atom
]
=
sum
;
values
[
0
][
atom
]
=
sum
;
data
.
x
=
posq
[
4
*
atom
];
data
.
x
=
posq
[
4
*
atom
];
data
.
y
=
posq
[
4
*
atom
+
1
];
data
.
y
=
posq
[
4
*
atom
+
1
];
...
@@ -320,11 +320,11 @@ void CpuCustomGBForce::threadComputeForce(ThreadPool& threads, int threadIndex)
...
@@ -320,11 +320,11 @@ void CpuCustomGBForce::threadComputeForce(ThreadPool& threads, int threadIndex)
// Now calculate the energy and its derivatives.
// Now calculate the energy and its derivatives.
for
(
int
i
=
0
;
i
<
(
int
)
data
.
dEdV
.
size
();
i
++
)
for
(
auto
&
vals
:
data
.
dEdV
)
for
(
int
j
=
0
;
j
<
(
int
)
data
.
dEdV
[
i
].
size
();
j
++
)
for
(
auto
&
v
:
vals
)
data
.
dEdV
[
i
][
j
]
=
0.0
f
;
v
=
0.0
f
;
for
(
int
i
=
0
;
i
<
(
int
)
data
.
energyParamDerivs
.
size
();
i
++
)
for
(
auto
&
v
:
data
.
energyParamDerivs
)
data
.
energyParamDerivs
[
i
]
=
0.0
f
;
v
=
0.0
f
;
for
(
int
termIndex
=
0
;
termIndex
<
(
int
)
data
.
energyExpressions
.
size
();
termIndex
++
)
{
for
(
int
termIndex
=
0
;
termIndex
<
(
int
)
data
.
energyExpressions
.
size
();
termIndex
++
)
{
if
(
energyTypes
[
termIndex
]
==
CustomGBForce
::
SingleParticle
)
if
(
energyTypes
[
termIndex
]
==
CustomGBForce
::
SingleParticle
)
calculateSingleParticleEnergyTerm
(
termIndex
,
data
,
numberOfAtoms
,
posq
,
atomParameters
,
forces
,
energy
);
calculateSingleParticleEnergyTerm
(
termIndex
,
data
,
numberOfAtoms
,
posq
,
atomParameters
,
forces
,
energy
);
...
@@ -340,8 +340,8 @@ void CpuCustomGBForce::threadComputeForce(ThreadPool& threads, int threadIndex)
...
@@ -340,8 +340,8 @@ void CpuCustomGBForce::threadComputeForce(ThreadPool& threads, int threadIndex)
for
(
int
atom
=
data
.
firstAtom
;
atom
<
data
.
lastAtom
;
atom
++
)
{
for
(
int
atom
=
data
.
firstAtom
;
atom
<
data
.
lastAtom
;
atom
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
dEdV
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
dEdV
.
size
();
i
++
)
{
float
sum
=
0.0
f
;
float
sum
=
0.0
f
;
for
(
int
j
=
0
;
j
<
(
int
)
threadData
.
size
();
j
++
)
for
(
auto
&
data
:
threadData
)
sum
+=
threadData
[
j
]
->
dEdV
[
i
][
atom
];
sum
+=
data
->
dEdV
[
i
][
atom
];
dEdV
[
i
][
atom
]
=
sum
;
dEdV
[
i
][
atom
]
=
sum
;
}
}
}
}
...
...
platforms/cpu/src/CpuCustomManyParticleForce.cpp
View file @
6ed5bc4e
...
@@ -63,8 +63,8 @@ CpuCustomManyParticleForce::CpuCustomManyParticleForce(const CustomManyParticleF
...
@@ -63,8 +63,8 @@ CpuCustomManyParticleForce::CpuCustomManyParticleForce(const CustomManyParticleF
// Delete the custom functions.
// Delete the custom functions.
for
(
map
<
string
,
Lepton
::
CustomFunction
*>::
iterator
iter
=
functions
.
begin
();
iter
!=
functions
.
end
();
iter
++
)
for
(
auto
&
function
:
functions
)
delete
iter
->
second
;
delete
function
.
second
;
// Record exclusions.
// Record exclusions.
...
@@ -84,8 +84,8 @@ CpuCustomManyParticleForce::CpuCustomManyParticleForce(const CustomManyParticleF
...
@@ -84,8 +84,8 @@ CpuCustomManyParticleForce::CpuCustomManyParticleForce(const CustomManyParticleF
CpuCustomManyParticleForce
::~
CpuCustomManyParticleForce
()
{
CpuCustomManyParticleForce
::~
CpuCustomManyParticleForce
()
{
if
(
neighborList
!=
NULL
)
if
(
neighborList
!=
NULL
)
delete
neighborList
;
delete
neighborList
;
for
(
int
i
=
0
;
i
<
(
int
)
threadData
.
size
();
i
++
)
for
(
auto
data
:
threadData
)
delete
threadData
[
i
]
;
delete
data
;
}
}
void
CpuCustomManyParticleForce
::
calculateIxn
(
AlignedArray
<
float
>&
posq
,
double
**
particleParameters
,
void
CpuCustomManyParticleForce
::
calculateIxn
(
AlignedArray
<
float
>&
posq
,
double
**
particleParameters
,
...
@@ -150,8 +150,8 @@ void CpuCustomManyParticleForce::threadComputeForce(ThreadPool& threads, int thr
...
@@ -150,8 +150,8 @@ void CpuCustomManyParticleForce::threadComputeForce(ThreadPool& threads, int thr
float
*
forces
=
&
(
*
threadForce
)[
threadIndex
][
0
];
float
*
forces
=
&
(
*
threadForce
)[
threadIndex
][
0
];
ThreadData
&
data
=
*
threadData
[
threadIndex
];
ThreadData
&
data
=
*
threadData
[
threadIndex
];
data
.
energy
=
0
;
data
.
energy
=
0
;
for
(
map
<
string
,
double
>::
const_iterator
iter
=
globalParameters
->
begin
();
iter
!=
globalParameters
->
end
();
++
iter
)
for
(
auto
&
param
:
*
globalParameters
)
data
.
expressionSet
.
setVariable
(
data
.
expressionSet
.
getVariableIndex
(
iter
->
first
),
iter
->
second
);
data
.
expressionSet
.
setVariable
(
data
.
expressionSet
.
getVariableIndex
(
param
.
first
),
param
.
second
);
if
(
useCutoff
)
{
if
(
useCutoff
)
{
// Loop over interactions from the neighbor list.
// Loop over interactions from the neighbor list.
...
@@ -287,18 +287,12 @@ void CpuCustomManyParticleForce::calculateOneIxn(vector<int>& particleSet, doubl
...
@@ -287,18 +287,12 @@ void CpuCustomManyParticleForce::calculateOneIxn(vector<int>& particleSet, doubl
// Compute all of the variables the energy can depend on.
// Compute all of the variables the energy can depend on.
for
(
int
i
=
0
;
i
<
(
int
)
data
.
particleTerms
.
size
();
i
++
)
{
for
(
auto
&
term
:
data
.
particleTerms
)
const
ParticleTermInfo
&
term
=
data
.
particleTerms
[
i
];
expressionSet
.
setVariable
(
term
.
variableIndex
,
posq
[
4
*
permutedParticles
[
term
.
atom
]
+
term
.
component
]);
expressionSet
.
setVariable
(
term
.
variableIndex
,
posq
[
4
*
permutedParticles
[
term
.
atom
]
+
term
.
component
]);
}
for
(
auto
&
term
:
data
.
distanceTerms
)
for
(
int
i
=
0
;
i
<
(
int
)
data
.
distanceTerms
.
size
();
i
++
)
{
const
DistanceTermInfo
&
term
=
data
.
distanceTerms
[
i
];
expressionSet
.
setVariable
(
term
.
variableIndex
,
normDelta
[
term
.
delta
]);
expressionSet
.
setVariable
(
term
.
variableIndex
,
normDelta
[
term
.
delta
]);
}
for
(
auto
&
term
:
data
.
angleTerms
)
for
(
int
i
=
0
;
i
<
(
int
)
data
.
angleTerms
.
size
();
i
++
)
{
const
AngleTermInfo
&
term
=
data
.
angleTerms
[
i
];
expressionSet
.
setVariable
(
term
.
variableIndex
,
computeAngle
(
delta
[
term
.
delta1
],
delta
[
term
.
delta2
],
norm2Delta
[
term
.
delta1
],
norm2Delta
[
term
.
delta2
],
term
.
delta1Sign
*
term
.
delta2Sign
));
expressionSet
.
setVariable
(
term
.
variableIndex
,
computeAngle
(
delta
[
term
.
delta1
],
delta
[
term
.
delta2
],
norm2Delta
[
term
.
delta1
],
norm2Delta
[
term
.
delta2
],
term
.
delta1Sign
*
term
.
delta2Sign
));
}
for
(
int
i
=
0
;
i
<
(
int
)
data
.
dihedralTerms
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
data
.
dihedralTerms
.
size
();
i
++
)
{
const
DihedralTermInfo
&
term
=
data
.
dihedralTerms
[
i
];
const
DihedralTermInfo
&
term
=
data
.
dihedralTerms
[
i
];
expressionSet
.
setVariable
(
term
.
variableIndex
,
getDihedralAngleBetweenThreeVectors
(
delta
[
term
.
delta1
],
delta
[
term
.
delta2
],
delta
[
term
.
delta3
],
cross1
[
i
],
cross2
[
i
],
delta
[
term
.
delta1
]));
expressionSet
.
setVariable
(
term
.
variableIndex
,
getDihedralAngleBetweenThreeVectors
(
delta
[
term
.
delta1
],
delta
[
term
.
delta2
],
delta
[
term
.
delta3
],
cross1
[
i
],
cross2
[
i
],
delta
[
term
.
delta1
]));
...
@@ -310,8 +304,7 @@ void CpuCustomManyParticleForce::calculateOneIxn(vector<int>& particleSet, doubl
...
@@ -310,8 +304,7 @@ void CpuCustomManyParticleForce::calculateOneIxn(vector<int>& particleSet, doubl
AlignedArray
<
fvec4
>&
f
=
data
.
f
;
AlignedArray
<
fvec4
>&
f
=
data
.
f
;
for
(
int
i
=
0
;
i
<
numParticlesPerSet
;
i
++
)
for
(
int
i
=
0
;
i
<
numParticlesPerSet
;
i
++
)
f
[
i
]
=
fvec4
(
0.0
f
);
f
[
i
]
=
fvec4
(
0.0
f
);
for
(
int
i
=
0
;
i
<
(
int
)
data
.
particleTerms
.
size
();
i
++
)
{
for
(
auto
&
term
:
data
.
particleTerms
)
{
const
ParticleTermInfo
&
term
=
data
.
particleTerms
[
i
];
float
temp
[
4
];
float
temp
[
4
];
f
[
term
.
atom
].
store
(
temp
);
f
[
term
.
atom
].
store
(
temp
);
temp
[
term
.
component
]
-=
term
.
forceExpression
.
evaluate
();
temp
[
term
.
component
]
-=
term
.
forceExpression
.
evaluate
();
...
@@ -320,8 +313,7 @@ void CpuCustomManyParticleForce::calculateOneIxn(vector<int>& particleSet, doubl
...
@@ -320,8 +313,7 @@ void CpuCustomManyParticleForce::calculateOneIxn(vector<int>& particleSet, doubl
// Apply forces based on distances.
// Apply forces based on distances.
for
(
int
i
=
0
;
i
<
(
int
)
data
.
distanceTerms
.
size
();
i
++
)
{
for
(
auto
&
term
:
data
.
distanceTerms
)
{
const
DistanceTermInfo
&
term
=
data
.
distanceTerms
[
i
];
float
dEdR
=
(
float
)
(
term
.
forceExpression
.
evaluate
()
*
term
.
deltaSign
/
(
normDelta
[
term
.
delta
]));
float
dEdR
=
(
float
)
(
term
.
forceExpression
.
evaluate
()
*
term
.
deltaSign
/
(
normDelta
[
term
.
delta
]));
fvec4
force
=
-
dEdR
*
delta
[
term
.
delta
];
fvec4
force
=
-
dEdR
*
delta
[
term
.
delta
];
f
[
term
.
p1
]
-=
force
;
f
[
term
.
p1
]
-=
force
;
...
@@ -330,8 +322,7 @@ void CpuCustomManyParticleForce::calculateOneIxn(vector<int>& particleSet, doubl
...
@@ -330,8 +322,7 @@ void CpuCustomManyParticleForce::calculateOneIxn(vector<int>& particleSet, doubl
// Apply forces based on angles.
// Apply forces based on angles.
for
(
int
i
=
0
;
i
<
(
int
)
data
.
angleTerms
.
size
();
i
++
)
{
for
(
auto
&
term
:
data
.
angleTerms
)
{
const
AngleTermInfo
&
term
=
data
.
angleTerms
[
i
];
float
dEdTheta
=
(
float
)
term
.
forceExpression
.
evaluate
();
float
dEdTheta
=
(
float
)
term
.
forceExpression
.
evaluate
();
fvec4
thetaCross
=
cross
(
delta
[
term
.
delta1
],
delta
[
term
.
delta2
]);
fvec4
thetaCross
=
cross
(
delta
[
term
.
delta1
],
delta
[
term
.
delta2
]);
float
lengthThetaCross
=
sqrtf
(
dot3
(
thetaCross
,
thetaCross
));
float
lengthThetaCross
=
sqrtf
(
dot3
(
thetaCross
,
thetaCross
));
...
@@ -482,20 +473,20 @@ CpuCustomManyParticleForce::ThreadData::ThreadData(const CustomManyParticleForce
...
@@ -482,20 +473,20 @@ CpuCustomManyParticleForce::ThreadData::ThreadData(const CustomManyParticleForce
particleParamIndices
[
i
].
push_back
(
expressionSet
.
getVariableIndex
(
paramname
.
str
()));
particleParamIndices
[
i
].
push_back
(
expressionSet
.
getVariableIndex
(
paramname
.
str
()));
}
}
}
}
for
(
map
<
string
,
vector
<
int
>
>::
const_iterator
iter
=
dihedrals
.
begin
();
iter
!=
dihedrals
.
end
();
++
iter
)
for
(
auto
&
term
:
dihedrals
)
dihedralTerms
.
push_back
(
CpuCustomManyParticleForce
::
DihedralTermInfo
(
i
ter
->
first
,
i
ter
->
second
,
energyExpr
.
differentiate
(
i
ter
->
first
).
optimize
().
createCompiledExpression
(),
*
this
));
dihedralTerms
.
push_back
(
CpuCustomManyParticleForce
::
DihedralTermInfo
(
ter
m
.
first
,
ter
m
.
second
,
energyExpr
.
differentiate
(
ter
m
.
first
).
optimize
().
createCompiledExpression
(),
*
this
));
for
(
map
<
string
,
vector
<
int
>
>::
const_iterator
iter
=
distances
.
begin
();
iter
!=
distances
.
end
();
++
iter
)
for
(
auto
&
term
:
distances
)
distanceTerms
.
push_back
(
CpuCustomManyParticleForce
::
DistanceTermInfo
(
i
ter
->
first
,
i
ter
->
second
,
energyExpr
.
differentiate
(
i
ter
->
first
).
optimize
().
createCompiledExpression
(),
*
this
));
distanceTerms
.
push_back
(
CpuCustomManyParticleForce
::
DistanceTermInfo
(
ter
m
.
first
,
ter
m
.
second
,
energyExpr
.
differentiate
(
ter
m
.
first
).
optimize
().
createCompiledExpression
(),
*
this
));
for
(
map
<
string
,
vector
<
int
>
>::
const_iterator
iter
=
angles
.
begin
();
iter
!=
angles
.
end
();
++
iter
)
for
(
auto
&
term
:
angles
)
angleTerms
.
push_back
(
CpuCustomManyParticleForce
::
AngleTermInfo
(
i
ter
->
first
,
i
ter
->
second
,
energyExpr
.
differentiate
(
i
ter
->
first
).
optimize
().
createCompiledExpression
(),
*
this
));
angleTerms
.
push_back
(
CpuCustomManyParticleForce
::
AngleTermInfo
(
ter
m
.
first
,
ter
m
.
second
,
energyExpr
.
differentiate
(
ter
m
.
first
).
optimize
().
createCompiledExpression
(),
*
this
));
for
(
int
i
=
0
;
i
<
particleTerms
.
size
();
i
++
)
for
(
auto
&
term
:
particleTerms
)
expressionSet
.
registerExpression
(
particleTerms
[
i
]
.
forceExpression
);
expressionSet
.
registerExpression
(
term
.
forceExpression
);
for
(
int
i
=
0
;
i
<
distanceTerms
.
size
();
i
++
)
for
(
auto
&
term
:
distanceTerms
)
expressionSet
.
registerExpression
(
distanceTerms
[
i
]
.
forceExpression
);
expressionSet
.
registerExpression
(
term
.
forceExpression
);
for
(
int
i
=
0
;
i
<
angleTerms
.
size
();
i
++
)
for
(
auto
&
term
:
angleTerms
)
expressionSet
.
registerExpression
(
angleTerms
[
i
]
.
forceExpression
);
expressionSet
.
registerExpression
(
term
.
forceExpression
);
for
(
int
i
=
0
;
i
<
dihedralTerms
.
size
();
i
++
)
for
(
auto
&
term
:
dihedralTerms
)
expressionSet
.
registerExpression
(
dihedralTerms
[
i
]
.
forceExpression
);
expressionSet
.
registerExpression
(
term
.
forceExpression
);
int
numDeltas
=
deltaPairs
.
size
();
int
numDeltas
=
deltaPairs
.
size
();
delta
.
resize
(
numDeltas
);
delta
.
resize
(
numDeltas
);
normDelta
.
resize
(
numDeltas
);
normDelta
.
resize
(
numDeltas
);
...
...
platforms/cpu/src/CpuCustomNonbondedForce.cpp
View file @
6ed5bc4e
...
@@ -51,9 +51,9 @@ CpuCustomNonbondedForce::ThreadData::ThreadData(const Lepton::CompiledExpression
...
@@ -51,9 +51,9 @@ CpuCustomNonbondedForce::ThreadData::ThreadData(const Lepton::CompiledExpression
this
->
forceExpression
.
setVariableLocations
(
variableLocations
);
this
->
forceExpression
.
setVariableLocations
(
variableLocations
);
expressionSet
.
registerExpression
(
this
->
energyExpression
);
expressionSet
.
registerExpression
(
this
->
energyExpression
);
expressionSet
.
registerExpression
(
this
->
forceExpression
);
expressionSet
.
registerExpression
(
this
->
forceExpression
);
for
(
int
i
=
0
;
i
<
this
->
energyParamDerivExpressions
.
size
();
i
++
)
{
for
(
auto
&
expression
:
this
->
energyParamDerivExpressions
)
{
this
->
energyParamDerivE
xpression
s
[
i
]
.
setVariableLocations
(
variableLocations
);
e
xpression
.
setVariableLocations
(
variableLocations
);
expressionSet
.
registerExpression
(
this
->
energyParamDerivE
xpression
s
[
i
]
);
expressionSet
.
registerExpression
(
e
xpression
);
}
}
}
}
...
@@ -66,8 +66,8 @@ CpuCustomNonbondedForce::CpuCustomNonbondedForce(const Lepton::CompiledExpressio
...
@@ -66,8 +66,8 @@ CpuCustomNonbondedForce::CpuCustomNonbondedForce(const Lepton::CompiledExpressio
}
}
CpuCustomNonbondedForce
::~
CpuCustomNonbondedForce
()
{
CpuCustomNonbondedForce
::~
CpuCustomNonbondedForce
()
{
for
(
int
i
=
0
;
i
<
(
int
)
threadData
.
size
();
i
++
)
for
(
auto
data
:
threadData
)
delete
threadData
[
i
]
;
delete
data
;
}
}
void
CpuCustomNonbondedForce
::
setUseCutoff
(
double
distance
,
const
CpuNeighborList
&
neighbors
)
{
void
CpuCustomNonbondedForce
::
setUseCutoff
(
double
distance
,
const
CpuNeighborList
&
neighbors
)
{
...
@@ -78,9 +78,9 @@ void CpuCustomNonbondedForce::setUseCutoff(double distance, const CpuNeighborLis
...
@@ -78,9 +78,9 @@ void CpuCustomNonbondedForce::setUseCutoff(double distance, const CpuNeighborLis
void
CpuCustomNonbondedForce
::
setInteractionGroups
(
const
vector
<
pair
<
set
<
int
>
,
set
<
int
>
>
>&
groups
)
{
void
CpuCustomNonbondedForce
::
setInteractionGroups
(
const
vector
<
pair
<
set
<
int
>
,
set
<
int
>
>
>&
groups
)
{
useInteractionGroups
=
true
;
useInteractionGroups
=
true
;
for
(
int
group
=
0
;
group
<
(
int
)
groups
.
size
();
group
++
)
{
for
(
auto
&
group
:
groups
)
{
const
set
<
int
>&
set1
=
group
s
[
group
]
.
first
;
const
set
<
int
>&
set1
=
group
.
first
;
const
set
<
int
>&
set2
=
group
s
[
group
]
.
second
;
const
set
<
int
>&
set2
=
group
.
second
;
for
(
set
<
int
>::
const_iterator
atom1
=
set1
.
begin
();
atom1
!=
set1
.
end
();
++
atom1
)
{
for
(
set
<
int
>::
const_iterator
atom1
=
set1
.
begin
();
atom1
!=
set1
.
end
();
++
atom1
)
{
for
(
set
<
int
>::
const_iterator
atom2
=
set2
.
begin
();
atom2
!=
set2
.
end
();
++
atom2
)
{
for
(
set
<
int
>::
const_iterator
atom2
=
set2
.
begin
();
atom2
!=
set2
.
end
();
++
atom2
)
{
if
(
*
atom1
==
*
atom2
||
exclusions
[
*
atom1
].
find
(
*
atom2
)
!=
exclusions
[
*
atom1
].
end
())
if
(
*
atom1
==
*
atom2
||
exclusions
[
*
atom1
].
find
(
*
atom2
)
!=
exclusions
[
*
atom1
].
end
())
...
@@ -167,10 +167,10 @@ void CpuCustomNonbondedForce::threadComputeForce(ThreadPool& threads, int thread
...
@@ -167,10 +167,10 @@ void CpuCustomNonbondedForce::threadComputeForce(ThreadPool& threads, int thread
double
&
energy
=
threadEnergy
[
threadIndex
];
double
&
energy
=
threadEnergy
[
threadIndex
];
float
*
forces
=
&
(
*
threadForce
)[
threadIndex
][
0
];
float
*
forces
=
&
(
*
threadForce
)[
threadIndex
][
0
];
ThreadData
&
data
=
*
threadData
[
threadIndex
];
ThreadData
&
data
=
*
threadData
[
threadIndex
];
for
(
map
<
string
,
double
>::
const_iterator
iter
=
globalParameters
->
begin
();
iter
!=
globalParameters
->
end
();
++
iter
)
for
(
auto
&
param
:
*
globalParameters
)
data
.
expressionSet
.
setVariable
(
data
.
expressionSet
.
getVariableIndex
(
iter
->
first
),
iter
->
second
);
data
.
expressionSet
.
setVariable
(
data
.
expressionSet
.
getVariableIndex
(
param
.
first
),
param
.
second
);
for
(
int
i
=
0
;
i
<
data
.
energyParamDerivs
.
size
();
i
++
)
for
(
auto
&
deriv
:
data
.
energyParamDerivs
)
d
ata
.
energyParamDerivs
[
i
]
=
0.0
;
d
eriv
=
0.0
;
fvec4
boxSize
(
periodicBoxVectors
[
0
][
0
],
periodicBoxVectors
[
1
][
1
],
periodicBoxVectors
[
2
][
2
],
0
);
fvec4
boxSize
(
periodicBoxVectors
[
0
][
0
],
periodicBoxVectors
[
1
][
1
],
periodicBoxVectors
[
2
][
2
],
0
);
fvec4
invBoxSize
(
recipBoxSize
[
0
],
recipBoxSize
[
1
],
recipBoxSize
[
2
],
0
);
fvec4
invBoxSize
(
recipBoxSize
[
0
],
recipBoxSize
[
1
],
recipBoxSize
[
2
],
0
);
if
(
useInteractionGroups
)
{
if
(
useInteractionGroups
)
{
...
...
platforms/cpu/src/CpuKernels.cpp
View file @
6ed5bc4e
...
@@ -98,8 +98,8 @@ static void validateVariables(const Lepton::ExpressionTreeNode& node, const set<
...
@@ -98,8 +98,8 @@ static void validateVariables(const Lepton::ExpressionTreeNode& node, const set<
const
Lepton
::
Operation
&
op
=
node
.
getOperation
();
const
Lepton
::
Operation
&
op
=
node
.
getOperation
();
if
(
op
.
getId
()
==
Lepton
::
Operation
::
VARIABLE
&&
variables
.
find
(
op
.
getName
())
==
variables
.
end
())
if
(
op
.
getId
()
==
Lepton
::
Operation
::
VARIABLE
&&
variables
.
find
(
op
.
getName
())
==
variables
.
end
())
throw
OpenMMException
(
"Unknown variable in expression: "
+
op
.
getName
());
throw
OpenMMException
(
"Unknown variable in expression: "
+
op
.
getName
());
for
(
int
i
=
0
;
i
<
(
int
)
node
.
getChildren
()
.
size
();
i
++
)
for
(
auto
&
child
:
node
.
getChildren
())
validateVariables
(
node
.
getChildren
()[
i
]
,
variables
);
validateVariables
(
child
,
variables
);
}
}
/**
/**
...
@@ -867,8 +867,8 @@ void CpuCalcCustomNonbondedForceKernel::initialize(const System& system, const C
...
@@ -867,8 +867,8 @@ void CpuCalcCustomNonbondedForceKernel::initialize(const System& system, const C
// Delete the custom functions.
// Delete the custom functions.
for
(
map
<
string
,
Lepton
::
CustomFunction
*>::
iterator
iter
=
functions
.
begin
();
iter
!=
functions
.
end
();
iter
++
)
for
(
auto
&
function
:
functions
)
delete
iter
->
second
;
delete
function
.
second
;
// Record information for the long range correction.
// Record information for the long range correction.
...
@@ -909,11 +909,11 @@ double CpuCalcCustomNonbondedForceKernel::execute(ContextImpl& context, bool inc
...
@@ -909,11 +909,11 @@ double CpuCalcCustomNonbondedForceKernel::execute(ContextImpl& context, bool inc
nonbonded
->
setPeriodic
(
boxVectors
);
nonbonded
->
setPeriodic
(
boxVectors
);
}
}
bool
globalParamsChanged
=
false
;
bool
globalParamsChanged
=
false
;
for
(
int
i
=
0
;
i
<
(
int
)
globalParameterNames
.
size
();
i
++
)
{
for
(
auto
&
name
:
globalParameterNames
)
{
double
value
=
context
.
getParameter
(
globalParameterNames
[
i
]
);
double
value
=
context
.
getParameter
(
name
);
if
(
globalParamValues
[
globalParameterNames
[
i
]
]
!=
value
)
if
(
globalParamValues
[
name
]
!=
value
)
globalParamsChanged
=
true
;
globalParamsChanged
=
true
;
globalParamValues
[
globalParameterNames
[
i
]
]
=
value
;
globalParamValues
[
name
]
=
value
;
}
}
if
(
useSwitchingFunction
)
if
(
useSwitchingFunction
)
nonbonded
->
setUseSwitchingFunction
(
switchingDistance
);
nonbonded
->
setUseSwitchingFunction
(
switchingDistance
);
...
@@ -1155,8 +1155,8 @@ void CpuCalcCustomGBForceKernel::initialize(const System& system, const CustomGB
...
@@ -1155,8 +1155,8 @@ void CpuCalcCustomGBForceKernel::initialize(const System& system, const CustomGB
// Delete the custom functions.
// Delete the custom functions.
for
(
map
<
string
,
Lepton
::
CustomFunction
*>::
iterator
iter
=
functions
.
begin
();
iter
!=
functions
.
end
();
iter
++
)
for
(
auto
&
function
:
functions
)
delete
iter
->
second
;
delete
function
.
second
;
ixn
=
new
CpuCustomGBForce
(
numParticles
,
exclusions
,
valueExpressions
,
valueDerivExpressions
,
valueGradientExpressions
,
valueParamDerivExpressions
,
ixn
=
new
CpuCustomGBForce
(
numParticles
,
exclusions
,
valueExpressions
,
valueDerivExpressions
,
valueGradientExpressions
,
valueParamDerivExpressions
,
valueNames
,
valueTypes
,
energyExpressions
,
energyDerivExpressions
,
energyGradientExpressions
,
energyParamDerivExpressions
,
energyTypes
,
valueNames
,
valueTypes
,
energyExpressions
,
energyDerivExpressions
,
energyGradientExpressions
,
energyParamDerivExpressions
,
energyTypes
,
particleParameterNames
,
data
.
threads
);
particleParameterNames
,
data
.
threads
);
...
@@ -1174,8 +1174,8 @@ double CpuCalcCustomGBForceKernel::execute(ContextImpl& context, bool includeFor
...
@@ -1174,8 +1174,8 @@ double CpuCalcCustomGBForceKernel::execute(ContextImpl& context, bool includeFor
ixn
->
setUseCutoff
(
nonbondedCutoff
,
*
data
.
neighborList
);
ixn
->
setUseCutoff
(
nonbondedCutoff
,
*
data
.
neighborList
);
}
}
map
<
string
,
double
>
globalParameters
;
map
<
string
,
double
>
globalParameters
;
for
(
int
i
=
0
;
i
<
(
int
)
globalParameterNames
.
size
();
i
++
)
for
(
auto
&
name
:
globalParameterNames
)
globalParameters
[
globalParameterNames
[
i
]
]
=
context
.
getParameter
(
globalParameterNames
[
i
]
);
globalParameters
[
name
]
=
context
.
getParameter
(
name
);
vector
<
double
>
energyParamDerivValues
(
energyParamDerivNames
.
size
()
+
1
,
0.0
);
vector
<
double
>
energyParamDerivValues
(
energyParamDerivNames
.
size
()
+
1
,
0.0
);
ixn
->
calculateIxn
(
numParticles
,
&
data
.
posq
[
0
],
particleParamArray
,
globalParameters
,
data
.
threadForce
,
includeForces
,
includeEnergy
,
energy
,
&
energyParamDerivValues
[
0
]);
ixn
->
calculateIxn
(
numParticles
,
&
data
.
posq
[
0
],
particleParamArray
,
globalParameters
,
data
.
threadForce
,
includeForces
,
includeEnergy
,
energy
,
&
energyParamDerivValues
[
0
]);
map
<
string
,
double
>&
energyParamDerivs
=
extractEnergyParameterDerivatives
(
context
);
map
<
string
,
double
>&
energyParamDerivs
=
extractEnergyParameterDerivatives
(
context
);
...
@@ -1236,8 +1236,8 @@ void CpuCalcCustomManyParticleForceKernel::initialize(const System& system, cons
...
@@ -1236,8 +1236,8 @@ void CpuCalcCustomManyParticleForceKernel::initialize(const System& system, cons
double
CpuCalcCustomManyParticleForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
double
CpuCalcCustomManyParticleForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
map
<
string
,
double
>
globalParameters
;
map
<
string
,
double
>
globalParameters
;
for
(
int
i
=
0
;
i
<
(
int
)
globalParameterNames
.
size
();
i
++
)
for
(
auto
&
name
:
globalParameterNames
)
globalParameters
[
globalParameterNames
[
i
]
]
=
context
.
getParameter
(
globalParameterNames
[
i
]
);
globalParameters
[
name
]
=
context
.
getParameter
(
name
);
if
(
nonbondedMethod
==
CutoffPeriodic
)
{
if
(
nonbondedMethod
==
CutoffPeriodic
)
{
Vec3
*
boxVectors
=
extractBoxVectors
(
context
);
Vec3
*
boxVectors
=
extractBoxVectors
(
context
);
double
minAllowedSize
=
2
*
cutoffDistance
;
double
minAllowedSize
=
2
*
cutoffDistance
;
...
...
platforms/cpu/src/CpuNeighborList.cpp
View file @
6ed5bc4e
...
@@ -577,10 +577,10 @@ void CpuNeighborList::threadComputeNeighborList(ThreadPool& threads, int threadI
...
@@ -577,10 +577,10 @@ void CpuNeighborList::threadComputeNeighborList(ThreadPool& threads, int threadI
for
(
int
j
=
0
;
j
<
atomsInBlock
;
j
++
)
{
for
(
int
j
=
0
;
j
<
atomsInBlock
;
j
++
)
{
const
set
<
int
>&
atomExclusions
=
(
*
exclusions
)[
sortedAtoms
[
firstIndex
+
j
]];
const
set
<
int
>&
atomExclusions
=
(
*
exclusions
)[
sortedAtoms
[
firstIndex
+
j
]];
char
mask
=
1
<<
j
;
char
mask
=
1
<<
j
;
for
(
set
<
int
>::
const_iterator
iter
=
atomExclusions
.
begin
();
iter
!=
atomExclusions
.
end
();
++
iter
)
{
for
(
int
exclusion
:
atomExclusions
)
{
map
<
int
,
char
>::
iterator
thisAtomFlags
=
atomFlags
.
find
(
*
iter
);
map
<
int
,
char
>::
iterator
thisAtomFlags
=
atomFlags
.
find
(
exclusion
);
if
(
thisAtomFlags
==
atomFlags
.
end
())
if
(
thisAtomFlags
==
atomFlags
.
end
())
atomFlags
[
*
iter
]
=
mask
;
atomFlags
[
exclusion
]
=
mask
;
else
else
thisAtomFlags
->
second
|=
mask
;
thisAtomFlags
->
second
|=
mask
;
}
}
...
...
platforms/cpu/src/CpuNonbondedForce.cpp
View file @
6ed5bc4e
...
@@ -447,9 +447,9 @@ void CpuNonbondedForce::threadComputeDirect(ThreadPool& threads, int threadIndex
...
@@ -447,9 +447,9 @@ void CpuNonbondedForce::threadComputeDirect(ThreadPool& threads, int threadIndex
for
(
int
i
=
start
;
i
<
end
;
i
++
)
{
for
(
int
i
=
start
;
i
<
end
;
i
++
)
{
fvec4
posI
((
float
)
atomCoordinates
[
i
][
0
],
(
float
)
atomCoordinates
[
i
][
1
],
(
float
)
atomCoordinates
[
i
][
2
],
0.0
f
);
fvec4
posI
((
float
)
atomCoordinates
[
i
][
0
],
(
float
)
atomCoordinates
[
i
][
1
],
(
float
)
atomCoordinates
[
i
][
2
],
0.0
f
);
float
scaledChargeI
=
(
float
)
(
ONE_4PI_EPS0
*
posq
[
4
*
i
+
3
]);
float
scaledChargeI
=
(
float
)
(
ONE_4PI_EPS0
*
posq
[
4
*
i
+
3
]);
for
(
set
<
int
>::
const_iterator
iter
=
exclusions
[
i
].
begin
();
iter
!=
exclusions
[
i
].
end
();
++
iter
)
{
for
(
int
excluded
:
exclusions
[
i
]
)
{
if
(
*
iter
>
i
)
{
if
(
excluded
>
i
)
{
int
j
=
*
iter
;
int
j
=
excluded
;
fvec4
deltaR
;
fvec4
deltaR
;
fvec4
posJ
((
float
)
atomCoordinates
[
j
][
0
],
(
float
)
atomCoordinates
[
j
][
1
],
(
float
)
atomCoordinates
[
j
][
2
],
0.0
f
);
fvec4
posJ
((
float
)
atomCoordinates
[
j
][
0
],
(
float
)
atomCoordinates
[
j
][
1
],
(
float
)
atomCoordinates
[
j
][
2
],
0.0
f
);
float
r2
;
float
r2
;
...
...
platforms/cpu/src/CpuRandom.cpp
View file @
6ed5bc4e
...
@@ -34,8 +34,8 @@ CpuRandom::CpuRandom() : hasInitialized(false) {
...
@@ -34,8 +34,8 @@ CpuRandom::CpuRandom() : hasInitialized(false) {
}
}
CpuRandom
::~
CpuRandom
()
{
CpuRandom
::~
CpuRandom
()
{
for
(
int
i
=
0
;
i
<
(
int
)
threadRandom
.
size
();
i
++
)
for
(
auto
random
:
threadRandom
)
delete
threadR
andom
[
i
]
;
delete
r
andom
;
}
}
void
CpuRandom
::
initialize
(
int
seed
,
int
numThreads
)
{
void
CpuRandom
::
initialize
(
int
seed
,
int
numThreads
)
{
...
...
platforms/cpu/src/CpuSETTLE.cpp
View file @
6ed5bc4e
...
@@ -56,8 +56,8 @@ CpuSETTLE::CpuSETTLE(const System& system, const ReferenceSETTLEAlgorithm& settl
...
@@ -56,8 +56,8 @@ CpuSETTLE::CpuSETTLE(const System& system, const ReferenceSETTLEAlgorithm& settl
}
}
CpuSETTLE
::~
CpuSETTLE
()
{
CpuSETTLE
::~
CpuSETTLE
()
{
for
(
int
i
=
0
;
i
<
(
int
)
threadSettle
.
size
();
i
++
)
for
(
auto
settle
:
threadSettle
)
delete
threadS
ettle
[
i
]
;
delete
s
ettle
;
}
}
void
CpuSETTLE
::
apply
(
vector
<
OpenMM
::
Vec3
>&
atomCoordinates
,
vector
<
OpenMM
::
Vec3
>&
atomCoordinatesP
,
vector
<
double
>&
inverseMasses
,
double
tolerance
)
{
void
CpuSETTLE
::
apply
(
vector
<
OpenMM
::
Vec3
>&
atomCoordinates
,
vector
<
OpenMM
::
Vec3
>&
atomCoordinatesP
,
vector
<
double
>&
inverseMasses
,
double
tolerance
)
{
...
...
platforms/cuda/src/CudaContext.cpp
View file @
6ed5bc4e
...
@@ -385,14 +385,14 @@ CudaContext::CudaContext(const System& system, int deviceIndex, bool useBlocking
...
@@ -385,14 +385,14 @@ CudaContext::CudaContext(const System& system, int deviceIndex, bool useBlocking
CudaContext
::~
CudaContext
()
{
CudaContext
::~
CudaContext
()
{
setAsCurrent
();
setAsCurrent
();
for
(
int
i
=
0
;
i
<
(
int
)
forces
.
size
();
i
++
)
for
(
auto
force
:
forces
)
delete
force
s
[
i
]
;
delete
force
;
for
(
int
i
=
0
;
i
<
(
int
)
reorderListeners
.
size
();
i
++
)
for
(
auto
listener
:
reorderListeners
)
delete
reorderL
istener
s
[
i
]
;
delete
l
istener
;
for
(
int
i
=
0
;
i
<
(
int
)
preComputations
.
size
();
i
++
)
for
(
auto
computation
:
preComputations
)
delete
preC
omputation
s
[
i
]
;
delete
c
omputation
;
for
(
int
i
=
0
;
i
<
(
int
)
postComputations
.
size
();
i
++
)
for
(
auto
computation
:
postComputations
)
delete
postC
omputation
s
[
i
]
;
delete
c
omputation
;
if
(
pinnedBuffer
!=
NULL
)
if
(
pinnedBuffer
!=
NULL
)
cuMemFreeHost
(
pinnedBuffer
);
cuMemFreeHost
(
pinnedBuffer
);
if
(
posq
!=
NULL
)
if
(
posq
!=
NULL
)
...
@@ -498,17 +498,17 @@ string CudaContext::replaceStrings(const string& input, const std::map<std::stri
...
@@ -498,17 +498,17 @@ string CudaContext::replaceStrings(const string& input, const std::map<std::stri
symbolChars
.
insert
(
c
);
symbolChars
.
insert
(
c
);
}
}
string
result
=
input
;
string
result
=
input
;
for
(
map
<
string
,
string
>::
const_iterator
iter
=
replacements
.
begin
();
iter
!=
replacements
.
end
();
iter
++
)
{
for
(
auto
&
pair
:
replacements
)
{
int
index
=
0
;
int
index
=
0
;
int
size
=
iter
->
first
.
size
();
int
size
=
pair
.
first
.
size
();
do
{
do
{
index
=
result
.
find
(
iter
->
first
,
index
);
index
=
result
.
find
(
pair
.
first
,
index
);
if
(
index
!=
result
.
npos
)
{
if
(
index
!=
result
.
npos
)
{
if
((
index
==
0
||
symbolChars
.
find
(
result
[
index
-
1
])
==
symbolChars
.
end
())
&&
(
index
==
result
.
size
()
-
size
||
symbolChars
.
find
(
result
[
index
+
size
])
==
symbolChars
.
end
()))
{
if
((
index
==
0
||
symbolChars
.
find
(
result
[
index
-
1
])
==
symbolChars
.
end
())
&&
(
index
==
result
.
size
()
-
size
||
symbolChars
.
find
(
result
[
index
+
size
])
==
symbolChars
.
end
()))
{
// We have found a complete symbol, not part of a longer symbol.
// We have found a complete symbol, not part of a longer symbol.
result
.
replace
(
index
,
size
,
iter
->
second
);
result
.
replace
(
index
,
size
,
pair
.
second
);
index
+=
iter
->
second
.
size
();
index
+=
pair
.
second
.
size
();
}
}
else
else
index
++
;
index
++
;
...
@@ -528,10 +528,10 @@ CUmodule CudaContext::createModule(const string source, const map<string, string
...
@@ -528,10 +528,10 @@ CUmodule CudaContext::createModule(const string source, const map<string, string
stringstream
src
;
stringstream
src
;
if
(
!
options
.
empty
())
if
(
!
options
.
empty
())
src
<<
"// Compilation Options: "
<<
options
<<
endl
<<
endl
;
src
<<
"// Compilation Options: "
<<
options
<<
endl
<<
endl
;
for
(
map
<
string
,
string
>::
const_iterator
iter
=
compilationDefines
.
begin
();
iter
!=
compilationDefines
.
end
();
++
iter
)
{
for
(
auto
&
pair
:
compilationDefines
)
{
src
<<
"#define "
<<
iter
->
first
;
src
<<
"#define "
<<
pair
.
first
;
if
(
!
iter
->
second
.
empty
())
if
(
!
pair
.
second
.
empty
())
src
<<
" "
<<
iter
->
second
;
src
<<
" "
<<
pair
.
second
;
src
<<
endl
;
src
<<
endl
;
}
}
if
(
!
compilationDefines
.
empty
())
if
(
!
compilationDefines
.
empty
())
...
@@ -561,10 +561,10 @@ CUmodule CudaContext::createModule(const string source, const map<string, string
...
@@ -561,10 +561,10 @@ CUmodule CudaContext::createModule(const string source, const map<string, string
src
<<
"typedef float4 mixed4;
\n
"
;
src
<<
"typedef float4 mixed4;
\n
"
;
}
}
src
<<
"typedef unsigned int tileflags;
\n
"
;
src
<<
"typedef unsigned int tileflags;
\n
"
;
for
(
map
<
string
,
string
>::
const_iterator
ite
r
=
defines
.
begin
();
iter
!=
defines
.
end
();
++
iter
)
{
for
(
auto
&
pai
r
:
defines
)
{
src
<<
"#define "
<<
iter
->
first
;
src
<<
"#define "
<<
pair
.
first
;
if
(
!
iter
->
second
.
empty
())
if
(
!
pair
.
second
.
empty
())
src
<<
" "
<<
iter
->
second
;
src
<<
" "
<<
pair
.
second
;
src
<<
endl
;
src
<<
endl
;
}
}
if
(
!
defines
.
empty
())
if
(
!
defines
.
empty
())
...
@@ -966,10 +966,10 @@ void CudaContext::findMoleculeGroups() {
...
@@ -966,10 +966,10 @@ void CudaContext::findMoleculeGroups() {
atomBonds
[
particle1
].
push_back
(
particle2
);
atomBonds
[
particle1
].
push_back
(
particle2
);
atomBonds
[
particle2
].
push_back
(
particle1
);
atomBonds
[
particle2
].
push_back
(
particle1
);
}
}
for
(
int
i
=
0
;
i
<
(
int
)
forces
.
size
();
i
++
)
{
for
(
auto
force
:
forces
)
{
for
(
int
j
=
0
;
j
<
force
s
[
i
]
->
getNumParticleGroups
();
j
++
)
{
for
(
int
j
=
0
;
j
<
force
->
getNumParticleGroups
();
j
++
)
{
vector
<
int
>
particles
;
vector
<
int
>
particles
;
force
s
[
i
]
->
getParticlesInGroup
(
j
,
particles
);
force
->
getParticlesInGroup
(
j
,
particles
);
for
(
int
k
=
0
;
k
<
(
int
)
particles
.
size
();
k
++
)
for
(
int
k
=
0
;
k
<
(
int
)
particles
.
size
();
k
++
)
for
(
int
m
=
0
;
m
<
(
int
)
particles
.
size
();
m
++
)
for
(
int
m
=
0
;
m
<
(
int
)
particles
.
size
();
m
++
)
if
(
k
!=
m
)
if
(
k
!=
m
)
...
@@ -1187,8 +1187,8 @@ bool CudaContext::invalidateMolecules(CudaForceInfo* force) {
...
@@ -1187,8 +1187,8 @@ bool CudaContext::invalidateMolecules(CudaForceInfo* force) {
}
}
atomIndexDevice
->
upload
(
atomIndex
);
atomIndexDevice
->
upload
(
atomIndex
);
findMoleculeGroups
();
findMoleculeGroups
();
for
(
int
i
=
0
;
i
<
(
int
)
reorderListeners
.
size
();
i
++
)
for
(
auto
listener
:
reorderListeners
)
reorderL
istener
s
[
i
]
->
execute
();
l
istener
->
execute
();
reorderAtoms
();
reorderAtoms
();
return
true
;
return
true
;
}
}
...
@@ -1250,10 +1250,9 @@ void CudaContext::reorderAtomsImpl() {
...
@@ -1250,10 +1250,9 @@ void CudaContext::reorderAtomsImpl() {
vector
<
Real4
>
newPosqCorrection
(
paddedNumAtoms
);
vector
<
Real4
>
newPosqCorrection
(
paddedNumAtoms
);
vector
<
Mixed4
>
newVelm
(
paddedNumAtoms
);
vector
<
Mixed4
>
newVelm
(
paddedNumAtoms
);
vector
<
int4
>
newCellOffsets
(
numAtoms
);
vector
<
int4
>
newCellOffsets
(
numAtoms
);
for
(
int
group
=
0
;
group
<
(
int
)
moleculeGroups
.
size
();
group
++
)
{
for
(
auto
&
mol
:
moleculeGroups
)
{
// Find the center of each molecule.
// Find the center of each molecule.
MoleculeGroup
&
mol
=
moleculeGroups
[
group
];
int
numMolecules
=
mol
.
offsets
.
size
();
int
numMolecules
=
mol
.
offsets
.
size
();
vector
<
int
>&
atoms
=
mol
.
atoms
;
vector
<
int
>&
atoms
=
mol
.
atoms
;
vector
<
Real4
>
molPos
(
numMolecules
);
vector
<
Real4
>
molPos
(
numMolecules
);
...
@@ -1347,9 +1346,9 @@ void CudaContext::reorderAtomsImpl() {
...
@@ -1347,9 +1346,9 @@ void CudaContext::reorderAtomsImpl() {
// Reorder the atoms.
// Reorder the atoms.
for
(
int
i
=
0
;
i
<
numMolecules
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numMolecules
;
i
++
)
{
for
(
int
j
=
0
;
j
<
(
int
)
atoms
.
size
();
j
++
)
{
for
(
int
atom
:
atoms
)
{
int
oldIndex
=
mol
.
offsets
[
molBins
[
i
].
second
]
+
atom
s
[
j
]
;
int
oldIndex
=
mol
.
offsets
[
molBins
[
i
].
second
]
+
atom
;
int
newIndex
=
mol
.
offsets
[
i
]
+
atom
s
[
j
]
;
int
newIndex
=
mol
.
offsets
[
i
]
+
atom
;
originalIndex
[
newIndex
]
=
atomIndex
[
oldIndex
];
originalIndex
[
newIndex
]
=
atomIndex
[
oldIndex
];
newPosq
[
newIndex
]
=
oldPosq
[
oldIndex
];
newPosq
[
newIndex
]
=
oldPosq
[
oldIndex
];
if
(
useMixedPrecision
)
if
(
useMixedPrecision
)
...
@@ -1371,8 +1370,8 @@ void CudaContext::reorderAtomsImpl() {
...
@@ -1371,8 +1370,8 @@ void CudaContext::reorderAtomsImpl() {
posqCorrection
->
upload
(
newPosqCorrection
);
posqCorrection
->
upload
(
newPosqCorrection
);
velm
->
upload
(
newVelm
);
velm
->
upload
(
newVelm
);
atomIndexDevice
->
upload
(
atomIndex
);
atomIndexDevice
->
upload
(
atomIndex
);
for
(
int
i
=
0
;
i
<
(
int
)
reorderListeners
.
size
();
i
++
)
for
(
auto
listener
:
reorderListeners
)
reorderL
istener
s
[
i
]
->
execute
();
l
istener
->
execute
();
}
}
void
CudaContext
::
addReorderListener
(
ReorderListener
*
listener
)
{
void
CudaContext
::
addReorderListener
(
ReorderListener
*
listener
)
{
...
...
platforms/cuda/src/CudaExpressionUtilities.cpp
View file @
6ed5bc4e
...
@@ -456,12 +456,12 @@ void CudaExpressionUtilities::processExpression(stringstream& out, const Express
...
@@ -456,12 +456,12 @@ void CudaExpressionUtilities::processExpression(stringstream& out, const Express
vector
<
bool
>
hasAssigned
(
powers
.
size
(),
false
);
vector
<
bool
>
hasAssigned
(
powers
.
size
(),
false
);
exponents
.
push_back
((
int
)
fabs
(
exponent
));
exponents
.
push_back
((
int
)
fabs
(
exponent
));
names
.
push_back
(
name
);
names
.
push_back
(
name
);
for
(
map
<
int
,
const
ExpressionTreeNode
*>::
const_iterator
iter
=
powers
.
begin
();
iter
!=
powers
.
end
();
++
iter
)
{
for
(
auto
&
power
:
powers
)
{
if
(
iter
->
first
!=
exponent
)
{
if
(
power
.
first
!=
exponent
)
{
exponents
.
push_back
(
iter
->
first
>=
0
?
iter
->
first
:
-
iter
->
first
);
exponents
.
push_back
(
power
.
first
>=
0
?
power
.
first
:
-
power
.
first
);
string
name2
=
prefix
+
context
.
intToString
(
temps
.
size
());
string
name2
=
prefix
+
context
.
intToString
(
temps
.
size
());
names
.
push_back
(
name2
);
names
.
push_back
(
name2
);
temps
.
push_back
(
make_pair
(
*
iter
->
second
,
name2
));
temps
.
push_back
(
make_pair
(
*
power
.
second
,
name2
));
out
<<
tempType
<<
" "
<<
name2
<<
" = 0.0f;
\n
"
;
out
<<
tempType
<<
" "
<<
name2
<<
" = 0.0f;
\n
"
;
}
}
}
}
...
...
platforms/cuda/src/CudaKernels.cpp
View file @
6ed5bc4e
This diff is collapsed.
Click to expand it.
Prev
1
2
3
4
5
6
7
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