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
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@ import copy
import numpy as np
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.backends.cbackend import CustomCodeNode
from pystencils.sympyextensions import fast_subs
......@@ -47,7 +47,7 @@ class RNGBase(CustomCodeNode):
def get_code(self, dialect, vector_instruction_set, print_arg):
code = "\n"
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
code += f"{r.dtype} {r.name};\n"
else:
......
......@@ -576,8 +576,8 @@ def move_constants_before_loop(ast_node):
if isinstance(element, ast.Conditional):
break
else:
critical_symbols = element.symbols_defined
if node.undefined_symbols.intersection(critical_symbols):
critical_symbols = set([s.name for s in element.symbols_defined])
if set([s.name for s in node.undefined_symbols]).intersection(critical_symbols):
break
prev_element = element
element = element.parent
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment