Skip to content
Snippets Groups Projects
Commit d8df729e authored by René Heß's avatar René Heß
Browse files

[skip ci] Fix dependency bug in reduction removal

parent 7542f0c5
No related branches found
No related tags found
No related merge requests found
......@@ -4,11 +4,19 @@ import pymbolic.primitives as prim
def remove_reduction(knl, match):
"""Removes all matching reductions and do direct accumulation in assignee instead"""
instructions = []
# Find reductions
for instr in lp.find_instructions(knl, match):
if isinstance(instr.expression, lp.symbolic.Reduction):
instructions = []
depends_on = instr.depends_on
# Depending on this instruction
depending = []
for i in knl.instructions:
if instr.id in i.depends_on:
depending.append(i.id)
# Remove the instruction from the kernel
knl = lp.remove_instructions(knl, set([instr.id]))
......@@ -30,11 +38,15 @@ def remove_reduction(knl, match):
expression,
within_inames=within_inames,
id=id_accum,
depends_on=frozenset((id_zero,)),
depends_on=frozenset((id_zero,) + tuple(depends_on)),
tags=('assignement',)))
knl = knl.copy(instructions=knl.instructions + instructions)
knl = knl.copy(instructions=knl.instructions + instructions)
for dep in depending:
match = lp.match.Id(dep)
knl = lp.add_dependency(knl, match, id_accum)
return knl
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment