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
b0bda3a1
"...ssh:/git@developer.sourcefind.cn:2222/tsoc/openmm.git" did not exist on "62cc2344329abfa3a89c10e0e33a642ac51468d4"
Commit
b0bda3a1
authored
Jan 14, 2012
by
Peter Eastman
Browse files
Bug fix to previous bug fix
parent
69812ad7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
5 deletions
+9
-5
platforms/opencl/src/OpenCLKernels.cpp
platforms/opencl/src/OpenCLKernels.cpp
+7
-4
platforms/opencl/tests/TestOpenCLCustomIntegrator.cpp
platforms/opencl/tests/TestOpenCLCustomIntegrator.cpp
+2
-1
No files found.
platforms/opencl/src/OpenCLKernels.cpp
View file @
b0bda3a1
...
@@ -3502,8 +3502,8 @@ void OpenCLIntegrateVariableLangevinStepKernel::execute(ContextImpl& context, co
...
@@ -3502,8 +3502,8 @@ void OpenCLIntegrateVariableLangevinStepKernel::execute(ContextImpl& context, co
class
OpenCLIntegrateCustomStepKernel
::
ReorderListener
:
public
OpenCLContext
::
ReorderListener
{
class
OpenCLIntegrateCustomStepKernel
::
ReorderListener
:
public
OpenCLContext
::
ReorderListener
{
public:
public:
ReorderListener
(
OpenCLContext
&
cl
,
OpenCLParameterSet
&
perDofValues
,
vector
<
vector
<
cl_float
>
>&
localPerDofValues
)
:
ReorderListener
(
OpenCLContext
&
cl
,
OpenCLParameterSet
&
perDofValues
,
vector
<
vector
<
cl_float
>
>&
localPerDofValues
,
bool
&
deviceValuesAreCurrent
)
:
cl
(
cl
),
perDofValues
(
perDofValues
),
localPerDofValues
(
localPerDofValues
)
{
cl
(
cl
),
perDofValues
(
perDofValues
),
localPerDofValues
(
localPerDofValues
)
,
deviceValuesAreCurrent
(
deviceValuesAreCurrent
)
{
int
numAtoms
=
cl
.
getNumAtoms
();
int
numAtoms
=
cl
.
getNumAtoms
();
lastAtomOrder
.
resize
(
numAtoms
);
lastAtomOrder
.
resize
(
numAtoms
);
for
(
int
i
=
0
;
i
<
numAtoms
;
i
++
)
for
(
int
i
=
0
;
i
<
numAtoms
;
i
++
)
...
@@ -3513,7 +3513,8 @@ public:
...
@@ -3513,7 +3513,8 @@ public:
// Reorder the per-DOF variables to reflect the new atom order.
// Reorder the per-DOF variables to reflect the new atom order.
int
numAtoms
=
cl
.
getNumAtoms
();
int
numAtoms
=
cl
.
getNumAtoms
();
perDofValues
.
getParameterValues
(
localPerDofValues
);
if
(
deviceValuesAreCurrent
)
perDofValues
.
getParameterValues
(
localPerDofValues
);
vector
<
vector
<
cl_float
>
>
swap
(
3
*
numAtoms
);
vector
<
vector
<
cl_float
>
>
swap
(
3
*
numAtoms
);
for
(
int
i
=
0
;
i
<
numAtoms
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numAtoms
;
i
++
)
{
swap
[
3
*
lastAtomOrder
[
i
]]
=
localPerDofValues
[
3
*
i
];
swap
[
3
*
lastAtomOrder
[
i
]]
=
localPerDofValues
[
3
*
i
];
...
@@ -3529,11 +3530,13 @@ public:
...
@@ -3529,11 +3530,13 @@ public:
perDofValues
.
setParameterValues
(
localPerDofValues
);
perDofValues
.
setParameterValues
(
localPerDofValues
);
for
(
int
i
=
0
;
i
<
numAtoms
;
i
++
)
for
(
int
i
=
0
;
i
<
numAtoms
;
i
++
)
lastAtomOrder
[
i
]
=
order
[
i
];
lastAtomOrder
[
i
]
=
order
[
i
];
deviceValuesAreCurrent
=
true
;
}
}
private:
private:
OpenCLContext
&
cl
;
OpenCLContext
&
cl
;
OpenCLParameterSet
&
perDofValues
;
OpenCLParameterSet
&
perDofValues
;
vector
<
vector
<
cl_float
>
>&
localPerDofValues
;
vector
<
vector
<
cl_float
>
>&
localPerDofValues
;
bool
&
deviceValuesAreCurrent
;
std
::
vector
<
int
>
lastAtomOrder
;
std
::
vector
<
int
>
lastAtomOrder
;
};
};
...
@@ -3562,6 +3565,7 @@ void OpenCLIntegrateCustomStepKernel::initialize(const System& system, const Cus
...
@@ -3562,6 +3565,7 @@ void OpenCLIntegrateCustomStepKernel::initialize(const System& system, const Cus
sumBuffer
=
new
OpenCLArray
<
cl_float
>
(
cl
,
3
*
system
.
getNumParticles
(),
"sumBuffer"
);
sumBuffer
=
new
OpenCLArray
<
cl_float
>
(
cl
,
3
*
system
.
getNumParticles
(),
"sumBuffer"
);
energy
=
new
OpenCLArray
<
cl_float
>
(
cl
,
1
,
"energy"
);
energy
=
new
OpenCLArray
<
cl_float
>
(
cl
,
1
,
"energy"
);
perDofValues
=
new
OpenCLParameterSet
(
cl
,
integrator
.
getNumPerDofVariables
(),
3
*
system
.
getNumParticles
(),
"perDofVariables"
);
perDofValues
=
new
OpenCLParameterSet
(
cl
,
integrator
.
getNumPerDofVariables
(),
3
*
system
.
getNumParticles
(),
"perDofVariables"
);
cl
.
addReorderListener
(
new
ReorderListener
(
cl
,
*
perDofValues
,
localPerDofValues
,
deviceValuesAreCurrent
));
prevStepSize
=
-
1.0
;
prevStepSize
=
-
1.0
;
SimTKOpenMMUtilities
::
setRandomNumberSeed
(
integrator
.
getRandomNumberSeed
());
SimTKOpenMMUtilities
::
setRandomNumberSeed
(
integrator
.
getRandomNumberSeed
());
}
}
...
@@ -3656,7 +3660,6 @@ void OpenCLIntegrateCustomStepKernel::execute(ContextImpl& context, CustomIntegr
...
@@ -3656,7 +3660,6 @@ void OpenCLIntegrateCustomStepKernel::execute(ContextImpl& context, CustomIntegr
invalidatesForces
.
resize
(
numSteps
,
false
);
invalidatesForces
.
resize
(
numSteps
,
false
);
merged
.
resize
(
numSteps
,
false
);
merged
.
resize
(
numSteps
,
false
);
modifiesParameters
=
false
;
modifiesParameters
=
false
;
cl
.
addReorderListener
(
new
ReorderListener
(
cl
,
*
perDofValues
,
localPerDofValues
));
map
<
string
,
string
>
defines
;
map
<
string
,
string
>
defines
;
defines
[
"NUM_ATOMS"
]
=
intToString
(
cl
.
getNumAtoms
());
defines
[
"NUM_ATOMS"
]
=
intToString
(
cl
.
getNumAtoms
());
defines
[
"WORK_GROUP_SIZE"
]
=
intToString
(
OpenCLContext
::
ThreadBlockSize
);
defines
[
"WORK_GROUP_SIZE"
]
=
intToString
(
OpenCLContext
::
ThreadBlockSize
);
...
...
platforms/opencl/tests/TestOpenCLCustomIntegrator.cpp
View file @
b0bda3a1
...
@@ -512,7 +512,8 @@ void testPerDofVariables() {
...
@@ -512,7 +512,8 @@ void testPerDofVariables() {
// Run a simulation, then query per-DOF values and see if they are correct.
// Run a simulation, then query per-DOF values and see if they are correct.
vector
<
Vec3
>
values
;
vector
<
Vec3
>
values
;
for
(
int
i
=
0
;
i
<
100
;
++
i
)
{
context
.
getState
(
State
::
Forces
);
// Cause atom reordering to happen before the first step
for
(
int
i
=
0
;
i
<
200
;
++
i
)
{
integrator
.
step
(
1
);
integrator
.
step
(
1
);
State
state
=
context
.
getState
(
State
::
Positions
);
State
state
=
context
.
getState
(
State
::
Positions
);
integrator
.
getPerDofVariable
(
0
,
values
);
integrator
.
getPerDofVariable
(
0
,
values
);
...
...
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