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
5b591ab0
Commit
5b591ab0
authored
Oct 23, 2014
by
peastman
Browse files
Merge pull request #669 from peastman/custom
Minor optimization to discrete tabulated functions
parents
98652498
87ea8433
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
12 deletions
+12
-12
platforms/cuda/src/CudaExpressionUtilities.cpp
platforms/cuda/src/CudaExpressionUtilities.cpp
+6
-6
platforms/opencl/src/OpenCLExpressionUtilities.cpp
platforms/opencl/src/OpenCLExpressionUtilities.cpp
+6
-6
No files found.
platforms/cuda/src/CudaExpressionUtilities.cpp
View file @
5b591ab0
...
...
@@ -239,7 +239,7 @@ void CudaExpressionUtilities::processExpression(stringstream& out, const Express
if
(
derivOrder
[
0
]
==
0
)
{
out
<<
"real x = "
<<
getTempName
(
node
.
getChildren
()[
0
],
temps
)
<<
";
\n
"
;
out
<<
"if (x >= 0 && x < "
<<
paramsInt
[
0
]
<<
") {
\n
"
;
out
<<
"int index = (int)
round(x
);
\n
"
;
out
<<
"int index = (int)
floor(x+0.5f
);
\n
"
;
out
<<
nodeNames
[
j
]
<<
" = "
<<
functionNames
[
i
].
second
<<
"[index];
\n
"
;
out
<<
"}
\n
"
;
}
...
...
@@ -249,8 +249,8 @@ void CudaExpressionUtilities::processExpression(stringstream& out, const Express
for
(
int
j
=
0
;
j
<
nodes
.
size
();
j
++
)
{
const
vector
<
int
>&
derivOrder
=
dynamic_cast
<
const
Operation
::
Custom
*>
(
&
nodes
[
j
]
->
getOperation
())
->
getDerivOrder
();
if
(
derivOrder
[
0
]
==
0
&&
derivOrder
[
1
]
==
0
)
{
out
<<
"int x = (int)
round
("
<<
getTempName
(
node
.
getChildren
()[
0
],
temps
)
<<
");
\n
"
;
out
<<
"int y = (int)
round
("
<<
getTempName
(
node
.
getChildren
()[
1
],
temps
)
<<
");
\n
"
;
out
<<
"int x = (int)
floor
("
<<
getTempName
(
node
.
getChildren
()[
0
],
temps
)
<<
"
+0.5f
);
\n
"
;
out
<<
"int y = (int)
floor
("
<<
getTempName
(
node
.
getChildren
()[
1
],
temps
)
<<
"
+0.5f
);
\n
"
;
out
<<
"int xsize = (int) "
<<
paramsInt
[
0
]
<<
";
\n
"
;
out
<<
"int ysize = (int) "
<<
paramsInt
[
1
]
<<
";
\n
"
;
out
<<
"int index = x+y*xsize;
\n
"
;
...
...
@@ -263,9 +263,9 @@ void CudaExpressionUtilities::processExpression(stringstream& out, const Express
for
(
int
j
=
0
;
j
<
nodes
.
size
();
j
++
)
{
const
vector
<
int
>&
derivOrder
=
dynamic_cast
<
const
Operation
::
Custom
*>
(
&
nodes
[
j
]
->
getOperation
())
->
getDerivOrder
();
if
(
derivOrder
[
0
]
==
0
&&
derivOrder
[
1
]
==
0
&&
derivOrder
[
2
]
==
0
)
{
out
<<
"int x = (int)
round
("
<<
getTempName
(
node
.
getChildren
()[
0
],
temps
)
<<
");
\n
"
;
out
<<
"int y = (int)
round
("
<<
getTempName
(
node
.
getChildren
()[
1
],
temps
)
<<
");
\n
"
;
out
<<
"int z = (int)
round
("
<<
getTempName
(
node
.
getChildren
()[
2
],
temps
)
<<
");
\n
"
;
out
<<
"int x = (int)
floor
("
<<
getTempName
(
node
.
getChildren
()[
0
],
temps
)
<<
"
+0.5f
);
\n
"
;
out
<<
"int y = (int)
floor
("
<<
getTempName
(
node
.
getChildren
()[
1
],
temps
)
<<
"
+0.5f
);
\n
"
;
out
<<
"int z = (int)
floor
("
<<
getTempName
(
node
.
getChildren
()[
2
],
temps
)
<<
"
+0.5f
);
\n
"
;
out
<<
"int xsize = (int) "
<<
paramsInt
[
0
]
<<
";
\n
"
;
out
<<
"int ysize = (int) "
<<
paramsInt
[
1
]
<<
";
\n
"
;
out
<<
"int zsize = (int) "
<<
paramsInt
[
2
]
<<
";
\n
"
;
...
...
platforms/opencl/src/OpenCLExpressionUtilities.cpp
View file @
5b591ab0
...
...
@@ -239,7 +239,7 @@ void OpenCLExpressionUtilities::processExpression(stringstream& out, const Expre
if
(
derivOrder
[
0
]
==
0
)
{
out
<<
"real x = "
<<
getTempName
(
node
.
getChildren
()[
0
],
temps
)
<<
";
\n
"
;
out
<<
"if (x >= 0 && x < "
<<
paramsInt
[
0
]
<<
") {
\n
"
;
out
<<
"int index = (int)
round(x
);
\n
"
;
out
<<
"int index = (int)
floor(x+0.5f
);
\n
"
;
out
<<
nodeNames
[
j
]
<<
" = "
<<
functionNames
[
i
].
second
<<
"[index];
\n
"
;
out
<<
"}
\n
"
;
}
...
...
@@ -249,8 +249,8 @@ void OpenCLExpressionUtilities::processExpression(stringstream& out, const Expre
for
(
int
j
=
0
;
j
<
nodes
.
size
();
j
++
)
{
const
vector
<
int
>&
derivOrder
=
dynamic_cast
<
const
Operation
::
Custom
*>
(
&
nodes
[
j
]
->
getOperation
())
->
getDerivOrder
();
if
(
derivOrder
[
0
]
==
0
&&
derivOrder
[
1
]
==
0
)
{
out
<<
"int x = (int)
round
("
<<
getTempName
(
node
.
getChildren
()[
0
],
temps
)
<<
");
\n
"
;
out
<<
"int y = (int)
round
("
<<
getTempName
(
node
.
getChildren
()[
1
],
temps
)
<<
");
\n
"
;
out
<<
"int x = (int)
floor
("
<<
getTempName
(
node
.
getChildren
()[
0
],
temps
)
<<
"
+0.5f
);
\n
"
;
out
<<
"int y = (int)
floor
("
<<
getTempName
(
node
.
getChildren
()[
1
],
temps
)
<<
"
+0.5f
);
\n
"
;
out
<<
"int xsize = "
<<
paramsInt
[
0
]
<<
";
\n
"
;
out
<<
"int ysize = "
<<
paramsInt
[
1
]
<<
";
\n
"
;
out
<<
"int index = x+y*xsize;
\n
"
;
...
...
@@ -263,9 +263,9 @@ void OpenCLExpressionUtilities::processExpression(stringstream& out, const Expre
for
(
int
j
=
0
;
j
<
nodes
.
size
();
j
++
)
{
const
vector
<
int
>&
derivOrder
=
dynamic_cast
<
const
Operation
::
Custom
*>
(
&
nodes
[
j
]
->
getOperation
())
->
getDerivOrder
();
if
(
derivOrder
[
0
]
==
0
&&
derivOrder
[
1
]
==
0
&&
derivOrder
[
2
]
==
0
)
{
out
<<
"int x = (int)
round
("
<<
getTempName
(
node
.
getChildren
()[
0
],
temps
)
<<
");
\n
"
;
out
<<
"int y = (int)
round
("
<<
getTempName
(
node
.
getChildren
()[
1
],
temps
)
<<
");
\n
"
;
out
<<
"int z = (int)
round
("
<<
getTempName
(
node
.
getChildren
()[
2
],
temps
)
<<
");
\n
"
;
out
<<
"int x = (int)
floor
("
<<
getTempName
(
node
.
getChildren
()[
0
],
temps
)
<<
"
+0.5f
);
\n
"
;
out
<<
"int y = (int)
floor
("
<<
getTempName
(
node
.
getChildren
()[
1
],
temps
)
<<
"
+0.5f
);
\n
"
;
out
<<
"int z = (int)
floor
("
<<
getTempName
(
node
.
getChildren
()[
2
],
temps
)
<<
"
+0.5f
);
\n
"
;
out
<<
"int xsize = "
<<
paramsInt
[
0
]
<<
";
\n
"
;
out
<<
"int ysize = "
<<
paramsInt
[
1
]
<<
";
\n
"
;
out
<<
"int zsize = "
<<
paramsInt
[
2
]
<<
";
\n
"
;
...
...
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