Commit cb42f2c0 authored by Jan Hönig's avatar Jan Hönig
Browse files

Reverting back to previous more correctly broken implementation

parent 0b0d4979
...@@ -219,7 +219,7 @@ class CBackend: ...@@ -219,7 +219,7 @@ class CBackend:
method_name = f"_print_{cls.__name__}" method_name = f"_print_{cls.__name__}"
if hasattr(self, method_name): if hasattr(self, method_name):
return getattr(self, method_name)(node) return getattr(self, method_name)(node)
return self.sympy_printer.doprint(node) raise NotImplementedError(f"{self.__class__.__name__} does not support node of type {node.__class__.__name__}")
def _print_AbstractType(self, node): def _print_AbstractType(self, node):
return str(node) return str(node)
......
...@@ -5,7 +5,7 @@ import sympy as sp ...@@ -5,7 +5,7 @@ import sympy as sp
import pystencils.astnodes as ast import pystencils.astnodes as ast
from pystencils.typing import parents_of_type from pystencils.typing import parents_of_type
from pystencils.backends import generate_c from pystencils.backends.cbackend import CustomSympyPrinter
def remove_brackets(s): def remove_brackets(s):
...@@ -52,7 +52,8 @@ def simplify_loop_counter_dependent_conditional(conditional): ...@@ -52,7 +52,8 @@ def simplify_loop_counter_dependent_conditional(conditional):
dofs_in_loops, iteration_set = isl_iteration_set(conditional) dofs_in_loops, iteration_set = isl_iteration_set(conditional)
if dofs_in_condition.issubset(dofs_in_loops): if dofs_in_condition.issubset(dofs_in_loops):
symbol_names = ','.join(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} }}") condition_set = isl.BasicSet(f"{{ [{symbol_names}] : {condition_str} }}")
if condition_set.is_empty(): if condition_set.is_empty():
......
...@@ -772,7 +772,7 @@ def simplify_conditionals(node: ast.Node, loop_counter_simplification: bool = Fa ...@@ -772,7 +772,7 @@ def simplify_conditionals(node: ast.Node, loop_counter_simplification: bool = Fa
default. default.
""" """
for conditional in node.atoms(ast.Conditional): 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) # conditional.condition_expr = sp.simplify(conditional.condition_expr)
if conditional.condition_expr == sp.true: if conditional.condition_expr == sp.true:
conditional.parent.replace(conditional, [conditional.true_block]) conditional.parent.replace(conditional, [conditional.true_block])
...@@ -781,7 +781,6 @@ def simplify_conditionals(node: ast.Node, loop_counter_simplification: bool = Fa ...@@ -781,7 +781,6 @@ def simplify_conditionals(node: ast.Node, loop_counter_simplification: bool = Fa
elif loop_counter_simplification: elif loop_counter_simplification:
try: try:
# noinspection PyUnresolvedReferences # noinspection PyUnresolvedReferences
raise ImportError
from pystencils.integer_set_analysis import simplify_loop_counter_dependent_conditional from pystencils.integer_set_analysis import simplify_loop_counter_dependent_conditional
simplify_loop_counter_dependent_conditional(conditional) simplify_loop_counter_dependent_conditional(conditional)
except ImportError: except ImportError:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment