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

Add dictionary of reduced symbols to codegen context

parent 66ce4395
No related branches found
No related tags found
1 merge request!438Reduction Support
...@@ -75,7 +75,7 @@ class KernelCreationContext: ...@@ -75,7 +75,7 @@ class KernelCreationContext:
self._symbol_ctr_pattern = re.compile(r"__[0-9]+$") self._symbol_ctr_pattern = re.compile(r"__[0-9]+$")
self._symbol_dup_table: defaultdict[str, int] = defaultdict(lambda: 0) self._symbol_dup_table: defaultdict[str, int] = defaultdict(lambda: 0)
# TODO: add list of reduction symbols self._symbols_with_reduction: dict[PsSymbol, ReductionSymbolProperty] = dict()
self._fields_and_arrays: dict[str, FieldArrayPair] = dict() self._fields_and_arrays: dict[str, FieldArrayPair] = dict()
self._fields_collection = FieldsInKernel() self._fields_collection = FieldsInKernel()
...@@ -170,6 +170,21 @@ class KernelCreationContext: ...@@ -170,6 +170,21 @@ class KernelCreationContext:
self._symbols[old.name] = new self._symbols[old.name] = new
def add_reduction_to_symbol(self, symbol: PsSymbol, reduction: ReductionSymbolProperty):
"""Adds a reduction property to a symbol.
The symbol ``symbol`` should not have a reduction property and must exist in the symbol table.
"""
if self.find_symbol(symbol.name) is None:
raise PsInternalCompilerError(
"add_reduction_to_symbol: Symbol does not exist in the symbol table"
)
if symbol not in self._symbols_with_reduction and not symbol.get_properties(ReductionSymbolProperty):
self._symbols_with_reduction[symbol] = reduction
else:
raise PsInternalCompilerError(f"add_reduction_to_symbol: 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
) -> PsSymbol: ) -> PsSymbol:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment