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

Fix declaration of local reduction var and write back to original variable

parent e0347f54
1 merge request!438Reduction Support
Pipeline #72407 failed with stages
in 2 minutes and 57 seconds
......@@ -13,7 +13,7 @@ from ..types import create_numeric_type, PsIntegerType, PsScalarType
from ..backend.memory import PsSymbol
from ..backend.ast import PsAstNode
from ..backend.ast.structural import PsBlock, PsLoop, PsAssignment
from ..backend.ast.structural import PsBlock, PsLoop, PsAssignment, PsDeclaration
from ..backend.ast.analysis import collect_undefined_symbols, collect_required_headers
from ..backend.kernelcreation import (
KernelCreationContext,
......@@ -153,12 +153,16 @@ class DefaultKernelCreationDriver:
self._intermediates.constants_eliminated = kernel_ast.clone()
# Init local reduction variable copy
# for red, prop in self._ctx.symbols_with_reduction.items():
# kernel_ast.statements = [PsAssignment(PsSymbolExpr(red), prop.init_val)] + kernel_ast.statements
for red, prop in self._ctx.symbols_with_reduction.items():
kernel_ast.statements = [PsDeclaration(PsSymbolExpr(red), prop.init_val)] + kernel_ast.statements
# Write back result to reduction target variable
# for red, prop in self._ctx.symbols_with_reduction.items():
# kernel_ast.statements += [PsAssignment(PsSymbolExpr(prop.orig_symbol), PsSymbolExpr(red))]
for red, prop in self._ctx.symbols_with_reduction.items():
kernel_ast.statements += [PsAssignment(PsSymbolExpr(prop.orig_symbol), PsSymbolExpr(red))]
# TODO: can this be omitted?
typify = Typifier(self._ctx)
kernel_ast = typify(kernel_ast)
# Target-Specific optimizations
if self._cfg.target.is_cpu():
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment