diff --git a/src/pystencils/backend/kernelcreation/context.py b/src/pystencils/backend/kernelcreation/context.py index 258204f8dfcc66c5dd14b96be0cd13ea9b506121..e41f8371c095cbce952005b49701726afb8f9e50 100644 --- a/src/pystencils/backend/kernelcreation/context.py +++ b/src/pystencils/backend/kernelcreation/context.py @@ -179,13 +179,14 @@ class KernelCreationContext: """ if self.find_symbol(symbol.name) is None: raise PsInternalCompilerError( - "add_reduction_to_symbol: Symbol does not exist in the symbol table" + f"add_reduction_to_symbol: {symbol.name} does not exist in the symbol table" ) if symbol not in self._symbols_with_reduction and not symbol.get_properties(ReductionSymbolProperty): + symbol.add_property(reduction) self._symbols_with_reduction[symbol] = reduction else: - raise PsInternalCompilerError(f"add_reduction_to_symbol: Symbol {symbol.name} already has a reduction property") + raise PsInternalCompilerError(f"add_reduction_to_symbol: {symbol.name} already has a reduction property") def duplicate_symbol( self, symb: PsSymbol, new_dtype: PsType | None = None diff --git a/src/pystencils/backend/kernelcreation/freeze.py b/src/pystencils/backend/kernelcreation/freeze.py index 7316e2f9f64c90c92bbc1cf7cd4de6cb3c0676c7..ae728dd4984cbb9814a120b7ab6c753c91254ea8 100644 --- a/src/pystencils/backend/kernelcreation/freeze.py +++ b/src/pystencils/backend/kernelcreation/freeze.py @@ -213,7 +213,7 @@ class FreezeExpressions: case _: raise FreezeError(f"Unsupported reduced assignment: {expr.op}.") - lhs.symbol.add_property(ReductionSymbolProperty(expr.op, init_val)) + self._ctx.add_reduction_to_symbol(lhs.symbol, ReductionSymbolProperty(expr.op, init_val)) return PsAssignment(lhs, op(lhs.clone(), rhs))