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
ff238051
Commit
ff238051
authored
May 02, 2018
by
peastman
Browse files
OpenCL implementation of vector functions for CustomIntegrator
parent
ad285083
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
351 additions
and
294 deletions
+351
-294
platforms/opencl/include/OpenCLKernels.h
platforms/opencl/include/OpenCLKernels.h
+8
-9
platforms/opencl/src/OpenCLExpressionUtilities.cpp
platforms/opencl/src/OpenCLExpressionUtilities.cpp
+233
-155
platforms/opencl/src/OpenCLKernels.cpp
platforms/opencl/src/OpenCLKernels.cpp
+103
-126
tests/TestCustomIntegrator.h
tests/TestCustomIntegrator.h
+7
-4
No files found.
platforms/opencl/include/OpenCLKernels.h
View file @
ff238051
...
...
@@ -1484,9 +1484,8 @@ class OpenCLIntegrateCustomStepKernel : public IntegrateCustomStepKernel {
public:
enum
GlobalTargetType
{
DT
,
VARIABLE
,
PARAMETER
};
OpenCLIntegrateCustomStepKernel
(
std
::
string
name
,
const
Platform
&
platform
,
OpenCLContext
&
cl
)
:
IntegrateCustomStepKernel
(
name
,
platform
),
cl
(
cl
),
hasInitializedKernels
(
false
),
localValuesAreCurrent
(
false
),
perDofValues
(
NULL
),
needsEnergyParamDerivs
(
false
)
{
hasInitializedKernels
(
false
),
needsEnergyParamDerivs
(
false
)
{
}
~
OpenCLIntegrateCustomStepKernel
();
/**
* Initialize the kernel.
*
...
...
@@ -1550,7 +1549,7 @@ private:
class
ReorderListener
;
class
GlobalTarget
;
class
DerivFunction
;
std
::
string
createPerDofComputation
(
const
std
::
string
&
variable
,
const
Lepton
::
ParsedExpression
&
expr
,
int
component
,
CustomIntegrator
&
integrator
,
std
::
string
createPerDofComputation
(
const
std
::
string
&
variable
,
const
Lepton
::
ParsedExpression
&
expr
,
CustomIntegrator
&
integrator
,
const
std
::
string
&
forceName
,
const
std
::
string
&
energyName
,
std
::
vector
<
const
TabulatedFunction
*>&
functions
,
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>
>&
functionNames
);
void
prepareForComputation
(
ContextImpl
&
context
,
CustomIntegrator
&
integrator
,
bool
&
forcesAreValid
);
...
...
@@ -1563,21 +1562,21 @@ private:
double
energy
;
float
energyFloat
;
int
numGlobalVariables
,
sumWorkGroupSize
;
bool
hasInitializedKernels
,
deviceValuesAreCurrent
,
deviceGlobalsAreCurrent
,
modifiesParameters
,
keNeedsForce
,
hasAnyConstraints
,
needsEnergyParamDerivs
;
mutable
bool
localValuesAreCurrent
;
bool
hasInitializedKernels
,
deviceGlobalsAreCurrent
,
modifiesParameters
,
keNeedsForce
,
hasAnyConstraints
,
needsEnergyParamDerivs
;
std
::
vector
<
bool
>
deviceValuesAreCurrent
;
mutable
std
::
vector
<
bool
>
localValuesAreCurrent
;
OpenCLArray
globalValues
;
OpenCLArray
sumBuffer
;
OpenCLArray
summedValue
;
OpenCLArray
uniformRandoms
;
OpenCLArray
randomSeed
;
OpenCLArray
perDofEnergyParamDerivs
;
std
::
vector
<
OpenCLArray
>
tabulatedFunctions
;
std
::
vector
<
OpenCLArray
>
tabulatedFunctions
,
perDofValues
;
std
::
map
<
int
,
double
>
savedEnergy
;
std
::
map
<
int
,
OpenCLArray
>
savedForces
;
std
::
set
<
int
>
validSavedForces
;
OpenCLParameterSet
*
perDofValues
;
mutable
std
::
vector
<
std
::
vector
<
cl_float
>
>
localPerDofValuesFloat
;
mutable
std
::
vector
<
std
::
vector
<
cl_double
>
>
localPerDofValuesDouble
;
mutable
std
::
vector
<
std
::
vector
<
mm_float4
>
>
localPerDofValuesFloat
;
mutable
std
::
vector
<
std
::
vector
<
mm_double4
>
>
localPerDofValuesDouble
;
std
::
map
<
std
::
string
,
double
>
energyParamDerivs
;
std
::
vector
<
std
::
string
>
perDofEnergyParamDerivNames
;
std
::
vector
<
cl_float
>
localPerDofEnergyParamDerivsFloat
;
...
...
platforms/opencl/src/OpenCLExpressionUtilities.cpp
View file @
ff238051
This diff is collapsed.
Click to expand it.
platforms/opencl/src/OpenCLKernels.cpp
View file @
ff238051
This diff is collapsed.
Click to expand it.
tests/TestCustomIntegrator.h
View file @
ff238051
...
...
@@ -102,7 +102,6 @@ void testSingleBond() {
*/
void
testConstraints
()
{
const
int
numParticles
=
8
;
const
double
temp
=
500.0
;
System
system
;
CustomIntegrator
integrator
(
0.002
);
integrator
.
addPerDofVariable
(
"oldx"
,
0
);
...
...
@@ -1028,8 +1027,10 @@ void testVectorFunctions() {
CustomIntegrator
integrator
(
0.001
);
integrator
.
addGlobalVariable
(
"sumy"
,
0.0
);
integrator
.
addPerDofVariable
(
"angular"
,
0.0
);
integrator
.
addPerDofVariable
(
"shuffle"
,
0.0
);
integrator
.
addComputeSum
(
"sumy"
,
"x*vector(0, 1, 0)"
);
integrator
.
addComputePerDof
(
"angular"
,
"cross(v, x)"
);
integrator
.
addComputePerDof
(
"shuffle"
,
"dot(vector(_z(x), _x(x), _y(x)), v)"
);
OpenMM_SFMT
::
SFMT
sfmt
;
init_gen_rand
(
0
,
sfmt
);
vector
<
Vec3
>
positions
(
numParticles
);
...
...
@@ -1047,10 +1048,12 @@ void testVectorFunctions() {
// See if the expressions were computed correctly.
double
sumy
=
0
;
vector
<
Vec3
>
values
;
integrator
.
getPerDofVariable
(
0
,
values
);
vector
<
Vec3
>
angular
,
shuffle
;
integrator
.
getPerDofVariable
(
0
,
angular
);
integrator
.
getPerDofVariable
(
1
,
shuffle
);
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
{
ASSERT_EQUAL_VEC
(
velocities
[
i
].
cross
(
positions
[
i
]),
values
[
i
],
1e-5
);
ASSERT_EQUAL_VEC
(
velocities
[
i
].
cross
(
positions
[
i
]),
angular
[
i
],
1e-5
);
ASSERT_EQUAL_VEC
(
Vec3
(
1
,
1
,
1
)
*
velocities
[
i
].
dot
(
Vec3
(
positions
[
i
][
2
],
positions
[
i
][
0
],
positions
[
i
][
1
])),
shuffle
[
i
],
1e-5
);
sumy
+=
positions
[
i
][
1
];
}
ASSERT_EQUAL_TOL
(
sumy
,
integrator
.
getGlobalVariable
(
0
),
1e-5
);
...
...
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