-
Notifications
You must be signed in to change notification settings - Fork 227
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: Implement graceful lowering of derivatives (aka "unexpansion") #2060
Merged
Merged
Changes from 1 commit
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
f799a72
compiler: Prototype unexpansion
FabioLuporini ffc8c21
compiler: Revamp code generation from _C_ctype
FabioLuporini 91eee45
compiler: Support trivial unexpanded-derivatives examples
FabioLuporini 0eddd5d
dsl: Patch cross_derivative evaluation
FabioLuporini 63f41e8
dsl: Introduce Spacing subclass
FabioLuporini a94ab05
compiler: Patch StencilDimension reconstruction
FabioLuporini ce7c96c
compiler: Extend unexpansion machinery
FabioLuporini 4d63f17
compiler: Support StencilDimension in estimate_cost
FabioLuporini 380d262
compiler: Enhance fusion upon lower_index_derivative
FabioLuporini 45b5fa4
compiler: Rework is_cross rule for Cluster fusion
FabioLuporini 8805cd9
compiler: Implement maximal fusion for lowered IndexDerivatives
FabioLuporini 573ba59
compiler: Patch profiling in presence of StencilDimensions
FabioLuporini fda18ef
compiler: Improve IndexDerivative lowering to catch duplicates
FabioLuporini be02291
compiler: Enhance pow_to_mul to work around SymPy misbehavior
FabioLuporini c069dfe
compiler: Rework globals generation for device backends
FabioLuporini 573b4cb
compiler: Rework weights generation for device backends
FabioLuporini eb8616c
compiler: Patch index mode detection with StencilDimensions
FabioLuporini 0044b3b
compiler: Add IndexDerivative.mapper
FabioLuporini fb6c226
compiler: Patch lower_index_derivative
FabioLuporini 9a6679a
tests: Patch draft flaky unexpansion test
FabioLuporini 958c9a0
compiler: Patch lower_index_derivatives
FabioLuporini 3f73098
compiler: Patch globs codegen for deterministic output
FabioLuporini 8d28be1
compiler: Relax Properties manipulation methods
FabioLuporini 3eecf4d
compiler: Change IndexDerivative.mapper
FabioLuporini 9a843ba
compiler: Add IterationSpace.translate
FabioLuporini 52e076a
compiler: Move IndexSum.mapper to IndexDerivative.mapper
FabioLuporini a993d0d
compiler: Patch IndexDerivative.mapper
FabioLuporini 417dac4
compiler: Relax WAR dependencies involving shared Array
FabioLuporini 9c6ac52
compiler: Maximize likelihood of fusing clusters over shm
FabioLuporini 42627b1
compiler: Improve data dependence analysis
FabioLuporini fead97c
compiler: Add Jump mixin class
FabioLuporini 19f6af3
compiler: Patch collect_derivative pass
FabioLuporini 17ab99b
compiler: Add shm-related heuristics to Cluster fusion
FabioLuporini c2044d5
compiler: Add Properties methods
FabioLuporini 60e2e03
compiler: Make IndexDerivatives comparable; fix their CSE
FabioLuporini e5ea4d6
compiler: Draft Guards, akin to Properties
FabioLuporini 9d579b1
compiler: Rework customization of clusters visitors
FabioLuporini fcc2e86
compiler: Fix Cluster properties normalization at init
FabioLuporini 50025f5
compiler: Extend uxreplace to substitute types as well
FabioLuporini 3496221
compiler: Fixup linearization with isolated routines
FabioLuporini fcfa448
misc: Fixup pep8 violations
FabioLuporini c562c30
compiler: Introduce AffineIndexAccessFunction
FabioLuporini 43e700f
compiler: Improve IndexDerivative
FabioLuporini a588b6d
compiler: Enhance dtype retrieval
FabioLuporini 18bc963
compiler: Tidy up Interval.expand()
FabioLuporini 2640df3
compiler: Drop has_free for compatibility with older SymPy versions
FabioLuporini 5113825
examples: Update expected notebook output
FabioLuporini 0297597
compiler: Patch codegen upon pow_to_mul
FabioLuporini 2c5eb4d
misc: Postpone codegen speed improvement
FabioLuporini 403a194
examples: Update expected output
FabioLuporini 62e0fc8
examples: Disable openmp where necessary due to issue 2061
FabioLuporini 0c801bd
compiler: Exploit SubDim.local to support nasty deps in examples
FabioLuporini a97f6e6
ci: Drop support for gcc5, sympy1.7, sympy1.8
FabioLuporini 77eae11
compiler: Add IndexDerivative.total_order
FabioLuporini 9af12f4
arch: Enable openmp with nvc on CPU
FabioLuporini f33fcfc
ci: Add back forgotten gcc-11
FabioLuporini 88fafce
compiler: Tweak lower_index_derivatives
FabioLuporini dde53cc
compiler: IndexDerivative.total_order -> depth
FabioLuporini 2ce2797
misc: Tweak docstring
FabioLuporini 95b482c
compiler: Lift overrides from AffineIndexAccessFunc into IndexAccessFunc
FabioLuporini 0453503
arch: Add amdclang mapping
FabioLuporini File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
compiler: Enhance fusion upon lower_index_derivative
- Loading branch information
commit 380d26266426dcd2d624cf8aee06c87d85ed2429
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,30 @@ | ||
from devito.finite_differences import IndexDerivative | ||
from devito.ir import Cluster, Interval, IntervalGroup, IterationSpace | ||
from devito.symbolics import retrieve_dimensions, q_leaf, uxreplace | ||
from devito.passes.clusters.misc import fuse | ||
from devito.symbolics import (retrieve_dimensions, reuse_if_untouched, q_leaf, | ||
uxreplace) | ||
from devito.tools import as_tuple, filter_ordered, timed_pass | ||
from devito.types import Eq, Inc, Spacing, StencilDimension, Symbol | ||
|
||
__all__ = ['lower_index_derivatives'] | ||
|
||
|
||
@timed_pass() | ||
def lower_index_derivatives(clusters, sregistry=None, **kwargs): | ||
def lower_index_derivatives(clusters, mode=None, **kwargs): | ||
clusters = _lower_index_derivatives(clusters, **kwargs) | ||
if mode != 'noop': | ||
clusters = fuse(clusters, toposort=True) | ||
|
||
return clusters | ||
|
||
def _lower_index_derivatives(clusters, sregistry=None, **kwargs): | ||
processed = [] | ||
weights = {} | ||
for c in clusters: | ||
|
||
exprs = [] | ||
for e in c.exprs: | ||
expr, v = _lower_index_derivatives(e, c, weights, sregistry) | ||
expr, v = _lower_index_derivatives_core(e, c, weights, sregistry) | ||
exprs.append(expr) | ||
processed.extend(v) | ||
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. move in 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. no, that would be wrong |
||
|
||
|
@@ -24,7 +33,7 @@ def lower_index_derivatives(clusters, sregistry=None, **kwargs): | |
return processed | ||
|
||
|
||
def _lower_index_derivatives(expr, c, weights, sregistry): | ||
def _lower_index_derivatives_core(expr, c, weights, sregistry): | ||
""" | ||
Recursively carry out the core of `lower_index_derivatives`. | ||
""" | ||
|
@@ -34,11 +43,11 @@ def _lower_index_derivatives(expr, c, weights, sregistry): | |
args = [] | ||
processed = [] | ||
for a in expr.args: | ||
e, clusters = _lower_index_derivatives(a, c, weights, sregistry) | ||
e, clusters = _lower_index_derivatives_core(a, c, weights, sregistry) | ||
args.append(e) | ||
processed.extend(clusters) | ||
|
||
expr = expr.func(*args) | ||
expr = reuse_if_untouched(expr, args) | ||
|
||
if not isinstance(expr, IndexDerivative): | ||
return expr, processed | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
set(i.find(Spacing) for i in weights)
?