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