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
7e9cf94b
Commit
7e9cf94b
authored
Oct 22, 2009
by
Peter Eastman
Browse files
Fixed an error on AMD's OpenCL implementation
parent
e43f14bf
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
61 deletions
+52
-61
platforms/opencl/src/OpenCLKernels.cpp
platforms/opencl/src/OpenCLKernels.cpp
+0
-1
platforms/opencl/src/kernels/nonbonded_default.cl
platforms/opencl/src/kernels/nonbonded_default.cl
+52
-60
No files found.
platforms/opencl/src/OpenCLKernels.cpp
View file @
7e9cf94b
...
...
@@ -56,7 +56,6 @@ void OpenCLCalcForcesAndEnergyKernel::beginForceComputation(ContextImpl& context
void
OpenCLCalcForcesAndEnergyKernel
::
finishForceComputation
(
ContextImpl
&
context
)
{
cl
.
getNonbondedUtilities
().
computeInteractions
();
cl
.
reduceBuffer
(
cl
.
getForceBuffers
(),
cl
.
getNumForceBuffers
());
cl
.
getNonbondedUtilities
().
prepareInteractions
();
}
void
OpenCLCalcForcesAndEnergyKernel
::
beginEnergyComputation
(
ContextImpl
&
context
)
{
...
...
platforms/opencl/src/kernels/nonbonded_default.cl
View file @
7e9cf94b
const
unsigned
int
TileSize
=
32
;
#
define
TILE_SIZE
32
/**
*
Compute
nonbonded
interactions.
...
...
@@ -23,12 +23,12 @@ __kernel void computeNonbonded(__global float4* forceBuffers, __global float* en
while
(
pos
<
end
)
{
//
Extract
the
coordinates
of
this
tile
unsigned
int
x
=
tiles[pos]
;
unsigned
int
y
=
((
x
>>
2
)
&
0x7fff
)
*T
ileSize
;
unsigned
int
y
=
((
x
>>
2
)
&
0x7fff
)
*T
ILE_SIZE
;
bool
hasExclusions
=
(
x
&
0x1
)
;
x
=
(
x>>17
)
*T
ileSize
;
unsigned
int
baseLocalAtom
=
(
get_local_id
(
0
)
<
T
ileSize
?
0
:
TileSize
/2
)
;
unsigned
int
tgx
=
get_local_id
(
0
)
&
(
T
ileSize
-1
)
;
unsigned
int
forceBufferOffset
=
(
tgx
<
T
ileSize
/2
?
0
:
T
ileSize
)
;
x
=
(
x>>17
)
*T
ILE_SIZE
;
unsigned
int
baseLocalAtom
=
(
get_local_id
(
0
)
<
T
ILE_SIZE
?
0
:
TILE_SIZE
/2
)
;
unsigned
int
tgx
=
get_local_id
(
0
)
&
(
T
ILE_SIZE
-1
)
;
unsigned
int
forceBufferOffset
=
(
tgx
<
T
ILE_SIZE
/2
?
0
:
T
ILE_SIZE
)
;
unsigned
int
atom1
=
x
+
tgx
;
float4
force
=
0.0f
;
float4
posq1
=
posq[atom1]
;
...
...
@@ -39,12 +39,12 @@ __kernel void computeNonbonded(__global float4* forceBuffers, __global float* en
local_posq[get_local_id
(
0
)
]
=
posq1
;
LOAD_LOCAL_PARAMETERS_FROM_1
barrier
(
CLK_LOCAL_MEM_FENCE
)
;
unsigned
int
xi
=
x/T
ileSize
;
unsigned
int
tile
=
xi+xi*PADDED_NUM_ATOMS/T
ileSize
-xi*
(
xi+1
)
/2
;
unsigned
int
xi
=
x/T
ILE_SIZE
;
unsigned
int
tile
=
xi+xi*PADDED_NUM_ATOMS/T
ILE_SIZE
-xi*
(
xi+1
)
/2
;
#
ifdef
USE_EXCLUSIONS
unsigned
int
excl
=
exclusions[exclusionIndices[tile]+tgx]
>>
baseLocalAtom
;
#
endif
for
(
unsigned
int
j
=
0
; j < T
ileSize
/2; j++) {
for
(
unsigned
int
j
=
0
; j < T
ILE_SIZE
/2; j++) {
#
ifdef
USE_EXCLUSIONS
bool
isExcluded
=
!
(
excl
&
0x1
)
;
#
endif
...
...
@@ -72,48 +72,41 @@ __kernel void computeNonbonded(__global float4* forceBuffers, __global float* en
//
Sum
the
forces
and
write
results.
if
(
get_local_id
(
0
)
>=
T
ileSize
)
if
(
get_local_id
(
0
)
>=
T
ILE_SIZE
)
tempBuffer[get_local_id
(
0
)
]
=
force
;
barrier
(
CLK_LOCAL_MEM_FENCE
)
;
if
(
get_local_id
(
0
)
<
T
ileSize
)
{
if
(
get_local_id
(
0
)
<
T
ILE_SIZE
)
{
#
ifdef
USE_OUTPUT_BUFFER_PER_BLOCK
unsigned
int
offset
=
x
+
tgx
+
(
x/T
ileSize
)
*PADDED_NUM_ATOMS
;
unsigned
int
offset
=
x
+
tgx
+
(
x/T
ILE_SIZE
)
*PADDED_NUM_ATOMS
;
#
else
unsigned
int
offset
=
x
+
tgx
+
get_group_id
(
0
)
*PADDED_NUM_ATOMS
;
#
endif
forceBuffers[offset].xyz
+
=
force.xyz+tempBuffer[get_local_id
(
0
)
+T
ileSize
].xyz
;
forceBuffers[offset].xyz
=
forceBuffers[offset].xyz+
force.xyz+tempBuffer[get_local_id
(
0
)
+T
ILE_SIZE
].xyz
;
}
}
else
{
//
This
is
an
off-diagonal
tile.
if
(
lasty
!=
y
&&
get_local_id
(
0
)
<
T
ileSize
)
{
if
(
lasty
!=
y
&&
get_local_id
(
0
)
<
T
ILE_SIZE
)
{
unsigned
int
j
=
y
+
tgx
;
local_posq[get_local_id
(
0
)
]
=
posq[j]
;
LOAD_LOCAL_PARAMETERS_FROM_GLOBAL
}
local_force[get_local_id
(
0
)
]
=
0.0f
;
barrier
(
CLK_LOCAL_MEM_FENCE
)
;
#
ifdef
USE_CUTOFF
unsigned
int
flags
=
interactionFlags[pos]
;
if
(
!hasExclusions
&&
flags
==
0
)
{
//
No
interactions
in
this
tile.
}
else
#
endif
{
//
Compute
the
full
set
of
interactions
in
this
tile.
unsigned
int
xi
=
x/T
ileSize
;
unsigned
int
yi
=
y/T
ileSize
;
unsigned
int
tile
=
xi+yi*PADDED_NUM_ATOMS/T
ileSize
-yi*
(
yi+1
)
/2
;
unsigned
int
xi
=
x/T
ILE_SIZE
;
unsigned
int
yi
=
y/T
ILE_SIZE
;
unsigned
int
tile
=
xi+yi*PADDED_NUM_ATOMS/T
ILE_SIZE
-yi*
(
yi+1
)
/2
;
#
ifdef
USE_EXCLUSIONS
unsigned
int
excl
=
(
hasExclusions
?
exclusions[exclusionIndices[tile]+tgx]
:
0xFFFFFFFF
)
;
excl
=
(
excl
>>
tgx
)
|
(
excl
<<
(
T
ileSize
-
tgx
))
;
excl
=
(
excl
>>
tgx
)
|
(
excl
<<
(
T
ILE_SIZE
-
tgx
))
;
excl
>>=
baseLocalAtom
;
#
endif
unsigned
int
tj
=
tgx%
(
T
ileSize
/2
)
;
for
(
unsigned
int
j
=
0
; j < T
ileSize
/2; j++) {
unsigned
int
tj
=
tgx%
(
T
ILE_SIZE
/2
)
;
for
(
unsigned
int
j
=
0
; j < T
ILE_SIZE
/2; j++) {
#
ifdef
USE_EXCLUSIONS
bool
isExcluded
=
!
(
excl
&
0x1
)
;
#
endif
...
...
@@ -139,25 +132,24 @@ __kernel void computeNonbonded(__global float4* forceBuffers, __global float* en
local_force[baseLocalAtom+tj+forceBufferOffset].xyz
+=
delta.xyz
;
barrier
(
CLK_LOCAL_MEM_FENCE
)
;
excl
>>=
1
;
tj
=
(
tj+1
)
%
(
TileSize/2
)
;
}
tj
=
(
tj+1
)
%
(
TILE_SIZE/2
)
;
}
//
Sum
the
forces
and
write
results.
if
(
get_local_id
(
0
)
>=
T
ileSize
)
if
(
get_local_id
(
0
)
>=
T
ILE_SIZE
)
tempBuffer[get_local_id
(
0
)
]
=
force
;
barrier
(
CLK_LOCAL_MEM_FENCE
)
;
if
(
get_local_id
(
0
)
<
T
ileSize
)
{
if
(
get_local_id
(
0
)
<
T
ILE_SIZE
)
{
#
ifdef
USE_OUTPUT_BUFFER_PER_BLOCK
unsigned
int
offset1
=
x
+
tgx
+
(
y/T
ileSize
)
*PADDED_NUM_ATOMS
;
unsigned
int
offset2
=
y
+
tgx
+
(
x/T
ileSize
)
*PADDED_NUM_ATOMS
;
unsigned
int
offset1
=
x
+
tgx
+
(
y/T
ILE_SIZE
)
*PADDED_NUM_ATOMS
;
unsigned
int
offset2
=
y
+
tgx
+
(
x/T
ILE_SIZE
)
*PADDED_NUM_ATOMS
;
#
else
unsigned
int
offset1
=
x
+
tgx
+
get_group_id
(
0
)
*PADDED_NUM_ATOMS
;
unsigned
int
offset2
=
y
+
tgx
+
get_group_id
(
0
)
*PADDED_NUM_ATOMS
;
#
endif
forceBuffers[offset1].xyz
+
=
force.xyz+tempBuffer[get_local_id
(
0
)
+T
ileSize
].xyz
;
forceBuffers[offset2].xyz
+
=
local_force[get_local_id
(
0
)
].xyz+local_force[get_local_id
(
0
)
+T
ileSize
].xyz
;
forceBuffers[offset1].xyz
=
forceBuffers[offset1].xyz+
force.xyz+tempBuffer[get_local_id
(
0
)
+T
ILE_SIZE
].xyz
;
forceBuffers[offset2].xyz
=
forceBuffers[offset2].xyz+
local_force[get_local_id
(
0
)
].xyz+local_force[get_local_id
(
0
)
+T
ILE_SIZE
].xyz
;
}
lasty
=
y
;
}
...
...
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