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
2c78200c
Unverified
Commit
2c78200c
authored
Dec 11, 2019
by
Andy Simmonett
Browse files
Clean up reference code, fix silly CUDA bug I just introduced
parent
d6fe5f61
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
27 deletions
+15
-27
platforms/cuda/src/CudaKernels.cpp
platforms/cuda/src/CudaKernels.cpp
+3
-3
platforms/reference/src/SimTKReference/ReferenceVelocityVerletDynamics.cpp
...ce/src/SimTKReference/ReferenceVelocityVerletDynamics.cpp
+12
-24
No files found.
platforms/cuda/src/CudaKernels.cpp
View file @
2c78200c
...
@@ -8705,13 +8705,13 @@ std::pair<double, double> CudaNoseHooverChainKernel::computeMaskedKineticEnergy(
...
@@ -8705,13 +8705,13 @@ std::pair<double, double> CudaNoseHooverChainKernel::computeMaskedKineticEnergy(
kineticEnergyBuffer.upload(zeros);
kineticEnergyBuffer.upload(zeros);
}
}
}
}
cu
.
clearBuffer
(
cu
.
getE
nergyBuffer
()
);
cu.clearBuffer(
e
nergyBuffer);
if (nAtoms) {
if (nAtoms) {
void
*
args
[]
=
{
&
cu
.
getE
nergyBuffer
()
.
getDevicePointer
(),
&
nAtoms
,
&
cu
.
getVelm
().
getDevicePointer
(),
&
atomlists
[
chainID
].
getDevicePointer
()};
void *args[] = {&
e
nergyBuffer.getDevicePointer(),&nAtoms, &cu.getVelm().getDevicePointer(), &atomlists[chainID].getDevicePointer()};
cu.executeKernel(computeAtomsKineticEnergyKernel, args, nAtoms);
cu.executeKernel(computeAtomsKineticEnergyKernel, args, nAtoms);
}
}
if (nPairs) {
if (nPairs) {
void
*
args
[]
=
{
&
cu
.
getE
nergyBuffer
()
.
getDevicePointer
(),
&
nPairs
,
&
cu
.
getVelm
().
getDevicePointer
(),
&
pairlists
[
chainID
].
getDevicePointer
()};
void *args[] = {&
e
nergyBuffer.getDevicePointer(),&nPairs, &cu.getVelm().getDevicePointer(), &pairlists[chainID].getDevicePointer()};
cu.executeKernel(computePairsKineticEnergyKernel, args, nPairs);
cu.executeKernel(computePairsKineticEnergyKernel, args, nPairs);
}
}
...
...
platforms/reference/src/SimTKReference/ReferenceVelocityVerletDynamics.cpp
View file @
2c78200c
...
@@ -105,11 +105,9 @@ void ReferenceVelocityVerletDynamics::update(OpenMM::ContextImpl &context, const
...
@@ -105,11 +105,9 @@ void ReferenceVelocityVerletDynamics::update(OpenMM::ContextImpl &context, const
// Regular atoms
// Regular atoms
for
(
const
auto
&
atom
:
atomList
)
{
for
(
const
auto
&
atom
:
atomList
)
{
if
(
masses
[
atom
]
!=
0.0
)
{
if
(
masses
[
atom
]
!=
0.0
)
{
for
(
int
xyz
=
0
;
xyz
<
3
;
++
xyz
)
{
velocities
[
atom
]
+=
0.5
*
inverseMasses
[
atom
]
*
forces
[
atom
]
*
getDeltaT
();
velocities
[
atom
][
xyz
]
+=
0.5
*
inverseMasses
[
atom
]
*
forces
[
atom
][
xyz
]
*
getDeltaT
();
xPrime
[
atom
]
=
atomCoordinates
[
atom
];
xPrime
[
atom
][
xyz
]
=
atomCoordinates
[
atom
][
xyz
];
atomCoordinates
[
atom
]
+=
velocities
[
atom
]
*
getDeltaT
();
atomCoordinates
[
atom
][
xyz
]
+=
velocities
[
atom
][
xyz
]
*
getDeltaT
();
}
}
}
}
}
// Connected particles
// Connected particles
...
@@ -129,18 +127,14 @@ void ReferenceVelocityVerletDynamics::update(OpenMM::ContextImpl &context, const
...
@@ -129,18 +127,14 @@ void ReferenceVelocityVerletDynamics::update(OpenMM::ContextImpl &context, const
comVel
+=
0.5
*
comForce
*
getDeltaT
()
*
invTotMass
;
comVel
+=
0.5
*
comForce
*
getDeltaT
()
*
invTotMass
;
relVel
+=
0.5
*
relForce
*
getDeltaT
()
*
invRedMass
;
relVel
+=
0.5
*
relForce
*
getDeltaT
()
*
invRedMass
;
if
(
m1
!=
0.0
)
{
if
(
m1
!=
0.0
)
{
for
(
int
xyz
=
0
;
xyz
<
3
;
++
xyz
)
{
velocities
[
atom1
]
=
comVel
-
relVel
*
mass2fract
;
velocities
[
atom1
][
xyz
]
=
comVel
[
xyz
]
-
relVel
[
xyz
]
*
mass2fract
;
xPrime
[
atom1
]
=
atomCoordinates
[
atom1
];
xPrime
[
atom1
][
xyz
]
=
atomCoordinates
[
atom1
][
xyz
];
atomCoordinates
[
atom1
]
+=
velocities
[
atom1
]
*
getDeltaT
();
atomCoordinates
[
atom1
][
xyz
]
+=
velocities
[
atom1
][
xyz
]
*
getDeltaT
();
}
}
}
if
(
m2
!=
0.0
)
{
if
(
m2
!=
0.0
)
{
for
(
int
xyz
=
0
;
xyz
<
3
;
++
xyz
)
{
velocities
[
atom2
]
=
comVel
+
relVel
*
mass1fract
;
velocities
[
atom2
][
xyz
]
=
comVel
[
xyz
]
+
relVel
[
xyz
]
*
mass1fract
;
xPrime
[
atom2
]
=
atomCoordinates
[
atom2
];
xPrime
[
atom2
][
xyz
]
=
atomCoordinates
[
atom2
][
xyz
];
atomCoordinates
[
atom2
]
+=
velocities
[
atom2
]
*
getDeltaT
();
atomCoordinates
[
atom2
][
xyz
]
+=
velocities
[
atom2
][
xyz
]
*
getDeltaT
();
}
}
}
}
}
...
@@ -235,9 +229,7 @@ void ReferenceVelocityVerletDynamics::update(OpenMM::ContextImpl &context, const
...
@@ -235,9 +229,7 @@ void ReferenceVelocityVerletDynamics::update(OpenMM::ContextImpl &context, const
// Regular atoms
// Regular atoms
for
(
const
auto
&
atom
:
atomList
)
{
for
(
const
auto
&
atom
:
atomList
)
{
if
(
masses
[
atom
]
!=
0.0
)
{
if
(
masses
[
atom
]
!=
0.0
)
{
for
(
int
xyz
=
0
;
xyz
<
3
;
++
xyz
)
{
velocities
[
atom
]
+=
0.5
*
inverseMasses
[
atom
]
*
forces
[
atom
]
*
getDeltaT
()
+
(
atomCoordinates
[
atom
]
-
xPrime
[
atom
])
/
getDeltaT
();
velocities
[
atom
][
xyz
]
+=
0.5
*
inverseMasses
[
atom
]
*
forces
[
atom
][
xyz
]
*
getDeltaT
()
+
(
atomCoordinates
[
atom
][
xyz
]
-
xPrime
[
atom
][
xyz
])
/
getDeltaT
();
}
}
}
}
}
// Connected particles
// Connected particles
...
@@ -257,14 +249,10 @@ void ReferenceVelocityVerletDynamics::update(OpenMM::ContextImpl &context, const
...
@@ -257,14 +249,10 @@ void ReferenceVelocityVerletDynamics::update(OpenMM::ContextImpl &context, const
comVel
+=
0.5
*
comForce
*
getDeltaT
()
*
invTotMass
;
comVel
+=
0.5
*
comForce
*
getDeltaT
()
*
invTotMass
;
relVel
+=
0.5
*
relForce
*
getDeltaT
()
*
invRedMass
;
relVel
+=
0.5
*
relForce
*
getDeltaT
()
*
invRedMass
;
if
(
m1
!=
0.0
)
{
if
(
m1
!=
0.0
)
{
for
(
int
xyz
=
0
;
xyz
<
3
;
++
xyz
)
{
velocities
[
atom1
]
=
comVel
-
relVel
*
mass2fract
+
(
atomCoordinates
[
atom1
]
-
xPrime
[
atom1
])
/
getDeltaT
();
velocities
[
atom1
][
xyz
]
=
comVel
[
xyz
]
-
relVel
[
xyz
]
*
mass2fract
+
(
atomCoordinates
[
atom1
][
xyz
]
-
xPrime
[
atom1
][
xyz
])
/
getDeltaT
();
}
}
}
if
(
m2
!=
0.0
)
{
if
(
m2
!=
0.0
)
{
for
(
int
xyz
=
0
;
xyz
<
3
;
++
xyz
)
{
velocities
[
atom2
]
=
comVel
+
relVel
*
mass1fract
+
(
atomCoordinates
[
atom2
]
-
xPrime
[
atom2
])
/
getDeltaT
();
velocities
[
atom2
][
xyz
]
=
comVel
[
xyz
]
+
relVel
[
xyz
]
*
mass1fract
+
(
atomCoordinates
[
atom2
][
xyz
]
-
xPrime
[
atom2
][
xyz
])
/
getDeltaT
();
}
}
}
}
}
if
(
referenceConstraintAlgorithm
)
if
(
referenceConstraintAlgorithm
)
...
...
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