Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pystencils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pycodegen
pystencils
Commits
e46f4149
Commit
e46f4149
authored
4 years ago
by
Markus Holzer
Browse files
Options
Downloads
Patches
Plain Diff
Added test case for inner loop split
parent
7f76698d
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!168
Extend testsuite
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pystencils/transformations.py
+3
-3
3 additions, 3 deletions
pystencils/transformations.py
pystencils_tests/test_simplification_strategy.py
+37
-0
37 additions, 0 deletions
pystencils_tests/test_simplification_strategy.py
with
40 additions
and
3 deletions
pystencils/transformations.py
+
3
−
3
View file @
e46f4149
...
@@ -1206,13 +1206,13 @@ def get_loop_hierarchy(ast_node):
...
@@ -1206,13 +1206,13 @@ def get_loop_hierarchy(ast_node):
return
reversed
(
result
)
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.
"""
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
:return: list of loop counter symbols, where the first list entry is the symbol of the innermost loop
"""
"""
result
=
[]
result
=
[]
node
=
ast
N
ode
node
=
ast
_n
ode
while
node
is
not
None
:
while
node
is
not
None
:
node
=
get_next_parent_of_type
(
node
,
ast
.
LoopOverCoordinate
)
node
=
get_next_parent_of_type
(
node
,
ast
.
LoopOverCoordinate
)
if
node
:
if
node
:
...
...
This diff is collapsed.
Click to expand it.
pystencils_tests/test_simplification_strategy.py
+
37
−
0
View file @
e46f4149
import
sympy
as
sp
import
sympy
as
sp
import
pystencils
as
ps
from
pystencils
import
Assignment
,
AssignmentCollection
from
pystencils
import
Assignment
,
AssignmentCollection
from
pystencils.simp
import
(
from
pystencils.simp
import
(
SimplificationStrategy
,
apply_on_all_subexpressions
,
SimplificationStrategy
,
apply_on_all_subexpressions
,
...
@@ -43,3 +44,39 @@ def test_simplification_strategy():
...
@@ -43,3 +44,39 @@ def test_simplification_strategy():
assert
'
Adds
'
in
report
.
_repr_html_
()
assert
'
Adds
'
in
report
.
_repr_html_
()
assert
'
factor
'
in
str
(
strategy
)
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment