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

Analysis at a higher level of abstraction #1027

Merged
merged 24 commits into from Jan 7, 2020
Merged

Conversation

FabioLuporini
Copy link
Contributor

WARNING: this PR is based on top of #1026 , so it's pointless to look at the diff with master until #1026 will have been merged.

This PR moves several analysis passes from the IET level to the Cluster level.

No new functionality is added. This is in preparation for another PR.

Copy link
Contributor

@georgebisbas georgebisbas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs rebasing, right?

from devito.ir.iet import (IterationProperty, SEQUENTIAL, PARALLEL, PARALLEL_IF_ATOMIC,
VECTOR, WRAPPABLE, ROUNDABLE, AFFINE, OVERLAPPABLE)
from devito.ir.support import Forward, detect_io
from devito.ir.support import (SEQUENTIAL, PARALLEL, PARALLEL_IF_ATOMIC, VECTORIZED,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vectorizable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no

COLLAPSED = lambda i: Property('collapsed', i)
"""Collapsing Dimensions."""

VECTORIZED = Property('vector-dim')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as before.. vectorizable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, now it's really VECTORIZED

@@ -104,7 +104,7 @@ def timer_on(self, name, comm=None):
If provided, the global execution time is derived by a single MPI
rank, with timers started and stopped right after an MPI barrier.
"""
if comm is not MPI.COMM_NULL:
if comm and comm is not MPI.COMM_NULL:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have been spotted earlier on, right?

@@ -366,7 +366,7 @@ class Iteration(Node):
The for-loop direction. Accepted:
- ``Forward``: i += stepping (defaults)
- ``Backward``: i -= stepping
properties : IterationProperty or list of IterationProperty, optional
properties : Property or list of Property, optional
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get the idea, but "Property" feels very vague/general, maybe "CompilerProperty" or "PasssProperty" or just keep the previous IterationProperty

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would vote for IterationProperty

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not an IterationProperty (anymore), otherwise I'd have kept the original name

from devito.tools import Tag


class Property(Tag):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above, don't really like the name.

"""
A modulo-N Dimension (i.e., cycling over i, i+1, i+2, ..., i+N-1) that could
safely be turned into a modulo-K Dimension, with K < N. For example:
u[t+1, ...] = f(u[t, ...], u[t-1, ...]) --> u[t-1, ...] = f(u[t, ...], u[t-1, ...]).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's t-1 on both side of = in the second part.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that's the point. A very special case in which you could get away with two timeslots instead of three (here it's t-1 and t, could have been t+1 and t)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's inside f it's note the case as it implies it's not just a overwrite but need to know t-1 everywhere.

@@ -96,7 +96,7 @@ def test_mode_destructive():
grid = Grid(shape=(96, 96, 96))
f = TimeFunction(name='f', grid=grid, time_order=0)

op = Operator(Eq(f, f + 1.), dle=('advanced', {'openmp': False}))
op = Operator(Eq(f.forward, f + 1.), dle=('advanced', {'openmp': False}))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was just a leftover. I have reinstated the origin version

@@ -498,7 +498,7 @@ def test_default_functions(self):
grid = Grid(shape=(5, 6, 7))
f = TimeFunction(name='f', grid=grid)
g = Function(name='g', grid=grid)
op = Operator(Eq(g, g + f), dle=('advanced', {'openmp': False}))
op = Operator(Eq(f.forward, g + f), dle=('advanced', {'openmp': False}))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f would have worked too.

But not g. With g on the LHS, this is a fully parallel loop nest -- you may go in parallel even over time -- and heuristically the compiler doesn't do blocking if there is not at least one SEQUENTIAL Iteration

the test however expects x0_blk_size, ie it expects blocking, so...

"""
return Cluster(exprs, self.ispace, self.dspace, self.guards)
# Shortcut for backwards compatibility
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe raise a warning if this is only there for backward compatibility.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh no this is just an internal thing

and in fact, no worries -- this is changing again in one of the subsequent PRs (getting a proper cleanup)

Copy link
Contributor Author

@FabioLuporini FabioLuporini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed your comments + rebased on latest master

I'll stick to Property for now, but I'll think of a better name before landing the next PR. Though to be fair it's not ambiguous, so it seems OK to me

@@ -96,7 +96,7 @@ def test_mode_destructive():
grid = Grid(shape=(96, 96, 96))
f = TimeFunction(name='f', grid=grid, time_order=0)

op = Operator(Eq(f, f + 1.), dle=('advanced', {'openmp': False}))
op = Operator(Eq(f.forward, f + 1.), dle=('advanced', {'openmp': False}))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was just a leftover. I have reinstated the origin version

@@ -498,7 +498,7 @@ def test_default_functions(self):
grid = Grid(shape=(5, 6, 7))
f = TimeFunction(name='f', grid=grid)
g = Function(name='g', grid=grid)
op = Operator(Eq(g, g + f), dle=('advanced', {'openmp': False}))
op = Operator(Eq(f.forward, g + f), dle=('advanced', {'openmp': False}))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f would have worked too.

But not g. With g on the LHS, this is a fully parallel loop nest -- you may go in parallel even over time -- and heuristically the compiler doesn't do blocking if there is not at least one SEQUENTIAL Iteration

the test however expects x0_blk_size, ie it expects blocking, so...

"""
return Cluster(exprs, self.ispace, self.dspace, self.guards)
# Shortcut for backwards compatibility
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh no this is just an internal thing

and in fact, no worries -- this is changing again in one of the subsequent PRs (getting a proper cleanup)

@codecov
Copy link

codecov bot commented Jan 7, 2020

Codecov Report

Merging #1027 into master will increase coverage by 0.01%.
The diff coverage is 96.35%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1027      +/-   ##
==========================================
+ Coverage   88.71%   88.73%   +0.01%     
==========================================
  Files         116      118       +2     
  Lines       14715    14742      +27     
  Branches     2722     2710      -12     
==========================================
+ Hits        13055    13081      +26     
- Misses       1315     1316       +1     
  Partials      345      345
Impacted Files Coverage Δ
devito/ir/iet/scheduler.py 93.61% <ø> (ø) ⬆️
devito/ir/iet/__init__.py 100% <ø> (ø) ⬆️
devito/mpi/routines.py 92.91% <100%> (+0.01%) ⬆️
devito/ir/stree/algorithms.py 100% <100%> (ø) ⬆️
devito/ir/clusters/__init__.py 100% <100%> (ø) ⬆️
devito/ir/support/__init__.py 100% <100%> (ø) ⬆️
devito/ir/support/properties.py 100% <100%> (ø)
devito/ir/stree/tree.py 87.77% <100%> (+0.13%) ⬆️
devito/ir/iet/analysis.py 100% <100%> (+5.58%) ⬆️
devito/dse/rewriters.py 94.11% <100%> (ø) ⬆️
... and 16 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7c45f89...7e5d2f2. Read the comment docs.

@FabioLuporini FabioLuporini merged commit ea661f9 into master Jan 7, 2020
@FabioLuporini FabioLuporini deleted the hoist-analysis branch January 7, 2020 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants