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
Frederik Hennig
pystencils
Commits
cb42f2c0
Commit
cb42f2c0
authored
Feb 17, 2022
by
Jan Hönig
Browse files
Reverting back to previous more correctly broken implementation
parent
0b0d4979
Changes
3
Hide whitespace changes
Inline
Side-by-side
pystencils/backends/cbackend.py
View file @
cb42f2c0
...
...
@@ -219,7 +219,7 @@ class CBackend:
method_name
=
f
"_print_
{
cls
.
__name__
}
"
if
hasattr
(
self
,
method_name
):
return
getattr
(
self
,
method_name
)(
node
)
r
eturn
self
.
sympy_printer
.
doprint
(
node
)
r
aise
NotImplementedError
(
f
"
{
self
.
__class__
.
__name__
}
does not support node of type
{
node
.
__class__
.
__name__
}
"
)
def
_print_AbstractType
(
self
,
node
):
return
str
(
node
)
...
...
pystencils/integer_set_analysis.py
View file @
cb42f2c0
...
...
@@ -5,7 +5,7 @@ import sympy as sp
import
pystencils.astnodes
as
ast
from
pystencils.typing
import
parents_of_type
from
pystencils.backends
import
generate_c
from
pystencils.backends
.cbackend
import
CustomSympyPrinter
def
remove_brackets
(
s
):
...
...
@@ -52,7 +52,8 @@ def simplify_loop_counter_dependent_conditional(conditional):
dofs_in_loops
,
iteration_set
=
isl_iteration_set
(
conditional
)
if
dofs_in_condition
.
issubset
(
dofs_in_loops
):
symbol_names
=
','
.
join
(
dofs_in_loops
)
condition_str
=
remove_brackets
(
generate_c
(
conditional
.
condition_expr
))
condition_str
=
CustomSympyPrinter
().
doprint
(
conditional
.
condition_expr
)
condition_str
=
remove_brackets
(
condition_str
)
condition_set
=
isl
.
BasicSet
(
f
"{{ [
{
symbol_names
}
] :
{
condition_str
}
}}"
)
if
condition_set
.
is_empty
():
...
...
pystencils/transformations.py
View file @
cb42f2c0
...
...
@@ -772,7 +772,7 @@ def simplify_conditionals(node: ast.Node, loop_counter_simplification: bool = Fa
default.
"""
for
conditional
in
node
.
atoms
(
ast
.
Conditional
):
# TODO simplify conditional before the type system!
# TODO simplify conditional before the type system!
Casts make it very hard here
# conditional.condition_expr = sp.simplify(conditional.condition_expr)
if
conditional
.
condition_expr
==
sp
.
true
:
conditional
.
parent
.
replace
(
conditional
,
[
conditional
.
true_block
])
...
...
@@ -781,7 +781,6 @@ def simplify_conditionals(node: ast.Node, loop_counter_simplification: bool = Fa
elif
loop_counter_simplification
:
try
:
# noinspection PyUnresolvedReferences
raise
ImportError
from
pystencils.integer_set_analysis
import
simplify_loop_counter_dependent_conditional
simplify_loop_counter_dependent_conditional
(
conditional
)
except
ImportError
:
...
...
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