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
d3ec1d0c
Commit
d3ec1d0c
authored
Oct 15, 2009
by
Peter Eastman
Browse files
Bug fixes to GBSA
parent
2a465d40
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
15 deletions
+31
-15
platforms/cuda/src/kernels/kCalculateCDLJObcGbsaForces1.h
platforms/cuda/src/kernels/kCalculateCDLJObcGbsaForces1.h
+1
-1
platforms/opencl/src/OpenCLKernels.cpp
platforms/opencl/src/OpenCLKernels.cpp
+16
-0
platforms/opencl/src/kernels/gbsaObc.cl
platforms/opencl/src/kernels/gbsaObc.cl
+14
-14
No files found.
platforms/cuda/src/kernels/kCalculateCDLJObcGbsaForces1.h
View file @
d3ec1d0c
...
@@ -282,7 +282,7 @@ __global__ void METHOD_NAME(kCalculateCDLJObcGbsa, Forces1_kernel)(unsigned int*
...
@@ -282,7 +282,7 @@ __global__ void METHOD_NAME(kCalculateCDLJObcGbsa, Forces1_kernel)(unsigned int*
of
.
z
+=
af
.
z
;
of
.
z
+=
af
.
z
;
of
.
w
+=
af
.
w
;
of
.
w
+=
af
.
w
;
cSim
.
pForce4a
[
offset
]
=
of
;
cSim
.
pForce4a
[
offset
]
=
of
;
cSim
.
pBornForce
[
offset
]
=
a
f
.
w
;
cSim
.
pBornForce
[
offset
]
=
o
f
.
w
;
#else
#else
unsigned
int
offset
=
x
+
tgx
+
(
x
>>
GRIDBITS
)
*
cSim
.
stride
;
unsigned
int
offset
=
x
+
tgx
+
(
x
>>
GRIDBITS
)
*
cSim
.
stride
;
cSim
.
pForce4a
[
offset
]
=
af
;
cSim
.
pForce4a
[
offset
]
=
af
;
...
...
platforms/opencl/src/OpenCLKernels.cpp
View file @
d3ec1d0c
...
@@ -767,6 +767,21 @@ double OpenCLCalcNonbondedForceKernel::executeEnergy(ContextImpl& context) {
...
@@ -767,6 +767,21 @@ double OpenCLCalcNonbondedForceKernel::executeEnergy(ContextImpl& context) {
// SetCustomNonbondedGlobalParams(&globalParamValues[0]);
// SetCustomNonbondedGlobalParams(&globalParamValues[0]);
//}
//}
//
//
class
OpenCLGBSAOBCForceInfo
:
public
OpenCLForceInfo
{
public:
OpenCLGBSAOBCForceInfo
(
int
requiredBuffers
,
const
GBSAOBCForce
&
force
)
:
OpenCLForceInfo
(
requiredBuffers
),
force
(
force
)
{
}
bool
areParticlesIdentical
(
int
particle1
,
int
particle2
)
{
double
charge1
,
charge2
,
radius1
,
radius2
,
scale1
,
scale2
;
force
.
getParticleParameters
(
particle1
,
charge1
,
radius1
,
scale1
);
force
.
getParticleParameters
(
particle2
,
charge2
,
radius2
,
scale2
);
return
(
charge1
==
charge2
&&
radius1
==
radius2
&&
scale1
==
scale2
);
}
private:
const
GBSAOBCForce
&
force
;
};
OpenCLCalcGBSAOBCForceKernel
::~
OpenCLCalcGBSAOBCForceKernel
()
{
OpenCLCalcGBSAOBCForceKernel
::~
OpenCLCalcGBSAOBCForceKernel
()
{
if
(
params
!=
NULL
)
if
(
params
!=
NULL
)
delete
params
;
delete
params
;
...
@@ -807,6 +822,7 @@ void OpenCLCalcGBSAOBCForceKernel::initialize(const System& system, const GBSAOB
...
@@ -807,6 +822,7 @@ void OpenCLCalcGBSAOBCForceKernel::initialize(const System& system, const GBSAOB
nb
.
addInteraction
(
useCutoff
,
usePeriodic
,
false
,
force
.
getCutoffDistance
(),
vector
<
vector
<
int
>
>
(),
source
);
nb
.
addInteraction
(
useCutoff
,
usePeriodic
,
false
,
force
.
getCutoffDistance
(),
vector
<
vector
<
int
>
>
(),
source
);
nb
.
addParameter
(
OpenCLNonbondedUtilities
::
ParameterInfo
(
"obcParams"
,
"float2"
,
sizeof
(
cl_float2
),
params
->
getDeviceBuffer
()));;
nb
.
addParameter
(
OpenCLNonbondedUtilities
::
ParameterInfo
(
"obcParams"
,
"float2"
,
sizeof
(
cl_float2
),
params
->
getDeviceBuffer
()));;
nb
.
addParameter
(
OpenCLNonbondedUtilities
::
ParameterInfo
(
"bornForce"
,
"float"
,
sizeof
(
cl_float
),
bornForce
->
getDeviceBuffer
()));;
nb
.
addParameter
(
OpenCLNonbondedUtilities
::
ParameterInfo
(
"bornForce"
,
"float"
,
sizeof
(
cl_float
),
bornForce
->
getDeviceBuffer
()));;
cl
.
addForce
(
new
OpenCLGBSAOBCForceInfo
(
nb
.
getNumForceBuffers
(),
force
));
}
}
void
OpenCLCalcGBSAOBCForceKernel
::
executeForces
(
ContextImpl
&
context
)
{
void
OpenCLCalcGBSAOBCForceKernel
::
executeForces
(
ContextImpl
&
context
)
{
...
...
platforms/opencl/src/kernels/gbsaObc.cl
View file @
d3ec1d0c
...
@@ -109,6 +109,7 @@ __kernel void computeBornSum(int numAtoms, int paddedNumAtoms, __global float* g
...
@@ -109,6 +109,7 @@ __kernel void computeBornSum(int numAtoms, int paddedNumAtoms, __global float* g
delta.z
-=
floor
(
delta.z/periodicBoxSize.z+0.5f
)
*periodicBoxSize.z
;
delta.z
-=
floor
(
delta.z/periodicBoxSize.z+0.5f
)
*periodicBoxSize.z
;
#
endif
#
endif
float
r2
=
delta.x*delta.x
+
delta.y*delta.y
+
delta.z*delta.z
;
float
r2
=
delta.x*delta.x
+
delta.y*delta.y
+
delta.z*delta.z
;
tempBuffer[get_local_id
(
0
)
]
=
0.0f
;
#
ifdef
USE_CUTOFF
#
ifdef
USE_CUTOFF
if
(
atom1
<
numAtoms
&&
y+j
<
numAtoms
&&
r2
<
cutoffSquared
)
{
if
(
atom1
<
numAtoms
&&
y+j
<
numAtoms
&&
r2
<
cutoffSquared
)
{
#
else
#
else
...
@@ -118,7 +119,7 @@ __kernel void computeBornSum(int numAtoms, int paddedNumAtoms, __global float* g
...
@@ -118,7 +119,7 @@ __kernel void computeBornSum(int numAtoms, int paddedNumAtoms, __global float* g
float
invR
=
1.0f/r
;
float
invR
=
1.0f/r
;
float2
params2
=
local_params[tbx+j]
;
float2
params2
=
local_params[tbx+j]
;
float
rScaledRadiusJ
=
r+params2.y
;
float
rScaledRadiusJ
=
r+params2.y
;
if
((
j
!=
tgx
)
&&
(
params1.x
<
rScaledRadiusJ
)
)
{
if
(
params1.x
<
rScaledRadiusJ
)
{
float
l_ij
=
1.0f/max
(
params1.x,
fabs
(
r-params2.y
))
;
float
l_ij
=
1.0f/max
(
params1.x,
fabs
(
r-params2.y
))
;
float
u_ij
=
1.0f/rScaledRadiusJ
;
float
u_ij
=
1.0f/rScaledRadiusJ
;
float
l_ij2
=
l_ij*l_ij
;
float
l_ij2
=
l_ij*l_ij
;
...
@@ -130,7 +131,7 @@ __kernel void computeBornSum(int numAtoms, int paddedNumAtoms, __global float* g
...
@@ -130,7 +131,7 @@ __kernel void computeBornSum(int numAtoms, int paddedNumAtoms, __global float* g
bornSum
+=
2.0f*
(
1.0f/params1.x-l_ij
)
;
bornSum
+=
2.0f*
(
1.0f/params1.x-l_ij
)
;
}
}
float
rScaledRadiusI
=
r+params1.y
;
float
rScaledRadiusI
=
r+params1.y
;
if
((
j
!=
tgx
)
&&
(
params2.x
<
rScaledRadiusJ
)
)
{
if
(
params2.x
<
rScaledRadiusJ
)
{
float
l_ij
=
1.0f/max
(
params2.x,
fabs
(
r-params1.y
))
;
float
l_ij
=
1.0f/max
(
params2.x,
fabs
(
r-params1.y
))
;
float
u_ij
=
1.0f/rScaledRadiusJ
;
float
u_ij
=
1.0f/rScaledRadiusJ
;
float
l_ij2
=
l_ij*l_ij
;
float
l_ij2
=
l_ij*l_ij
;
...
@@ -185,7 +186,7 @@ __kernel void computeBornSum(int numAtoms, int paddedNumAtoms, __global float* g
...
@@ -185,7 +186,7 @@ __kernel void computeBornSum(int numAtoms, int paddedNumAtoms, __global float* g
float
invR
=
1.0f/r
;
float
invR
=
1.0f/r
;
float2
params2
=
local_params[tbx+tj]
;
float2
params2
=
local_params[tbx+tj]
;
float
rScaledRadiusJ
=
r+params2.y
;
float
rScaledRadiusJ
=
r+params2.y
;
if
((
tj
!=
tgx
)
&&
(
params1.x
<
rScaledRadiusJ
)
)
{
if
(
params1.x
<
rScaledRadiusJ
)
{
float
l_ij
=
1.0f/max
(
params1.x,
fabs
(
r-params2.y
))
;
float
l_ij
=
1.0f/max
(
params1.x,
fabs
(
r-params2.y
))
;
float
u_ij
=
1.0f/rScaledRadiusJ
;
float
u_ij
=
1.0f/rScaledRadiusJ
;
float
l_ij2
=
l_ij*l_ij
;
float
l_ij2
=
l_ij*l_ij
;
...
@@ -197,7 +198,7 @@ __kernel void computeBornSum(int numAtoms, int paddedNumAtoms, __global float* g
...
@@ -197,7 +198,7 @@ __kernel void computeBornSum(int numAtoms, int paddedNumAtoms, __global float* g
bornSum
+=
2.0f*
(
1.0f/params1.x-l_ij
)
;
bornSum
+=
2.0f*
(
1.0f/params1.x-l_ij
)
;
}
}
float
rScaledRadiusI
=
r+params1.y
;
float
rScaledRadiusI
=
r+params1.y
;
if
((
tj
!=
tgx
)
&&
(
params2.x
<
rScaledRadiusJ
)
)
{
if
(
params2.x
<
rScaledRadiusJ
)
{
float
l_ij
=
1.0f/max
(
params2.x,
fabs
(
r-params1.y
))
;
float
l_ij
=
1.0f/max
(
params2.x,
fabs
(
r-params1.y
))
;
float
u_ij
=
1.0f/rScaledRadiusJ
;
float
u_ij
=
1.0f/rScaledRadiusJ
;
float
l_ij2
=
l_ij*l_ij
;
float
l_ij2
=
l_ij*l_ij
;
...
@@ -207,7 +208,7 @@ __kernel void computeBornSum(int numAtoms, int paddedNumAtoms, __global float* g
...
@@ -207,7 +208,7 @@ __kernel void computeBornSum(int numAtoms, int paddedNumAtoms, __global float* g
(
0.25f*params1.y*params1.y*invR
)
*
(
l_ij2-u_ij2
)
;
(
0.25f*params1.y*params1.y*invR
)
*
(
l_ij2-u_ij2
)
;
if
(
params2.x
<
params1.x-r
)
if
(
params2.x
<
params1.x-r
)
term
+=
2.0f*
(
1.0f/params2.x-l_ij
)
;
term
+=
2.0f*
(
1.0f/params2.x-l_ij
)
;
local_bornSum[tbx+tj]
=
term
;
local_bornSum[tbx+tj]
+
=
term
;
}
}
}
}
tj
=
(
tj
+
1
)
&
(
TileSize
-
1
)
;
tj
=
(
tj
+
1
)
&
(
TileSize
-
1
)
;
...
@@ -245,7 +246,6 @@ __kernel void reduceBornSum(int numAtoms, int bufferSize, int numBuffers, float
...
@@ -245,7 +246,6 @@ __kernel void reduceBornSum(int numAtoms, int bufferSize, int numBuffers, float
float
sum
=
bornSum[index]
;
float
sum
=
bornSum[index]
;
for
(
int
i
=
index+bufferSize
; i < totalSize; i += bufferSize)
for
(
int
i
=
index+bufferSize
; i < totalSize; i += bufferSize)
sum
+=
bornSum[i]
;
sum
+=
bornSum[i]
;
bornSum[index]
=
sum
;
//
Now
calculate
Born
radius
and
OBC
term.
//
Now
calculate
Born
radius
and
OBC
term.
...
@@ -254,10 +254,10 @@ __kernel void reduceBornSum(int numAtoms, int bufferSize, int numBuffers, float
...
@@ -254,10 +254,10 @@ __kernel void reduceBornSum(int numAtoms, int bufferSize, int numBuffers, float
float
sum2
=
sum*sum
;
float
sum2
=
sum*sum
;
float
sum3
=
sum*sum2
;
float
sum3
=
sum*sum2
;
float
tanhSum
=
tanh
(
alpha*sum
-
beta*sum2
+
gamma*sum3
)
;
float
tanhSum
=
tanh
(
alpha*sum
-
beta*sum2
+
gamma*sum3
)
;
float
nonOffsetRadi
i
=
offsetRadius
+
dielectricOffset
;
float
nonOffsetRadi
us
=
offsetRadius
+
dielectricOffset
;
float
radius
=
1.0f/
(
1.0f/offsetRadius
-
tanhSum/nonOffsetRadi
i
)
;
float
radius
=
1.0f/
(
1.0f/offsetRadius
-
tanhSum/nonOffsetRadi
us
)
;
float
chain
=
offsetRadius*
(
alpha
-
2.0f*beta*sum
+
3.0f*gamma*sum2
)
;
float
chain
=
offsetRadius*
(
alpha
-
2.0f*beta*sum
+
3.0f*gamma*sum2
)
;
chain
=
(
1.0f-tanhSum*tanhSum
)
*chain
/
nonOffsetRadi
i
;
chain
=
(
1.0f-tanhSum*tanhSum
)
*chain
/
nonOffsetRadi
us
;
bornRadii[index]
=
radius
;
bornRadii[index]
=
radius
;
obcChain[index]
=
chain
;
obcChain[index]
=
chain
;
index
+=
get_global_size
(
0
)
;
index
+=
get_global_size
(
0
)
;
...
@@ -347,7 +347,7 @@ __kernel void computeGBSAForce1(int numAtoms, int paddedNumAtoms, float prefacto
...
@@ -347,7 +347,7 @@ __kernel void computeGBSAForce1(int numAtoms, int paddedNumAtoms, float prefacto
unsigned
int
offset
=
x
+
tgx
+
warp*paddedNumAtoms
;
unsigned
int
offset
=
x
+
tgx
+
warp*paddedNumAtoms
;
#
endif
#
endif
forceBuffers[offset].xyz
+=
force.xyz
;
forceBuffers[offset].xyz
+=
force.xyz
;
global_bornForce[offset]
=
force.w
;
global_bornForce[offset]
+
=
force.w
;
}
}
else
{
else
{
//
This
is
an
off-diagonal
tile.
//
This
is
an
off-diagonal
tile.
...
@@ -401,7 +401,7 @@ __kernel void computeGBSAForce1(int numAtoms, int paddedNumAtoms, float prefacto
...
@@ -401,7 +401,7 @@ __kernel void computeGBSAForce1(int numAtoms, int paddedNumAtoms, float prefacto
energy
+=
tempEnergy
;
energy
+=
tempEnergy
;
delta.xyz
*=
dEdR
;
delta.xyz
*=
dEdR
;
force.xyz
-=
delta.xyz
;
force.xyz
-=
delta.xyz
;
tempBuffer[get_local_id
(
0
)
]
=
(
float4
)
(
delta.xyz,
dGpol_dalpha2_ij*bornRadius
2
)
;
tempBuffer[get_local_id
(
0
)
]
=
(
float4
)
(
delta.xyz,
dGpol_dalpha2_ij*bornRadius
1
)
;
//
Sum
the
forces
on
atom
j.
//
Sum
the
forces
on
atom
j.
...
@@ -459,7 +459,7 @@ __kernel void computeGBSAForce1(int numAtoms, int paddedNumAtoms, float prefacto
...
@@ -459,7 +459,7 @@ __kernel void computeGBSAForce1(int numAtoms, int paddedNumAtoms, float prefacto
energy
+=
tempEnergy
;
energy
+=
tempEnergy
;
delta.xyz
*=
dEdR
;
delta.xyz
*=
dEdR
;
force.xyz
-=
delta.xyz
;
force.xyz
-=
delta.xyz
;
local_force[tbx+tj]
.xyz
+=
delta.xyz
;
local_force[tbx+tj]
+=
(
float4
)
(
delta.xyz,
dGpol_dalpha2_ij*bornRadius1
)
;
}
}
tj
=
(
tj
+
1
)
&
(
TileSize
-
1
)
;
tj
=
(
tj
+
1
)
&
(
TileSize
-
1
)
;
}
}
...
@@ -475,8 +475,8 @@ __kernel void computeGBSAForce1(int numAtoms, int paddedNumAtoms, float prefacto
...
@@ -475,8 +475,8 @@ __kernel void computeGBSAForce1(int numAtoms, int paddedNumAtoms, float prefacto
#
endif
#
endif
forceBuffers[offset1].xyz
+=
force.xyz
;
forceBuffers[offset1].xyz
+=
force.xyz
;
forceBuffers[offset2].xyz
+=
local_force[get_local_id
(
0
)
].xyz
;
forceBuffers[offset2].xyz
+=
local_force[get_local_id
(
0
)
].xyz
;
global_bornForce[offset1]
=
force.w
;
global_bornForce[offset1]
+
=
force.w
;
global_bornForce[offset2]
=
local_force[get_local_id
(
0
)
].w
;
global_bornForce[offset2]
+
=
local_force[get_local_id
(
0
)
].w
;
lasty
=
y
;
lasty
=
y
;
}
}
pos++
;
pos++
;
...
...
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