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
73369ddd
Commit
73369ddd
authored
Oct 17, 2011
by
Peter Eastman
Browse files
Minor optimizations to reorderAtoms()
parent
2927116e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
20 deletions
+24
-20
platforms/opencl/src/OpenCLContext.cpp
platforms/opencl/src/OpenCLContext.cpp
+24
-20
No files found.
platforms/opencl/src/OpenCLContext.cpp
View file @
73369ddd
...
@@ -590,12 +590,13 @@ void OpenCLContext::reorderAtoms() {
...
@@ -590,12 +590,13 @@ void OpenCLContext::reorderAtoms() {
}
}
else
{
else
{
for
(
int
i
=
1
;
i
<
numAtoms
;
i
++
)
{
for
(
int
i
=
1
;
i
<
numAtoms
;
i
++
)
{
minx
=
min
(
minx
,
posq
->
get
(
i
).
x
);
const
mm_float4
&
pos
=
posq
->
get
(
i
);
maxx
=
max
(
maxx
,
posq
->
get
(
i
).
x
);
minx
=
min
(
minx
,
pos
.
x
);
miny
=
min
(
miny
,
posq
->
get
(
i
).
y
);
maxx
=
max
(
maxx
,
pos
.
x
);
maxy
=
max
(
maxy
,
posq
->
get
(
i
).
y
);
miny
=
min
(
miny
,
pos
.
y
);
minz
=
min
(
minz
,
posq
->
get
(
i
).
z
);
maxy
=
max
(
maxy
,
pos
.
y
);
maxz
=
max
(
maxz
,
posq
->
get
(
i
).
z
);
minz
=
min
(
minz
,
pos
.
z
);
maxz
=
max
(
maxz
,
pos
.
z
);
}
}
}
}
...
@@ -612,27 +613,29 @@ void OpenCLContext::reorderAtoms() {
...
@@ -612,27 +613,29 @@ void OpenCLContext::reorderAtoms() {
int
numMolecules
=
mol
.
instances
.
size
();
int
numMolecules
=
mol
.
instances
.
size
();
vector
<
int
>&
atoms
=
mol
.
atoms
;
vector
<
int
>&
atoms
=
mol
.
atoms
;
vector
<
mm_float4
>
molPos
(
numMolecules
);
vector
<
mm_float4
>
molPos
(
numMolecules
);
float
invNumAtoms
=
1.0
f
/
atoms
.
size
();
for
(
int
i
=
0
;
i
<
numMolecules
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numMolecules
;
i
++
)
{
molPos
[
i
].
x
=
0.0
f
;
molPos
[
i
].
x
=
0.0
f
;
molPos
[
i
].
y
=
0.0
f
;
molPos
[
i
].
y
=
0.0
f
;
molPos
[
i
].
z
=
0.0
f
;
molPos
[
i
].
z
=
0.0
f
;
for
(
int
j
=
0
;
j
<
(
int
)
atoms
.
size
();
j
++
)
{
for
(
int
j
=
0
;
j
<
(
int
)
atoms
.
size
();
j
++
)
{
int
atom
=
atoms
[
j
]
+
mol
.
instances
[
i
];
int
atom
=
atoms
[
j
]
+
mol
.
instances
[
i
];
molPos
[
i
].
x
+=
posq
->
get
(
atom
).
x
;
const
mm_float4
&
pos
=
posq
->
get
(
atom
);
molPos
[
i
].
y
+=
posq
->
get
(
atom
).
y
;
molPos
[
i
].
x
+=
pos
.
x
;
molPos
[
i
].
z
+=
posq
->
get
(
atom
).
z
;
molPos
[
i
].
y
+=
pos
.
y
;
molPos
[
i
].
z
+=
pos
.
z
;
}
}
molPos
[
i
].
x
/
=
atoms
.
size
()
;
molPos
[
i
].
x
*
=
invNumAtoms
;
molPos
[
i
].
y
/
=
atoms
.
size
()
;
molPos
[
i
].
y
*
=
invNumAtoms
;
molPos
[
i
].
z
/
=
atoms
.
size
()
;
molPos
[
i
].
z
*
=
invNumAtoms
;
}
}
if
(
nonbonded
->
getUsePeriodic
())
{
if
(
nonbonded
->
getUsePeriodic
())
{
// Move each molecule position into the same box.
// Move each molecule position into the same box.
for
(
int
i
=
0
;
i
<
numMolecules
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numMolecules
;
i
++
)
{
int
xcell
=
(
int
)
floor
(
molPos
[
i
].
x
/
p
eriodicBoxSize
.
x
);
int
xcell
=
(
int
)
floor
(
molPos
[
i
].
x
*
invP
eriodicBoxSize
.
x
);
int
ycell
=
(
int
)
floor
(
molPos
[
i
].
y
/
p
eriodicBoxSize
.
y
);
int
ycell
=
(
int
)
floor
(
molPos
[
i
].
y
*
invP
eriodicBoxSize
.
y
);
int
zcell
=
(
int
)
floor
(
molPos
[
i
].
z
/
p
eriodicBoxSize
.
z
);
int
zcell
=
(
int
)
floor
(
molPos
[
i
].
z
*
invP
eriodicBoxSize
.
z
);
float
dx
=
xcell
*
periodicBoxSize
.
x
;
float
dx
=
xcell
*
periodicBoxSize
.
x
;
float
dy
=
ycell
*
periodicBoxSize
.
y
;
float
dy
=
ycell
*
periodicBoxSize
.
y
;
float
dz
=
zcell
*
periodicBoxSize
.
z
;
float
dz
=
zcell
*
periodicBoxSize
.
z
;
...
@@ -663,14 +666,15 @@ void OpenCLContext::reorderAtoms() {
...
@@ -663,14 +666,15 @@ void OpenCLContext::reorderAtoms() {
binWidth
=
(
float
)(
max
(
max
(
maxx
-
minx
,
maxy
-
miny
),
maxz
-
minz
)
/
255.0
);
binWidth
=
(
float
)(
max
(
max
(
maxx
-
minx
,
maxy
-
miny
),
maxz
-
minz
)
/
255.0
);
else
else
binWidth
=
(
float
)(
0.2
*
nonbonded
->
getCutoffDistance
());
binWidth
=
(
float
)(
0.2
*
nonbonded
->
getCutoffDistance
());
int
xbins
=
1
+
(
int
)
((
maxx
-
minx
)
/
binWidth
);
float
invBinWidth
=
1.0
f
/
binWidth
;
int
ybins
=
1
+
(
int
)
((
maxy
-
miny
)
/
binWidth
);
int
xbins
=
1
+
(
int
)
((
maxx
-
minx
)
*
invBinWidth
);
int
ybins
=
1
+
(
int
)
((
maxy
-
miny
)
*
invBinWidth
);
vector
<
pair
<
int
,
int
>
>
molBins
(
numMolecules
);
vector
<
pair
<
int
,
int
>
>
molBins
(
numMolecules
);
bitmask_t
coords
[
3
];
bitmask_t
coords
[
3
];
for
(
int
i
=
0
;
i
<
numMolecules
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numMolecules
;
i
++
)
{
int
x
=
(
int
)
((
molPos
[
i
].
x
-
minx
)
/
b
inWidth
);
int
x
=
(
int
)
((
molPos
[
i
].
x
-
minx
)
*
invB
inWidth
);
int
y
=
(
int
)
((
molPos
[
i
].
y
-
miny
)
/
b
inWidth
);
int
y
=
(
int
)
((
molPos
[
i
].
y
-
miny
)
*
invB
inWidth
);
int
z
=
(
int
)
((
molPos
[
i
].
z
-
minz
)
/
b
inWidth
);
int
z
=
(
int
)
((
molPos
[
i
].
z
-
minz
)
*
invB
inWidth
);
int
bin
;
int
bin
;
if
(
useHilbert
)
{
if
(
useHilbert
)
{
coords
[
0
]
=
x
;
coords
[
0
]
=
x
;
...
...
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