-
Notifications
You must be signed in to change notification settings - Fork 229
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
compiler: Patch CSE in presence of conditionals #2392
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
ConditionalDimension, DefaultDimension, Grid, Operator, | ||
norm, grad, div, dimensions, switchconfig, configuration, | ||
centered, first_derivative, solve, transpose, Abs, cos, | ||
sin, sqrt) | ||
sin, sqrt, Ge) | ||
from devito.exceptions import InvalidArgument, InvalidOperator | ||
from devito.finite_differences.differentiable import diffify | ||
from devito.ir import (Conditional, DummyEq, Expression, Iteration, FindNodes, | ||
|
@@ -168,6 +168,29 @@ def test_cse_temp_order(): | |
assert type(args[2]) is CTemp | ||
|
||
|
||
def test_cse_w_conditionals(): | ||
grid = Grid(shape=(10, 10, 10)) | ||
x, _, _ = grid.dimensions | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tidier but (nitpicking) the one above performs an implicit assertion There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fairs |
||
|
||
cd = ConditionalDimension(name='cd', parent=x, condition=Ge(x, 4), | ||
indirect=True) | ||
|
||
f = Function(name='f', grid=grid) | ||
g = Function(name='g', grid=grid) | ||
h = Function(name='h', grid=grid) | ||
a0 = Function(name='a0', grid=grid) | ||
a1 = Function(name='a1', grid=grid) | ||
|
||
eqns = [Eq(h, a0, implicit_dims=cd), | ||
Eq(a0, a0 + f*g, implicit_dims=cd), | ||
Eq(a1, a1 + f*g, implicit_dims=cd)] | ||
|
||
op = Operator(eqns) | ||
|
||
assert_structure(op, ['x,y,z'], 'xyz') | ||
assert len(FindNodes(Conditional).visit(op)) == 1 | ||
|
||
|
||
@pytest.mark.parametrize('expr,expected', [ | ||
('2*fa[x] + fb[x]', '2*fa[x] + fb[x]'), | ||
('fa[x]**2', 'fa[x]*fa[x]'), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just use
updated
henceforth, rather than usingprocessed
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wdym ? we keep on looping and
processed
needs to be updated? what change are you proposing ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignore me then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed an indent