Skip to content
Snippets Groups Projects
Commit e5861425 authored by Richard Angersbach's avatar Richard Angersbach
Browse files

Minor adaptation on how symbols are given reduction property

parent 3d592ab0
Branches
Tags release/0.4.1
1 merge request!438Reduction Support
...@@ -179,13 +179,14 @@ class KernelCreationContext: ...@@ -179,13 +179,14 @@ class KernelCreationContext:
""" """
if self.find_symbol(symbol.name) is None: if self.find_symbol(symbol.name) is None:
raise PsInternalCompilerError( 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): if symbol not in self._symbols_with_reduction and not symbol.get_properties(ReductionSymbolProperty):
symbol.add_property(reduction)
self._symbols_with_reduction[symbol] = reduction self._symbols_with_reduction[symbol] = reduction
else: 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( def duplicate_symbol(
self, symb: PsSymbol, new_dtype: PsType | None = None self, symb: PsSymbol, new_dtype: PsType | None = None
......
...@@ -213,7 +213,7 @@ class FreezeExpressions: ...@@ -213,7 +213,7 @@ class FreezeExpressions:
case _: case _:
raise FreezeError(f"Unsupported reduced assignment: {expr.op}.") 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)) return PsAssignment(lhs, op(lhs.clone(), rhs))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment