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

Loop merger embarrassed by empty loops #98

Closed
miklos1 opened this issue Oct 25, 2016 · 2 comments · Fixed by #104
Closed

Loop merger embarrassed by empty loops #98

miklos1 opened this issue Oct 25, 2016 · 2 comments · Fixed by #104
Labels

Comments

@miklos1
Copy link
Contributor

miklos1 commented Oct 25, 2016

Testing with the finat branch of Firedrake, firedrakeproject/tsfc@4589cf2 and master FInAT, I get the following failure:

$ py.test tests/extrusion/test_helmholtz_scalar.py::test_scalar_convergence[testcase2-3.9-False]
...
../PyOP2/pyop2/host.py:60: in _ast_to_c
    ast_handler.plan_cpu(self._opts)
../COFFEE/coffee/plan.py:120: in plan_cpu
    loop_opt.rewrite(rewrite)
../COFFEE/coffee/optimizer.py:145: in rewrite
    merged_loops = SSALoopMerger(self.expr_graph).merge(self.header)
../COFFEE/coffee/scheduler.py:183: in merge
    merged, l_dims, m_dims = self._merge_loops(parent, l, merging_in)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <coffee.scheduler.SSALoopMerger object at 0x7f8e602b2dd0>
root = <coffee.base.Block object at 0x7f8e5ab0c510>
loop_a = <coffee.base.For object at 0x7f8e5abb6490>
loop_b = <coffee.base.Block object at 0x7f8e5abdb290>

    def _merge_loops(self, root, loop_a, loop_b):
        """Merge the body of ``loop_a`` in ``loop_b`` and eliminate ``loop_a``
            from the tree rooted in ``root``. Return a reference to the block
            containing the merged loop as well as the iteration variables used
            in the respective iteration spaces."""
        # Find the first statement in the perfect loop nest loop_b
        dims_a, dims_b = [], []
>       while isinstance(loop_b.children[0], (Block, For)):
E       IndexError: list index out of range

../COFFEE/coffee/scheduler.py:76: IndexError

Here is the unoptimised C code. It seems that the loop merger doesn't expect spurious empty loops.

@miklos1
Copy link
Contributor Author

miklos1 commented Oct 25, 2016

Note that firedrakeproject/tsfc@509cb75 avoids triggering this code path, but then leads to #99.

@FabioLuporini
Copy link
Contributor

OK, this is another easy fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants