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: Introducing min/max bounds to replace 'bf' elemental functions #1673
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1673 +/- ##
==========================================
- Coverage 89.60% 87.91% -1.69%
==========================================
Files 206 201 -5
Lines 33163 32669 -494
Branches 4316 4281 -35
==========================================
- Hits 29716 28722 -994
- Misses 2958 3443 +485
- Partials 489 504 +15
Continue to review full report at Codecov.
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
0823044
to
754e1a5
Compare
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.
it's not easy to follow the implementation of relax_incr_dimension
You could try improving the comments, maybe you could also add a couple of examples inline just like I often do for ease of explanation
63b2074
to
6bd01b0
Compare
f8b020f
to
b75e1ca
Compare
1e21971
to
13c79c1
Compare
8254b84
to
8844b0a
Compare
a2f0416
to
df1e67d
Compare
tests/conftest.py
Outdated
def assert_structure(operator, exp_trees=None, exp_iters=None): | ||
""" | ||
Utility function that helps to check loop structure of IETs. Retrieves trees from an | ||
Operator and check that blocking structure is as expected. Trees and Iterations are |
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.
... that the blocking structure...
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.
ok
tests/conftest.py
Outdated
|
||
Example: | ||
|
||
To check the following structure: |
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.
"To check that an Iteration tree as the following structure"
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.
ok, (*has the following.. )?
tests/conftest.py
Outdated
|
||
we call: | ||
|
||
`trees, iters = assert_structure(op, ['t,x,y', 't,f,y'], 't,x,y,f,y')` |
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.
nitpicking: use should use ..code-block again, no?
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.
no, AFAI saw from other examples....did some more changes to be homogeneous with the codebase, let me know if yout think it is better or not now...
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.
ah, yes, I thought you were saying that we need to have an ending delimeter such as
code-block
code
code-block end
ok, all clear now
tests/conftest.py
Outdated
|
||
we call: | ||
|
||
`trees, bns = get_blocked_nests(op, {'x0_blk0', 'x1_blk0'})` |
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.
same as before, use code-block ?
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.
yes
tests/test_dimension.py
Outdated
@@ -1072,11 +1072,12 @@ def test_no_fusion_simple(self): | |||
Eq(g, f + 1, implicit_dims=[ctime])] | |||
|
|||
op = Operator(eqns) | |||
exprs = FindNodes(Expression).visit(op._func_table['bf0'].root) | |||
_, bns = get_blocked_nests(op, {'x0_blk0', 'x1_blk0'}) |
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.
imho all these calls to assert_blocking
want blank lines around
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.
So, not as before right?
i.e. we add two empty lines ?
tests/test_dle.py
Outdated
assert tree[3].dim.is_Incr and tree[3].dim.parent is tree[1].dim and\ | ||
tree[3].dim.root is y | ||
assert not tree[4].dim.is_Incr and tree[4].dim is zi and tree[4].dim.parent is z | ||
_, _ = assert_structure(op, ['t,i0x0_blk0,i0y0_blk0,i0x,i0y,i0z']) |
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.
I don't know, you tell me?
4252061
to
29b832b
Compare
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.
Some comment, very nice!
tests/test_dle.py
Outdated
opt=('blocking', {'openmp': True, | ||
'blockinner': blockinner, | ||
'par-collapse-ncores': 1})) | ||
for opi in [op, op2]: |
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 parametize
over openmp?
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.
This will lead to redundantly run additional tests as there is CI for openmp and no-openmp, no?
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.
I don't see how, it won't change anything only split this test in two cases rather than having them as if/else inside the test.
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.
Ah yes, you are right, pushed a change, let me know if you like it.
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.
Thanks for the review!
tests/test_dle.py
Outdated
opt=('blocking', {'openmp': True, | ||
'blockinner': blockinner, | ||
'par-collapse-ncores': 1})) | ||
for opi in [op, op2]: |
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.
This will lead to redundantly run additional tests as there is CI for openmp and no-openmp, no?
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.
we nearly ready to land!
|
||
if exp_trees is not None: | ||
exp_trees = [i.replace(',', '') for i in exp_trees] # 't,x,y' -> 'txy' | ||
tree_struc = (["".join(mapper.get(i.dim.name, i.dim.name) for i in j) |
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.
comment about what this line's doing? just like the one in the line above
tests/conftest.py
Outdated
trees = retrieve_iteration_tree(operator) | ||
for tree in trees: | ||
iterations = [i for i in tree if i.dim.is_Incr] # Collect Incr dimensions | ||
parallel_blocks = FindNodes(ParallelBlock).visit(tree) |
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.
You only need this tree traversal if you get inside the if iterations
branch right? so move it below inside the try
?
tests/test_autotuner.py
Outdated
@@ -238,8 +238,7 @@ def test_multiple_blocking(): | |||
opt=('blocking', {'openmp': False})) | |||
|
|||
# First of all, make sure there are indeed two different loop nests | |||
assert 'bf0' in op._func_table | |||
assert 'bf1' in op._func_table | |||
_, _ = assert_blocking(op, {'x0_blk0', 'x1_blk0'}) |
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.
just assert_blocking(op, {'x0_blk0', 'x1_blk0'})
no need to catch the return value if ever used!
replicate this change wherever needed
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.
ok
30cdbc5
to
4d25407
Compare
tests/conftest.py
Outdated
""" | ||
mapper = {'time': 't'} | ||
trees = retrieve_iteration_tree(operator) | ||
iters = FindNodes(Iteration).visit(operator) |
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.
this is not needed unless exp_iters is not None
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.
There are cases where the structure is simple, so exp_iters is not tested as redundant. There are also tests that use Iterations later. So it is needed.
tests/conftest.py
Outdated
for f | ||
for y | ||
|
||
we call(Note: `time` mapped to `t`): |
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.
space, or rather change the for t
into for time
in the code-block above?
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.
I left a couple of tiny, last-minute comments, but to be fair I'm fine if they're addressed in the next PR. Approving -- well done! This is a really nice piece of work
tests/test_dle.py
Outdated
assert len(trees) == 1 | ||
tree = trees[0] | ||
assert len(tree) == exp_iters | ||
opt=('blocking', {'openmp': True, 'blockinner': blockinner, |
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.
openmp
: openmp?
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.
nitpicking: blockinner could probably be moved to parametrize
as well
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, it is alreday there?
tests/conftest.py
Outdated
exp_iters = exp_iters.replace(',', '') # 't,x,y' -> 'txy' | ||
iter_struc = "".join(mapper.get(i.dim.name, i.dim.name) for i in iters) | ||
assert iter_struc == exp_iters | ||
|
||
return trees, iters | ||
return |
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.
no need
c7735d0
to
c38526b
Compare
This PR is removing Elemental Functions from Devito generated code. The so-called "bf" functions.
The most important part for review is in
devito/passes/iet/misc.py
.So now you get:
instead of:
where
bf:...