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
5e6862fd
Commit
5e6862fd
authored
Feb 04, 2016
by
Peter Eastman
Browse files
Fixed error in computing global variables
parent
1085085d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
4 deletions
+7
-4
platforms/cuda/src/CudaKernels.cpp
platforms/cuda/src/CudaKernels.cpp
+2
-2
platforms/opencl/src/OpenCLKernels.cpp
platforms/opencl/src/OpenCLKernels.cpp
+2
-2
tests/TestCustomIntegrator.h
tests/TestCustomIntegrator.h
+3
-0
No files found.
platforms/cuda/src/CudaKernels.cpp
View file @
5e6862fd
...
...
@@ -6661,12 +6661,12 @@ void CudaIntegrateCustomStepKernel::execute(ContextImpl& context, CustomIntegrat
if
(
cu
.
getUseDoublePrecision
()
||
cu
.
getUseMixedPrecision
())
{
double
value
;
summedValue
->
download
(
&
value
);
g
lobalValue
sDouble
[
stepTarget
[
step
]
.
variableIndex
]
=
value
;
recordG
lobalValue
(
value
,
stepTarget
[
step
]
)
;
}
else
{
float
value
;
summedValue
->
download
(
&
value
);
g
lobalValue
sDouble
[
stepTarget
[
step
]
.
variableIndex
]
=
value
;
recordG
lobalValue
(
value
,
stepTarget
[
step
]
)
;
}
}
else
if
(
stepType
[
step
]
==
CustomIntegrator
::
UpdateContextState
)
{
...
...
platforms/opencl/src/OpenCLKernels.cpp
View file @
5e6862fd
...
...
@@ -6939,12 +6939,12 @@ void OpenCLIntegrateCustomStepKernel::execute(ContextImpl& context, CustomIntegr
if (cl.getUseDoublePrecision() || cl.getUseMixedPrecision()) {
double value;
summedValue->download(&value);
g
lobalValue
sDouble[
stepTarget[step]
.variableIndex] = value
;
recordG
lobalValue
(value,
stepTarget[step]
)
;
}
else {
float value;
summedValue->download(&value);
g
lobalValue
sDouble[
stepTarget[step]
.variableIndex] = value
;
recordG
lobalValue
(value,
stepTarget[step]
)
;
}
}
else if (stepType[step] == CustomIntegrator::UpdateContextState) {
...
...
tests/TestCustomIntegrator.h
View file @
5e6862fd
...
...
@@ -391,9 +391,11 @@ void testSum() {
}
CustomIntegrator
integrator
(
0.005
);
integrator
.
addGlobalVariable
(
"ke"
,
0
);
integrator
.
addGlobalVariable
(
"kecopy"
,
0
);
integrator
.
addComputePerDof
(
"v"
,
"v+dt*f/m"
);
integrator
.
addComputePerDof
(
"x"
,
"x+dt*v"
);
integrator
.
addComputeSum
(
"ke"
,
"m*v*v/2"
);
integrator
.
addComputeGlobal
(
"kecopy"
,
"ke"
);
Context
context
(
system
,
integrator
,
platform
);
context
.
setPositions
(
positions
);
...
...
@@ -402,6 +404,7 @@ void testSum() {
for
(
int
i
=
0
;
i
<
100
;
++
i
)
{
State
state
=
context
.
getState
(
State
::
Energy
);
ASSERT_EQUAL_TOL
(
state
.
getKineticEnergy
(),
integrator
.
getGlobalVariable
(
0
),
1e-5
);
ASSERT_EQUAL
(
integrator
.
getGlobalVariable
(
0
),
integrator
.
getGlobalVariable
(
1
));
integrator
.
step
(
1
);
}
}
...
...
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