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
14125aa9
Commit
14125aa9
authored
Apr 20, 2010
by
Peter Eastman
Browse files
Fixed bugs in OpenCL CustomHbondForce
parent
f2012ad8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
6 deletions
+10
-6
platforms/opencl/src/OpenCLKernels.cpp
platforms/opencl/src/OpenCLKernels.cpp
+6
-2
platforms/opencl/src/kernels/customHbondForce.cl
platforms/opencl/src/kernels/customHbondForce.cl
+4
-4
No files found.
platforms/opencl/src/OpenCLKernels.cpp
View file @
14125aa9
...
@@ -2596,10 +2596,14 @@ void OpenCLCalcCustomHbondForceKernel::initialize(const System& system, const Cu
...
@@ -2596,10 +2596,14 @@ void OpenCLCalcCustomHbondForceKernel::initialize(const System& system, const Cu
vector
<
mm_int4
>
acceptorBufferVector
(
numAcceptors
);
vector
<
mm_int4
>
acceptorBufferVector
(
numAcceptors
);
vector
<
int
>
donorBufferCounter
(
numParticles
,
0
);
vector
<
int
>
donorBufferCounter
(
numParticles
,
0
);
for
(
int
i
=
0
;
i
<
numDonors
;
i
++
)
for
(
int
i
=
0
;
i
<
numDonors
;
i
++
)
donorBufferVector
[
i
]
=
mm_int4
(
donorBufferCounter
[
donorVector
[
i
].
x
]
++
,
donorBufferCounter
[
donorVector
[
i
].
y
]
++
,
donorBufferCounter
[
donorVector
[
i
].
z
]
++
,
0
);
donorBufferVector
[
i
]
=
mm_int4
(
donorVector
[
i
].
x
>
-
1
?
donorBufferCounter
[
donorVector
[
i
].
x
]
++
:
0
,
donorVector
[
i
].
y
>
-
1
?
donorBufferCounter
[
donorVector
[
i
].
y
]
++
:
0
,
donorVector
[
i
].
z
>
-
1
?
donorBufferCounter
[
donorVector
[
i
].
z
]
++
:
0
,
0
);
vector
<
int
>
acceptorBufferCounter
(
numParticles
,
0
);
vector
<
int
>
acceptorBufferCounter
(
numParticles
,
0
);
for
(
int
i
=
0
;
i
<
numAcceptors
;
i
++
)
for
(
int
i
=
0
;
i
<
numAcceptors
;
i
++
)
acceptorBufferVector
[
i
]
=
mm_int4
(
acceptorBufferCounter
[
acceptorVector
[
i
].
x
]
++
,
acceptorBufferCounter
[
acceptorVector
[
i
].
y
]
++
,
acceptorBufferCounter
[
acceptorVector
[
i
].
z
]
++
,
0
);
acceptorBufferVector
[
i
]
=
mm_int4
(
acceptorVector
[
i
].
x
>
-
1
?
acceptorBufferCounter
[
acceptorVector
[
i
].
x
]
++
:
0
,
acceptorVector
[
i
].
y
>
-
1
?
acceptorBufferCounter
[
acceptorVector
[
i
].
y
]
++
:
0
,
acceptorVector
[
i
].
z
>
-
1
?
acceptorBufferCounter
[
acceptorVector
[
i
].
z
]
++
:
0
,
0
);
donorBufferIndices
->
upload
(
donorBufferVector
);
donorBufferIndices
->
upload
(
donorBufferVector
);
acceptorBufferIndices
->
upload
(
acceptorBufferVector
);
acceptorBufferIndices
->
upload
(
acceptorBufferVector
);
int
maxBuffers
=
1
;
int
maxBuffers
=
1
;
...
...
platforms/opencl/src/kernels/customHbondForce.cl
View file @
14125aa9
...
@@ -26,15 +26,15 @@ float4 deltaPeriodic(float4 vec1, float4 vec2) {
...
@@ -26,15 +26,15 @@ float4 deltaPeriodic(float4 vec1, float4 vec2) {
*
Compute
the
angle
between
two
vectors.
The
w
component
of
each
vector
should
contain
the
squared
magnitude.
*
Compute
the
angle
between
two
vectors.
The
w
component
of
each
vector
should
contain
the
squared
magnitude.
*/
*/
float
computeAngle
(
float4
vec1,
float4
vec2
)
{
float
computeAngle
(
float4
vec1,
float4
vec2
)
{
float
dot
=
vec1.x*vec2.x
+
vec1.y*vec2.y
+
vec1.z*vec2.z
;
float
dot
Product
=
vec1.x*vec2.x
+
vec1.y*vec2.y
+
vec1.z*vec2.z
;
float
cosine
=
dot/sqrt
(
vec1.w*vec2.w
)
;
float
cosine
=
dot
Product
/sqrt
(
vec1.w*vec2.w
)
;
float
angle
;
float
angle
;
if
(
cosine
>
0.99f
|
| cosine < -0.99f) {
if
(
cosine
>
0.99f
|
| cosine < -0.99f) {
// We're close to the singularity in acos(), so take the cross product and use asin() instead.
// We're close to the singularity in acos(), so take the cross product and use asin() instead.
float4 cross
_p
rod = cross(vec1, vec2);
float4 cross
P
rod
uct
= cross(vec1, vec2);
float scale = vec1.w*vec2.w;
float scale = vec1.w*vec2.w;
angle = asin(sqrt(dot(cross
_p
rod, cross
_p
rod)/scale));
angle = asin(sqrt(dot(cross
P
rod
uct
, cross
P
rod
uct
)/scale));
if (cosine < 0.0f)
if (cosine < 0.0f)
angle = M_PI-angle;
angle = M_PI-angle;
}
}
...
...
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