Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work around bug in transform chain for certain quadrature orders #8

Merged
merged 2 commits into from
Oct 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions loopy/transform/loop_fusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@
dependencies between the *candidates* loops that has been obtained by
removing instances of :class:`NonCandidateLoop` and
:class:`OuterLoopNestStatement` from the graph described by *predecessors*,
*succcessors*.

Check warning on line 212 in loopy/transform/loop_fusion.py

View workflow job for this annotation

GitHub Actions / Typos

"succcessors" should be "successors".

Check warning on line 212 in loopy/transform/loop_fusion.py

View workflow job for this annotation

GitHub Actions / Typos

"succcessors" should be "successors".

New dependency edges are added in the new graph to preserve the transitive
dependencies that exists in the original graph.
Expand Down Expand Up @@ -753,24 +753,26 @@
# {{{ sanitary checks

_nest_tree_id_to_candidate = {}
_fusable_candidates = set()

for iname in candidates:
loop_nest_tree_node_id = iname_to_tree_node_id[iname]
if loop_nest_tree_node_id not in _nest_tree_id_to_candidate:
_nest_tree_id_to_candidate[loop_nest_tree_node_id] = iname
_fusable_candidates.add(iname)
else:
conflict_iname = _nest_tree_id_to_candidate[loop_nest_tree_node_id]
raise LoopyError(f"'{iname}' and '{conflict_iname}' "
"cannot fused be fused as they can be nested "
"within one another.")
from warnings import warn
warn(f"'{iname}' and '{conflict_iname}' "
"cannot be fused as they can be nested within one another.")

for iname in candidates:
for iname in _fusable_candidates:
outer_loops = reduce(frozenset.union,
tree.ancestors(iname_to_tree_node_id[iname]),
frozenset())
if outer_loops & candidates:
if outer_loops & _fusable_candidates:
raise LoopyError(f"Cannot fuse '{iname}' with"
f" '{outer_loops & candidates}' as they"
f" '{outer_loops & _fusable_candidates}' as they"
" maybe nesting within one another.")

del _nest_tree_id_to_candidate
Expand All @@ -782,7 +784,7 @@
just_outer_loop_nest = {tree.parent(iname_to_tree_node_id[iname]): set()
for iname in candidates}

for iname in candidates:
for iname in _fusable_candidates:
just_outer_loop_nest[tree.parent(iname_to_tree_node_id[iname])].add(iname)

for outer_inames, inames in just_outer_loop_nest.items():
Expand Down
Loading