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
3344bb7a
"examples/hello/HelloSodiumChloride.cpp" did not exist on "9a985f07ca28d3d68cea7cfc0f89d51a84615392"
Commit
3344bb7a
authored
Apr 28, 2010
by
Peter Eastman
Browse files
Switched erfc table to use constant memory instead of texture cache
parent
40891bab
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
36 deletions
+19
-36
platforms/opencl/src/OpenCLKernels.cpp
platforms/opencl/src/OpenCLKernels.cpp
+8
-26
platforms/opencl/src/OpenCLKernels.h
platforms/opencl/src/OpenCLKernels.h
+1
-1
platforms/opencl/src/kernels/coulombLennardJones.cl
platforms/opencl/src/kernels/coulombLennardJones.cl
+10
-9
No files found.
platforms/opencl/src/OpenCLKernels.cpp
View file @
3344bb7a
...
...
@@ -1209,32 +1209,14 @@ void OpenCLCalcNonbondedForceKernel::initialize(const System& system, const Nonb
// Tabulate values of erfc().
if
(
force
.
getNonbondedMethod
()
==
NonbondedForce
::
Ewald
||
force
.
getNonbondedMethod
()
==
NonbondedForce
::
PME
)
{
if
(
cl
.
getDevice
().
getInfo
<
CL_DEVICE_IMAGE_SUPPORT
>
())
{
try
{
const
int
tableSize
=
2048
;
defines
[
"USE_TABULATED_ERFC"
]
=
"1"
;
defines
[
"ERFC_TABLE_SCALE"
]
=
doubleToString
((
tableSize
-
1
)
/
(
alpha
*
force
.
getCutoffDistance
()));
erfcTable
=
new
cl
::
Image2D
(
cl
.
getContext
(),
CL_MEM_READ_ONLY
,
cl
::
ImageFormat
(
CL_INTENSITY
,
CL_FLOAT
),
tableSize
,
1
,
0
);
erfcTable
=
new
OpenCLArray
<
cl_float
>
(
cl
,
tableSize
,
"ErfcTable"
,
false
,
CL_MEM_READ_ONLY
);
vector
<
cl_float
>
erfcVector
(
tableSize
);
for
(
int
i
=
0
;
i
<
tableSize
;
++
i
)
erfcVector
[
i
]
=
(
float
)
erfc
(
i
*
(
alpha
*
force
.
getCutoffDistance
())
/
(
tableSize
-
1
));
cl
::
size_t
<
3
>
origin
,
region
;
origin
.
push_back
(
0
);
origin
.
push_back
(
0
);
origin
.
push_back
(
0
);
region
.
push_back
(
tableSize
);
region
.
push_back
(
1
);
region
.
push_back
(
1
);
cl
.
getQueue
().
enqueueWriteImage
(
*
erfcTable
,
CL_TRUE
,
origin
,
region
,
0
,
0
,
&
erfcVector
[
0
]);
cl
.
getNonbondedUtilities
().
addArgument
(
OpenCLNonbondedUtilities
::
ParameterInfo
(
"erfcTable"
,
"image2d_t"
,
sizeof
(
cl_float
),
*
erfcTable
));
}
catch
(
cl
::
Error
err
)
{
std
::
stringstream
str
;
str
<<
"Error creating erfc() image: "
<<
err
.
what
()
<<
" ("
<<
err
.
err
()
<<
")"
;
throw
OpenMMException
(
str
.
str
());
}
}
erfcTable
->
upload
(
erfcVector
);
cl
.
getNonbondedUtilities
().
addArgument
(
OpenCLNonbondedUtilities
::
ParameterInfo
(
"erfcTable"
,
"float"
,
sizeof
(
cl_float
),
erfcTable
->
getDeviceBuffer
()));
}
// Add the interaction to the default nonbonded kernel.
...
...
platforms/opencl/src/OpenCLKernels.h
View file @
3344bb7a
...
...
@@ -476,9 +476,9 @@ private:
OpenCLArray
<
mm_float4
>*
pmeBsplineDtheta
;
OpenCLArray
<
cl_int
>*
pmeAtomRange
;
OpenCLArray
<
mm_float2
>*
pmeAtomGridIndex
;
OpenCLArray
<
cl_float
>*
erfcTable
;
OpenCLSort
<
mm_float2
>*
sort
;
OpenCLFFT3D
*
fft
;
cl
::
Image2D
*
erfcTable
;
cl
::
Kernel
exceptionsKernel
;
cl
::
Kernel
ewaldSumsKernel
;
cl
::
Kernel
ewaldForcesKernel
;
...
...
platforms/opencl/src/kernels/coulombLennardJones.cl
View file @
3344bb7a
...
...
@@ -3,15 +3,16 @@ bool needCorrection = isExcluded && atom1 != atom2 && atom1 < NUM_ATOMS && atom2
if
(
!isExcluded
||
needCorrection
)
{
const
float
prefactor
=
138.935456f*posq1.w*posq2.w*invR
;
float
alphaR
=
EWALD_ALPHA*r
;
#
ifdef
USE_TABULATED_ERFC
float
erfcAlphaR
=
0.0f
;
if
(
r2
<
CUTOFF_SQUARED
)
{
float
normalized
=
ERFC_TABLE_SCALE*alphaR
;
int
tableIndex
=
(
int
)
normalized
;
float
fract2
=
normalized-tableIndex
;
float
fract1
=
1.0f-fract2
;
float
erfcAlphaR
=
fract1*
read_imagef
(
erfcTable,
sampler,
(
int2
)(
tableIndex
,
0
))
.
x
+
fract2*
read_imagef
(
erfcTable,
sampler,
(
int2
)(
tableIndex+1
,
0
))
.
x
;
#
else
float
erfcAlphaR
=
erfc
(
alphaR
)
;
#
endif
erfcAlphaR
=
fract1*
erfcTable[
tableIndex
]
+
fract2*
erfcTable[
tableIndex+1
]
;
}
else
if
(
needCorrection
)
erfcAlphaR
=
erfc
(
alphaR
)
;
float
tempForce
=
0.0f
;
if
(
needCorrection
)
{
//
Subtract
off
the
part
of
this
interaction
that
was
included
in
the
reciprocal
space
contribution.
...
...
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