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
ab8f1021
Commit
ab8f1021
authored
Mar 02, 2017
by
peastman
Browse files
Use C++11 style loops
parent
88da682c
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
597 additions
and
578 deletions
+597
-578
platforms/cpu/src/CpuKernels.cpp
platforms/cpu/src/CpuKernels.cpp
+14
-14
platforms/cuda/src/CudaContext.cpp
platforms/cuda/src/CudaContext.cpp
+32
-33
platforms/cuda/src/CudaKernels.cpp
platforms/cuda/src/CudaKernels.cpp
+229
-217
platforms/opencl/src/OpenCLContext.cpp
platforms/opencl/src/OpenCLContext.cpp
+44
-45
platforms/opencl/src/OpenCLKernels.cpp
platforms/opencl/src/OpenCLKernels.cpp
+240
-231
platforms/reference/src/ReferenceKernels.cpp
platforms/reference/src/ReferenceKernels.cpp
+38
-38
No files found.
platforms/cpu/src/CpuKernels.cpp
View file @
ab8f1021
...
@@ -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/cuda/src/CudaContext.cpp
View file @
ab8f1021
...
@@ -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/CudaKernels.cpp
View file @
ab8f1021
This diff is collapsed.
Click to expand it.
platforms/opencl/src/OpenCLContext.cpp
View file @
ab8f1021
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* *
* Portions copyright (c) 2009-201
6
Stanford University and the Authors. *
* Portions copyright (c) 2009-201
7
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -318,8 +318,8 @@ OpenCLContext::OpenCLContext(const System& system, int platformIndex, int device
...
@@ -318,8 +318,8 @@ OpenCLContext::OpenCLContext(const System& system, int platformIndex, int device
OpenCLArray
valuesArray
(
*
this
,
20
,
sizeof
(
mm_float8
),
"values"
);
OpenCLArray
valuesArray
(
*
this
,
20
,
sizeof
(
mm_float8
),
"values"
);
vector
<
mm_float8
>
values
(
valuesArray
.
getSize
());
vector
<
mm_float8
>
values
(
valuesArray
.
getSize
());
float
nextValue
=
1e-4
f
;
float
nextValue
=
1e-4
f
;
for
(
int
i
=
0
;
i
<
(
int
)
values
.
size
();
++
i
)
{
for
(
auto
&
val
:
values
)
{
val
ues
[
i
]
.
s0
=
nextValue
;
val
.
s0
=
nextValue
;
nextValue
*=
(
float
)
M_PI
;
nextValue
*=
(
float
)
M_PI
;
}
}
valuesArray
.
upload
(
values
);
valuesArray
.
upload
(
values
);
...
@@ -328,14 +328,14 @@ OpenCLContext::OpenCLContext(const System& system, int platformIndex, int device
...
@@ -328,14 +328,14 @@ OpenCLContext::OpenCLContext(const System& system, int platformIndex, int device
executeKernel
(
accuracyKernel
,
values
.
size
());
executeKernel
(
accuracyKernel
,
values
.
size
());
valuesArray
.
download
(
values
);
valuesArray
.
download
(
values
);
double
maxSqrtError
=
0.0
,
maxRsqrtError
=
0.0
,
maxRecipError
=
0.0
,
maxExpError
=
0.0
,
maxLogError
=
0.0
;
double
maxSqrtError
=
0.0
,
maxRsqrtError
=
0.0
,
maxRecipError
=
0.0
,
maxExpError
=
0.0
,
maxLogError
=
0.0
;
for
(
int
i
=
0
;
i
<
(
int
)
values
.
size
();
++
i
)
{
for
(
auto
&
val
:
values
)
{
double
v
=
val
ues
[
i
]
.
s0
;
double
v
=
val
.
s0
;
double
correctSqrt
=
sqrt
(
v
);
double
correctSqrt
=
sqrt
(
v
);
maxSqrtError
=
max
(
maxSqrtError
,
fabs
(
correctSqrt
-
val
ues
[
i
]
.
s1
)
/
correctSqrt
);
maxSqrtError
=
max
(
maxSqrtError
,
fabs
(
correctSqrt
-
val
.
s1
)
/
correctSqrt
);
maxRsqrtError
=
max
(
maxRsqrtError
,
fabs
(
1.0
/
correctSqrt
-
val
ues
[
i
]
.
s2
)
*
correctSqrt
);
maxRsqrtError
=
max
(
maxRsqrtError
,
fabs
(
1.0
/
correctSqrt
-
val
.
s2
)
*
correctSqrt
);
maxRecipError
=
max
(
maxRecipError
,
fabs
(
1.0
/
v
-
val
ues
[
i
]
.
s3
)
/
val
ues
[
i
]
.
s3
);
maxRecipError
=
max
(
maxRecipError
,
fabs
(
1.0
/
v
-
val
.
s3
)
/
val
.
s3
);
maxExpError
=
max
(
maxExpError
,
fabs
(
exp
(
v
)
-
val
ues
[
i
]
.
s4
)
/
val
ues
[
i
]
.
s4
);
maxExpError
=
max
(
maxExpError
,
fabs
(
exp
(
v
)
-
val
.
s4
)
/
val
.
s4
);
maxLogError
=
max
(
maxLogError
,
fabs
(
log
(
v
)
-
val
ues
[
i
]
.
s5
)
/
val
ues
[
i
]
.
s5
);
maxLogError
=
max
(
maxLogError
,
fabs
(
log
(
v
)
-
val
.
s5
)
/
val
.
s5
);
}
}
compilationDefines
[
"SQRT"
]
=
(
maxSqrtError
<
1e-6
)
?
"native_sqrt"
:
"sqrt"
;
compilationDefines
[
"SQRT"
]
=
(
maxSqrtError
<
1e-6
)
?
"native_sqrt"
:
"sqrt"
;
compilationDefines
[
"RSQRT"
]
=
(
maxRsqrtError
<
1e-6
)
?
"native_rsqrt"
:
"rsqrt"
;
compilationDefines
[
"RSQRT"
]
=
(
maxRsqrtError
<
1e-6
)
?
"native_rsqrt"
:
"rsqrt"
;
...
@@ -412,14 +412,14 @@ OpenCLContext::OpenCLContext(const System& system, int platformIndex, int device
...
@@ -412,14 +412,14 @@ OpenCLContext::OpenCLContext(const System& system, int platformIndex, int device
}
}
OpenCLContext
::~
OpenCLContext
()
{
OpenCLContext
::~
OpenCLContext
()
{
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
)
delete
pinnedBuffer
;
delete
pinnedBuffer
;
if
(
posq
!=
NULL
)
if
(
posq
!=
NULL
)
...
@@ -458,8 +458,8 @@ void OpenCLContext::initialize() {
...
@@ -458,8 +458,8 @@ void OpenCLContext::initialize() {
bonded
->
initialize
(
system
);
bonded
->
initialize
(
system
);
numForceBuffers
=
platformData
.
contexts
.
size
();
numForceBuffers
=
platformData
.
contexts
.
size
();
numForceBuffers
=
std
::
max
(
numForceBuffers
,
bonded
->
getNumForceBuffers
());
numForceBuffers
=
std
::
max
(
numForceBuffers
,
bonded
->
getNumForceBuffers
());
for
(
int
i
=
0
;
i
<
(
int
)
forces
.
size
();
i
++
)
for
(
auto
force
:
forces
)
numForceBuffers
=
std
::
max
(
numForceBuffers
,
force
s
[
i
]
->
getRequiredForceBuffers
());
numForceBuffers
=
std
::
max
(
numForceBuffers
,
force
->
getRequiredForceBuffers
());
int
energyBufferSize
=
max
(
numThreadBlocks
*
ThreadBlockSize
,
nonbonded
->
getNumEnergyBuffers
());
int
energyBufferSize
=
max
(
numThreadBlocks
*
ThreadBlockSize
,
nonbonded
->
getNumEnergyBuffers
());
if
(
useDoublePrecision
)
{
if
(
useDoublePrecision
)
{
forceBuffers
=
OpenCLArray
::
create
<
mm_double4
>
(
*
this
,
paddedNumAtoms
*
numForceBuffers
,
"forceBuffers"
);
forceBuffers
=
OpenCLArray
::
create
<
mm_double4
>
(
*
this
,
paddedNumAtoms
*
numForceBuffers
,
"forceBuffers"
);
...
@@ -525,17 +525,17 @@ string OpenCLContext::replaceStrings(const string& input, const std::map<std::st
...
@@ -525,17 +525,17 @@ string OpenCLContext::replaceStrings(const string& input, const std::map<std::st
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
++
;
...
@@ -554,10 +554,10 @@ cl::Program OpenCLContext::createProgram(const string source, const map<string,
...
@@ -554,10 +554,10 @@ cl::Program OpenCLContext::createProgram(const string source, const map<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
())
...
@@ -588,10 +588,10 @@ cl::Program OpenCLContext::createProgram(const string source, const map<string,
...
@@ -588,10 +588,10 @@ cl::Program OpenCLContext::createProgram(const string source, const map<string,
src
<<
"typedef float3 mixed3;
\n
"
;
src
<<
"typedef float3 mixed3;
\n
"
;
src
<<
"typedef float4 mixed4;
\n
"
;
src
<<
"typedef float4 mixed4;
\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
())
...
@@ -856,10 +856,10 @@ void OpenCLContext::findMoleculeGroups() {
...
@@ -856,10 +856,10 @@ void OpenCLContext::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
)
...
@@ -1076,8 +1076,8 @@ bool OpenCLContext::invalidateMolecules(OpenCLForceInfo* force) {
...
@@ -1076,8 +1076,8 @@ bool OpenCLContext::invalidateMolecules(OpenCLForceInfo* 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
;
}
}
...
@@ -1138,10 +1138,9 @@ void OpenCLContext::reorderAtomsImpl() {
...
@@ -1138,10 +1138,9 @@ void OpenCLContext::reorderAtomsImpl() {
vector
<
Real4
>
newPosqCorrection
(
paddedNumAtoms
,
Real4
(
0
,
0
,
0
,
0
));
vector
<
Real4
>
newPosqCorrection
(
paddedNumAtoms
,
Real4
(
0
,
0
,
0
,
0
));
vector
<
Mixed4
>
newVelm
(
paddedNumAtoms
,
Mixed4
(
0
,
0
,
0
,
0
));
vector
<
Mixed4
>
newVelm
(
paddedNumAtoms
,
Mixed4
(
0
,
0
,
0
,
0
));
vector
<
mm_int4
>
newCellOffsets
(
numAtoms
);
vector
<
mm_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
);
...
@@ -1235,9 +1234,9 @@ void OpenCLContext::reorderAtomsImpl() {
...
@@ -1235,9 +1234,9 @@ void OpenCLContext::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
)
...
@@ -1259,8 +1258,8 @@ void OpenCLContext::reorderAtomsImpl() {
...
@@ -1259,8 +1258,8 @@ void OpenCLContext::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
OpenCLContext
::
addReorderListener
(
ReorderListener
*
listener
)
{
void
OpenCLContext
::
addReorderListener
(
ReorderListener
*
listener
)
{
...
...
platforms/opencl/src/OpenCLKernels.cpp
View file @
ab8f1021
This diff is collapsed.
Click to expand it.
platforms/reference/src/ReferenceKernels.cpp
View file @
ab8f1021
...
@@ -159,8 +159,8 @@ static void validateVariables(const Lepton::ExpressionTreeNode& node, const set<
...
@@ -159,8 +159,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
);
}
}
/**
/**
...
@@ -214,8 +214,8 @@ void ReferenceCalcForcesAndEnergyKernel::beginComputation(ContextImpl& context,
...
@@ -214,8 +214,8 @@ void ReferenceCalcForcesAndEnergyKernel::beginComputation(ContextImpl& context,
}
}
else
else
savedForces
=
forceData
;
savedForces
=
forceData
;
for
(
map
<
string
,
double
>::
const_iterator
iter
=
context
.
getParameters
().
begin
();
iter
!=
context
.
getParameters
()
.
end
();
++
iter
)
for
(
auto
&
param
:
context
.
getParameters
())
extractEnergyParameterDerivatives
(
context
)[
iter
->
first
]
=
0
;
extractEnergyParameterDerivatives
(
context
)[
param
.
first
]
=
0
;
}
}
double
ReferenceCalcForcesAndEnergyKernel
::
finishComputation
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
,
int
groups
,
bool
&
valid
)
{
double
ReferenceCalcForcesAndEnergyKernel
::
finishComputation
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
,
int
groups
,
bool
&
valid
)
{
...
@@ -466,8 +466,8 @@ double ReferenceCalcCustomBondForceKernel::execute(ContextImpl& context, bool in
...
@@ -466,8 +466,8 @@ double ReferenceCalcCustomBondForceKernel::execute(ContextImpl& context, bool in
vector
<
Vec3
>&
forceData
=
extractForces
(
context
);
vector
<
Vec3
>&
forceData
=
extractForces
(
context
);
double
energy
=
0
;
double
energy
=
0
;
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
);
ReferenceCustomBondIxn
bond
(
energyExpression
,
forceExpression
,
parameterNames
,
globalParameters
,
energyParamDerivExpressions
);
ReferenceCustomBondIxn
bond
(
energyExpression
,
forceExpression
,
parameterNames
,
globalParameters
,
energyParamDerivExpressions
);
if
(
usePeriodic
)
if
(
usePeriodic
)
bond
.
setPeriodic
(
extractBoxVectors
(
context
));
bond
.
setPeriodic
(
extractBoxVectors
(
context
));
...
@@ -600,8 +600,8 @@ double ReferenceCalcCustomAngleForceKernel::execute(ContextImpl& context, bool i
...
@@ -600,8 +600,8 @@ double ReferenceCalcCustomAngleForceKernel::execute(ContextImpl& context, bool i
vector
<
Vec3
>&
forceData
=
extractForces
(
context
);
vector
<
Vec3
>&
forceData
=
extractForces
(
context
);
double
energy
=
0
;
double
energy
=
0
;
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
);
ReferenceCustomAngleIxn
customAngle
(
energyExpression
,
forceExpression
,
parameterNames
,
globalParameters
,
energyParamDerivExpressions
);
ReferenceCustomAngleIxn
customAngle
(
energyExpression
,
forceExpression
,
parameterNames
,
globalParameters
,
energyParamDerivExpressions
);
if
(
usePeriodic
)
if
(
usePeriodic
)
customAngle
.
setPeriodic
(
extractBoxVectors
(
context
));
customAngle
.
setPeriodic
(
extractBoxVectors
(
context
));
...
@@ -870,8 +870,8 @@ double ReferenceCalcCustomTorsionForceKernel::execute(ContextImpl& context, bool
...
@@ -870,8 +870,8 @@ double ReferenceCalcCustomTorsionForceKernel::execute(ContextImpl& context, bool
vector
<
Vec3
>&
forceData
=
extractForces
(
context
);
vector
<
Vec3
>&
forceData
=
extractForces
(
context
);
double
energy
=
0
;
double
energy
=
0
;
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
);
ReferenceCustomTorsionIxn
customTorsion
(
energyExpression
,
forceExpression
,
parameterNames
,
globalParameters
,
energyParamDerivExpressions
);
ReferenceCustomTorsionIxn
customTorsion
(
energyExpression
,
forceExpression
,
parameterNames
,
globalParameters
,
energyParamDerivExpressions
);
if
(
usePeriodic
)
if
(
usePeriodic
)
customTorsion
.
setPeriodic
(
extractBoxVectors
(
context
));
customTorsion
.
setPeriodic
(
extractBoxVectors
(
context
));
...
@@ -1165,8 +1165,8 @@ void ReferenceCalcCustomNonbondedForceKernel::initialize(const System& system, c
...
@@ -1165,8 +1165,8 @@ void ReferenceCalcCustomNonbondedForceKernel::initialize(const System& system, 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.
...
@@ -1208,11 +1208,11 @@ double ReferenceCalcCustomNonbondedForceKernel::execute(ContextImpl& context, bo
...
@@ -1208,11 +1208,11 @@ double ReferenceCalcCustomNonbondedForceKernel::execute(ContextImpl& context, bo
if
(
interactionGroups
.
size
()
>
0
)
if
(
interactionGroups
.
size
()
>
0
)
ixn
.
setInteractionGroups
(
interactionGroups
);
ixn
.
setInteractionGroups
(
interactionGroups
);
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
)
ixn
.
setUseSwitchingFunction
(
switchingDistance
);
ixn
.
setUseSwitchingFunction
(
switchingDistance
);
...
@@ -1459,8 +1459,8 @@ void ReferenceCalcCustomGBForceKernel::initialize(const System& system, const Cu
...
@@ -1459,8 +1459,8 @@ void ReferenceCalcCustomGBForceKernel::initialize(const System& system, const Cu
// 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
;
}
}
double
ReferenceCalcCustomGBForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
double
ReferenceCalcCustomGBForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
...
@@ -1477,8 +1477,8 @@ double ReferenceCalcCustomGBForceKernel::execute(ContextImpl& context, bool incl
...
@@ -1477,8 +1477,8 @@ double ReferenceCalcCustomGBForceKernel::execute(ContextImpl& context, bool incl
ixn
.
setUseCutoff
(
nonbondedCutoff
,
*
neighborList
);
ixn
.
setUseCutoff
(
nonbondedCutoff
,
*
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
,
posData
,
particleParamArray
,
exclusions
,
globalParameters
,
forceData
,
includeEnergy
?
&
energy
:
NULL
,
&
energyParamDerivValues
[
0
]);
ixn
.
calculateIxn
(
numParticles
,
posData
,
particleParamArray
,
exclusions
,
globalParameters
,
forceData
,
includeEnergy
?
&
energy
:
NULL
,
&
energyParamDerivValues
[
0
]);
map
<
string
,
double
>&
energyParamDerivs
=
extractEnergyParameterDerivatives
(
context
);
map
<
string
,
double
>&
energyParamDerivs
=
extractEnergyParameterDerivatives
(
context
);
...
@@ -1593,8 +1593,8 @@ double ReferenceCalcCustomExternalForceKernel::execute(ContextImpl& context, boo
...
@@ -1593,8 +1593,8 @@ double ReferenceCalcCustomExternalForceKernel::execute(ContextImpl& context, boo
boxVectors
=
extractBoxVectors
(
context
);
boxVectors
=
extractBoxVectors
(
context
);
double
energy
=
0
;
double
energy
=
0
;
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
);
ReferenceCustomExternalIxn
force
(
energyExpression
,
forceExpressionX
,
forceExpressionY
,
forceExpressionZ
,
parameterNames
,
globalParameters
);
ReferenceCustomExternalIxn
force
(
energyExpression
,
forceExpressionX
,
forceExpressionY
,
forceExpressionZ
,
parameterNames
,
globalParameters
);
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
force
.
calculateForce
(
particles
[
i
],
posData
,
particleParamArray
[
i
],
forceData
,
includeEnergy
?
&
energy
:
NULL
);
force
.
calculateForce
(
particles
[
i
],
posData
,
particleParamArray
[
i
],
forceData
,
includeEnergy
?
&
energy
:
NULL
);
...
@@ -1699,8 +1699,8 @@ void ReferenceCalcCustomHbondForceKernel::initialize(const System& system, const
...
@@ -1699,8 +1699,8 @@ void ReferenceCalcCustomHbondForceKernel::initialize(const System& system, const
// 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
;
}
}
double
ReferenceCalcCustomHbondForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
double
ReferenceCalcCustomHbondForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
...
@@ -1710,8 +1710,8 @@ double ReferenceCalcCustomHbondForceKernel::execute(ContextImpl& context, bool i
...
@@ -1710,8 +1710,8 @@ double ReferenceCalcCustomHbondForceKernel::execute(ContextImpl& context, bool i
ixn
->
setPeriodic
(
extractBoxVectors
(
context
));
ixn
->
setPeriodic
(
extractBoxVectors
(
context
));
double
energy
=
0
;
double
energy
=
0
;
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
);
ixn
->
calculatePairIxn
(
posData
,
donorParamArray
,
acceptorParamArray
,
exclusions
,
globalParameters
,
forceData
,
includeEnergy
?
&
energy
:
NULL
);
ixn
->
calculatePairIxn
(
posData
,
donorParamArray
,
acceptorParamArray
,
exclusions
,
globalParameters
,
forceData
,
includeEnergy
?
&
energy
:
NULL
);
return
energy
;
return
energy
;
}
}
...
@@ -1803,8 +1803,8 @@ void ReferenceCalcCustomCentroidBondForceKernel::initialize(const System& system
...
@@ -1803,8 +1803,8 @@ void ReferenceCalcCustomCentroidBondForceKernel::initialize(const System& system
// 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
;
}
}
double
ReferenceCalcCustomCentroidBondForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
double
ReferenceCalcCustomCentroidBondForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
...
@@ -1812,8 +1812,8 @@ double ReferenceCalcCustomCentroidBondForceKernel::execute(ContextImpl& context,
...
@@ -1812,8 +1812,8 @@ double ReferenceCalcCustomCentroidBondForceKernel::execute(ContextImpl& context,
vector
<
Vec3
>&
forceData
=
extractForces
(
context
);
vector
<
Vec3
>&
forceData
=
extractForces
(
context
);
double
energy
=
0
;
double
energy
=
0
;
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
(
usePeriodic
)
if
(
usePeriodic
)
ixn
->
setPeriodic
(
extractBoxVectors
(
context
));
ixn
->
setPeriodic
(
extractBoxVectors
(
context
));
vector
<
double
>
energyParamDerivValues
(
energyParamDerivNames
.
size
()
+
1
,
0.0
);
vector
<
double
>
energyParamDerivValues
(
energyParamDerivNames
.
size
()
+
1
,
0.0
);
...
@@ -1893,8 +1893,8 @@ void ReferenceCalcCustomCompoundBondForceKernel::initialize(const System& system
...
@@ -1893,8 +1893,8 @@ void ReferenceCalcCustomCompoundBondForceKernel::initialize(const System& system
// 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
;
}
}
double
ReferenceCalcCustomCompoundBondForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
double
ReferenceCalcCustomCompoundBondForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
...
@@ -1902,8 +1902,8 @@ double ReferenceCalcCustomCompoundBondForceKernel::execute(ContextImpl& context,
...
@@ -1902,8 +1902,8 @@ double ReferenceCalcCustomCompoundBondForceKernel::execute(ContextImpl& context,
vector
<
Vec3
>&
forceData
=
extractForces
(
context
);
vector
<
Vec3
>&
forceData
=
extractForces
(
context
);
double
energy
=
0
;
double
energy
=
0
;
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
(
usePeriodic
)
if
(
usePeriodic
)
ixn
->
setPeriodic
(
extractBoxVectors
(
context
));
ixn
->
setPeriodic
(
extractBoxVectors
(
context
));
vector
<
double
>
energyParamDerivValues
(
energyParamDerivNames
.
size
()
+
1
,
0.0
);
vector
<
double
>
energyParamDerivValues
(
energyParamDerivNames
.
size
()
+
1
,
0.0
);
...
@@ -1966,8 +1966,8 @@ double ReferenceCalcCustomManyParticleForceKernel::execute(ContextImpl& context,
...
@@ -1966,8 +1966,8 @@ double ReferenceCalcCustomManyParticleForceKernel::execute(ContextImpl& context,
vector
<
Vec3
>&
forceData
=
extractForces
(
context
);
vector
<
Vec3
>&
forceData
=
extractForces
(
context
);
double
energy
=
0
;
double
energy
=
0
;
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
;
...
@@ -2232,8 +2232,8 @@ void ReferenceIntegrateCustomStepKernel::initialize(const System& system, const
...
@@ -2232,8 +2232,8 @@ void ReferenceIntegrateCustomStepKernel::initialize(const System& system, const
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
masses
[
i
]
=
system
.
getParticleMass
(
i
);
masses
[
i
]
=
system
.
getParticleMass
(
i
);
perDofValues
.
resize
(
integrator
.
getNumPerDofVariables
());
perDofValues
.
resize
(
integrator
.
getNumPerDofVariables
());
for
(
int
i
=
0
;
i
<
(
int
)
perDofValues
.
size
();
i
++
)
for
(
auto
&
values
:
perDofValues
)
perDofV
alues
[
i
]
.
resize
(
numParticles
);
v
alues
.
resize
(
numParticles
);
// Create the computation objects.
// Create the computation objects.
...
...
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