-
Notifications
You must be signed in to change notification settings - Fork 6
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
Conditionals not dealt with correctly #53
Comments
A little bit more digging (using https://bitbucket.org/mapdes/ffc/pull-request/78/create-correct-nodes-for-max_value-and/diff) suggests this is a problem with the loop merger step of the rewriter. After licm and expression factorisation, you do: lm = SSALoopMerger(self.header, ew.expr_graph)
merged_loops = lm.merge()
for merged, merged_in in merged_loops:
[self.hoisted.update_loop(l, merged_in) for l in merged]
lm.simplify() However, the expr_graph only tracks dependencies in the loop being optimised. The resulting code ends up doing: double F0 = 0;
double F1 = 0;
double C0 = some_expression(F0, F1);
for ( .... ) {
F0 += ...;
F1 += ...;
}
// quad loop here i.e. the read-after-write dependency between C and F0/F1 is missing. If I apply this patch in coffee: diff --git a/coffee/optimizer.py b/coffee/optimizer.py
index a744f7e..3dd87d4 100644
--- a/coffee/optimizer.py
+++ b/coffee/optimizer.py
@@ -58,7 +58,7 @@ class LoopOptimizer(object):
# Track nonzero regions accessed in the loop nest
self.nonzero_info = {}
# Track data dependencies
- self.expr_graph = ExpressionGraph(loop)
+ self.expr_graph = ExpressionGraph(self.header)
# Track hoisted expressions
self.hoisted = StmtTracker()
then I get the right answer. But is this the correct thing to do? |
I can't reproduce the error because of this:
did you mean:
or presumably larger... As for your patch: it is actually probably the right thing to do to start tracking from the header. Let's make the example run on my machine, and then I can tell definitely what we should do. |
|
This seems to be the right fix. Plus, this also fixes firedrakeproject/firedrake#525. I'm running the test suite right now. If they all pass, I'll just add this commit to the PR I'm about to make. |
Please don't. It is a standalone fix that should be merged separately |
So the patch works, for me we can merge it even now. If we do so, let's close both this issue and firedrakeproject/firedrake#525 |
Shall we hit merge? |
Go ahead I think. |
PRs merged, closing |
Consider the following:
I expect to see:
and do so with coffee off.
When on, I instead see:
FWIW, I suspect this is somehow a problem that some of the conditional stuff in ffc is built as strings, rather than ast nodes.
The text was updated successfully, but these errors were encountered: