Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Stephan Seitz
pystencils
Commits
e46f4149
Commit
e46f4149
authored
Aug 09, 2020
by
Markus Holzer
Browse files
Added test case for inner loop split
parent
7f76698d
Changes
2
Hide whitespace changes
Inline
Side-by-side
pystencils/transformations.py
View file @
e46f4149
...
...
@@ -1206,13 +1206,13 @@ def get_loop_hierarchy(ast_node):
return
reversed
(
result
)
def
get_loop_counter_symbol_hierarchy
(
ast
N
ode
):
def
get_loop_counter_symbol_hierarchy
(
ast
_n
ode
):
"""Determines the loop counter symbols around a given AST node.
:param ast
N
ode: the AST node
:param ast
_n
ode: the AST node
:return: list of loop counter symbols, where the first list entry is the symbol of the innermost loop
"""
result
=
[]
node
=
ast
N
ode
node
=
ast
_n
ode
while
node
is
not
None
:
node
=
get_next_parent_of_type
(
node
,
ast
.
LoopOverCoordinate
)
if
node
:
...
...
pystencils_tests/test_simplification_strategy.py
View file @
e46f4149
import
sympy
as
sp
import
pystencils
as
ps
from
pystencils
import
Assignment
,
AssignmentCollection
from
pystencils.simp
import
(
SimplificationStrategy
,
apply_on_all_subexpressions
,
...
...
@@ -43,3 +44,39 @@ def test_simplification_strategy():
assert
'Adds'
in
report
.
_repr_html_
()
assert
'factor'
in
str
(
strategy
)
def
test_split_inner_loop
():
dst
=
ps
.
fields
(
'dst(8): double[2D]'
)
s
=
sp
.
symbols
(
's_:8'
)
x
=
sp
.
symbols
(
'x'
)
subexpressions
=
[]
main
=
[
Assignment
(
dst
[
0
,
0
](
0
),
s
[
0
]),
Assignment
(
dst
[
0
,
0
](
1
),
s
[
1
]),
Assignment
(
dst
[
0
,
0
](
2
),
s
[
2
]),
Assignment
(
dst
[
0
,
0
](
3
),
s
[
3
]),
Assignment
(
dst
[
0
,
0
](
4
),
s
[
4
]),
Assignment
(
dst
[
0
,
0
](
5
),
s
[
5
]),
Assignment
(
dst
[
0
,
0
](
6
),
s
[
6
]),
Assignment
(
dst
[
0
,
0
](
7
),
s
[
7
]),
Assignment
(
x
,
sum
(
s
))
]
ac
=
AssignmentCollection
(
main
,
subexpressions
)
split_groups
=
[[
dst
[
0
,
0
](
0
),
dst
[
0
,
0
](
1
)],
[
dst
[
0
,
0
](
2
),
dst
[
0
,
0
](
3
)],
[
dst
[
0
,
0
](
4
),
dst
[
0
,
0
](
5
)],
[
dst
[
0
,
0
](
6
),
dst
[
0
,
0
](
7
),
x
]]
ac
.
simplification_hints
[
'split_groups'
]
=
split_groups
ast
=
ps
.
create_kernel
(
ac
)
code
=
ps
.
get_code_str
(
ast
)
# we have four inner loops as indicated in split groups (4 elements) plus one outer loop
assert
code
.
count
(
'for'
)
==
5
ac
=
AssignmentCollection
(
main
,
subexpressions
)
ast
=
ps
.
create_kernel
(
ac
)
code
=
ps
.
get_code_str
(
ast
)
# one inner loop and one outer loop
assert
code
.
count
(
'for'
)
==
2
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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