Skip to content
Snippets Groups Projects
Commit 58eb707a authored by Michael Kuron's avatar Michael Kuron :mortar_board: Committed by Markus Holzer
Browse files

move_constants_before_loop: only compare symbol names, not types

The vectorized RNG can switch between scalar and vector types due to loop cutting.
parent cd2007fe
Branches
Tags
No related merge requests found
...@@ -2,7 +2,7 @@ import copy ...@@ -2,7 +2,7 @@ import copy
import numpy as np import numpy as np
import sympy as sp import sympy as sp
from pystencils.data_types import TypedSymbol from pystencils.data_types import TypedSymbol, cast_func
from pystencils.astnodes import LoopOverCoordinate from pystencils.astnodes import LoopOverCoordinate
from pystencils.backends.cbackend import CustomCodeNode from pystencils.backends.cbackend import CustomCodeNode
from pystencils.sympyextensions import fast_subs from pystencils.sympyextensions import fast_subs
...@@ -47,7 +47,7 @@ class RNGBase(CustomCodeNode): ...@@ -47,7 +47,7 @@ class RNGBase(CustomCodeNode):
def get_code(self, dialect, vector_instruction_set, print_arg): def get_code(self, dialect, vector_instruction_set, print_arg):
code = "\n" code = "\n"
for r in self.result_symbols: for r in self.result_symbols:
if vector_instruction_set and isinstance(self.args[1], sp.Integer): if vector_instruction_set and not self.args[1].atoms(cast_func):
# this vector RNG has become scalar through substitution # this vector RNG has become scalar through substitution
code += f"{r.dtype} {r.name};\n" code += f"{r.dtype} {r.name};\n"
else: else:
......
...@@ -576,8 +576,8 @@ def move_constants_before_loop(ast_node): ...@@ -576,8 +576,8 @@ def move_constants_before_loop(ast_node):
if isinstance(element, ast.Conditional): if isinstance(element, ast.Conditional):
break break
else: else:
critical_symbols = element.symbols_defined critical_symbols = set([s.name for s in element.symbols_defined])
if node.undefined_symbols.intersection(critical_symbols): if set([s.name for s in node.undefined_symbols]).intersection(critical_symbols):
break break
prev_element = element prev_element = element
element = element.parent element = element.parent
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment