-
Notifications
You must be signed in to change notification settings - Fork 230
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: Improve IndexDerivatives lowering #2183
Conversation
@@ -1064,3 +1090,147 @@ def r_all(self): | |||
All Relations of the Scope. | |||
""" | |||
return list(self.r_gen()) | |||
|
|||
|
|||
class ExprGeometry(object): |
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.
Lifted and tweaked from passes/clusters/aliases.py
Codecov Report
@@ Coverage Diff @@
## master #2183 +/- ##
==========================================
- Coverage 87.06% 86.95% -0.11%
==========================================
Files 228 228
Lines 40299 40774 +475
Branches 7357 7483 +126
==========================================
+ Hits 35088 35457 +369
- Misses 4625 4724 +99
- Partials 586 593 +7
|
8f8871e
to
4d2f5f2
Compare
if not expand and indices.expr is not None: | ||
weights = Weights(name='w', dimensions=indices.free_dim, initvalue=weights) | ||
|
||
if matvec == transpose: | ||
# For homogenity, always generate e.g. `x + i0` rather than `x - i0` |
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.
Homogeneity
return Properties(properties) | ||
|
||
|
||
def tailor_properties(properties, ispace): |
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.
tailor_*
reduce_*
normalize_*
relax_*
better to add docstrings that would make clear what is the use of each one.
I feel the names are not really helpful to someone who would read the code.
ofc they are all used in different ways, different args and context.... just saying how it feels
|
||
# *** Utils | ||
|
||
def and_smart(relation, v): |
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.
simplify_and ?
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, will change
@@ -916,6 +929,10 @@ def is_compatible(self, other): | |||
def itdimensions(self): | |||
return self.intervals.dimensions | |||
|
|||
@property | |||
def itdims(self): |
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.
redundant?
Why not use directly itdimensions?
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 indeed a shortcut. Itdimensions is painfully long and so we ought to update it everywhere. Maybe I'll do that in this PR
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.
doing it
return Extrema(minimum(expr), maximum(expr)) | ||
|
||
|
||
def minmax_index(expr, d): |
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.
dim_extrema or similar?
except (AttributeError, TypeError): | ||
# E.g., the section has a dynamic loop size | ||
points = np.nan | ||
|
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 gap?
def next(self, prefix, d, clusters): | ||
# If a whole new set of Dimensions, move the tip -- this means `clusters` | ||
# at `d` represents a new loop nest or kernel | ||
x = any(i.dim.is_Block for i in flatten(c.ispace for c in clusters)) |
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.
something different than x?
@@ -57,6 +62,37 @@ def track_subsections(iet, **kwargs): | |||
|
|||
iet = Transformer(mapper).visit(iet) | |||
|
|||
# Multi-pass implementations |
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.
Is this PRO only?
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
|
||
def _subs(self, old, new, **hints): | ||
# Wrap in a try to make sure no substitution happens when | ||
# old is an Indexed as only checkink `old is new` would lead to |
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.
checking
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 from a cherry-picked commit that is now in master
https://github.com/devitocodes/devito/blob/master/devito/types/basic.py#L1467
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.
Will have a proper look later
# For homogenity, always generate e.g. `x + i0` rather than `x - i0` | ||
# for transpose and `x + i0` for direct | ||
indices = indices.transpose() | ||
weights = weights._subs(indices.free_dim, -indices.free_dim) |
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.
weights.transpose()
?
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 was that way, just like the indices above, but I had to change it because... I don't remember exactly
isinstance(other.access, ComponentAccess) and \ | ||
self.access.index != other.access.index: | ||
# E.g., `uv(x).x` and `uv(x).y` -- not a real dependence! | ||
return Vector(S.ImaginaryUnit) |
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.
Can we use something else there. As we want to add complex support would be better to use something like Inf
or NaN
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 could do that, but this is several layers of abstraction below, when the imaginary parts (in a mathematical sense) will have already been completely lowered away
|
||
|
||
def sdims_max(expr): | ||
def _minmax(expr, callback, udims=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.
minmax
usually used for min-of-max so would use _relational
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!
ab8fd92
to
e4f186b
Compare
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Comments:
not to be merged until we introduce git-submodule in PRODONEsome notebooks still to be updatedDONEAnyway, open for early reviewing.EDIT: About time to start reviewing