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

compiler: Implement graceful lowering of derivatives (aka "unexpansion") #2060

Merged
merged 61 commits into from
Feb 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
f799a72
compiler: Prototype unexpansion
FabioLuporini Nov 24, 2022
ffc8c21
compiler: Revamp code generation from _C_ctype
FabioLuporini Nov 25, 2022
91eee45
compiler: Support trivial unexpanded-derivatives examples
FabioLuporini Nov 26, 2022
0eddd5d
dsl: Patch cross_derivative evaluation
FabioLuporini Nov 26, 2022
63f41e8
dsl: Introduce Spacing subclass
FabioLuporini Nov 28, 2022
a94ab05
compiler: Patch StencilDimension reconstruction
FabioLuporini Nov 28, 2022
ce7c96c
compiler: Extend unexpansion machinery
FabioLuporini Nov 26, 2022
4d63f17
compiler: Support StencilDimension in estimate_cost
FabioLuporini Dec 3, 2022
380d262
compiler: Enhance fusion upon lower_index_derivative
FabioLuporini Dec 3, 2022
45b5fa4
compiler: Rework is_cross rule for Cluster fusion
FabioLuporini Dec 10, 2022
8805cd9
compiler: Implement maximal fusion for lowered IndexDerivatives
FabioLuporini Dec 12, 2022
573ba59
compiler: Patch profiling in presence of StencilDimensions
FabioLuporini Dec 12, 2022
fda18ef
compiler: Improve IndexDerivative lowering to catch duplicates
FabioLuporini Dec 12, 2022
be02291
compiler: Enhance pow_to_mul to work around SymPy misbehavior
FabioLuporini Dec 13, 2022
c069dfe
compiler: Rework globals generation for device backends
FabioLuporini Dec 13, 2022
573b4cb
compiler: Rework weights generation for device backends
FabioLuporini Dec 13, 2022
eb8616c
compiler: Patch index mode detection with StencilDimensions
FabioLuporini Dec 15, 2022
0044b3b
compiler: Add IndexDerivative.mapper
FabioLuporini Dec 22, 2022
fb6c226
compiler: Patch lower_index_derivative
FabioLuporini Dec 23, 2022
9a6679a
tests: Patch draft flaky unexpansion test
FabioLuporini Dec 23, 2022
958c9a0
compiler: Patch lower_index_derivatives
FabioLuporini Dec 23, 2022
3f73098
compiler: Patch globs codegen for deterministic output
FabioLuporini Dec 27, 2022
8d28be1
compiler: Relax Properties manipulation methods
FabioLuporini Dec 27, 2022
3eecf4d
compiler: Change IndexDerivative.mapper
FabioLuporini Dec 30, 2022
9a843ba
compiler: Add IterationSpace.translate
FabioLuporini Jan 3, 2023
52e076a
compiler: Move IndexSum.mapper to IndexDerivative.mapper
FabioLuporini Jan 3, 2023
a993d0d
compiler: Patch IndexDerivative.mapper
FabioLuporini Jan 5, 2023
417dac4
compiler: Relax WAR dependencies involving shared Array
FabioLuporini Jan 9, 2023
9c6ac52
compiler: Maximize likelihood of fusing clusters over shm
FabioLuporini Jan 9, 2023
42627b1
compiler: Improve data dependence analysis
FabioLuporini Jan 10, 2023
fead97c
compiler: Add Jump mixin class
FabioLuporini Jan 11, 2023
19f6af3
compiler: Patch collect_derivative pass
FabioLuporini Jan 13, 2023
17ab99b
compiler: Add shm-related heuristics to Cluster fusion
FabioLuporini Jan 20, 2023
c2044d5
compiler: Add Properties methods
FabioLuporini Jan 21, 2023
60e2e03
compiler: Make IndexDerivatives comparable; fix their CSE
FabioLuporini Jan 25, 2023
e5ea4d6
compiler: Draft Guards, akin to Properties
FabioLuporini Jan 31, 2023
9d579b1
compiler: Rework customization of clusters visitors
FabioLuporini Jan 31, 2023
fcc2e86
compiler: Fix Cluster properties normalization at init
FabioLuporini Jan 31, 2023
50025f5
compiler: Extend uxreplace to substitute types as well
FabioLuporini Feb 3, 2023
3496221
compiler: Fixup linearization with isolated routines
FabioLuporini Feb 3, 2023
fcfa448
misc: Fixup pep8 violations
FabioLuporini Feb 4, 2023
c562c30
compiler: Introduce AffineIndexAccessFunction
FabioLuporini Feb 6, 2023
43e700f
compiler: Improve IndexDerivative
FabioLuporini Feb 6, 2023
a588b6d
compiler: Enhance dtype retrieval
FabioLuporini Feb 6, 2023
18bc963
compiler: Tidy up Interval.expand()
FabioLuporini Feb 6, 2023
2640df3
compiler: Drop has_free for compatibility with older SymPy versions
FabioLuporini Feb 7, 2023
5113825
examples: Update expected notebook output
FabioLuporini Feb 7, 2023
0297597
compiler: Patch codegen upon pow_to_mul
FabioLuporini Feb 7, 2023
2c5eb4d
misc: Postpone codegen speed improvement
FabioLuporini Feb 7, 2023
403a194
examples: Update expected output
FabioLuporini Feb 8, 2023
62e0fc8
examples: Disable openmp where necessary due to issue 2061
FabioLuporini Feb 8, 2023
0c801bd
compiler: Exploit SubDim.local to support nasty deps in examples
FabioLuporini Feb 8, 2023
a97f6e6
ci: Drop support for gcc5, sympy1.7, sympy1.8
FabioLuporini Feb 8, 2023
77eae11
compiler: Add IndexDerivative.total_order
FabioLuporini Feb 8, 2023
9af12f4
arch: Enable openmp with nvc on CPU
FabioLuporini Feb 8, 2023
f33fcfc
ci: Add back forgotten gcc-11
FabioLuporini Feb 9, 2023
88fafce
compiler: Tweak lower_index_derivatives
FabioLuporini Feb 9, 2023
dde53cc
compiler: IndexDerivative.total_order -> depth
FabioLuporini Feb 10, 2023
2ce2797
misc: Tweak docstring
FabioLuporini Feb 10, 2023
95b482c
compiler: Lift overrides from AffineIndexAccessFunc into IndexAccessFunc
FabioLuporini Feb 10, 2023
0453503
arch: Add amdclang mapping
FabioLuporini Feb 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
compiler: Add IndexDerivative.total_order
  • Loading branch information
FabioLuporini committed Feb 8, 2023
commit 77eae11114711dcc10c02f58aac248a55493f6d7
5 changes: 5 additions & 0 deletions devito/finite_differences/differentiable.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,11 @@ def weights(self):
def mapper(self):
return self._mapper

@property
def total_order(self):
iderivs = self.expr.find(IndexDerivative)
return 1 + max([i.total_order for i in iderivs], default=0)
Copy link
Contributor

Choose a reason for hiding this comment

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

why 1+?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

self is an IndexDerivative :)

Copy link
Contributor

Choose a reason for hiding this comment

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

IndexDerivative don't have an order? If an IndexDerivative is always 1 it's gonna lead to inconsistency with the actual order of the derivative.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you have an IndexDerivative (say self), the total_order will definitely be 1 + X. 1 is for self; X depends on the arguments. This still looks correct to me , it's also used in two tests (admittedly in a very simple way)

Copy link
Contributor

Choose a reason for hiding this comment

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

1 is for self;

But why is it one it could be any order derivative it's the representation of the stencil expression that corresponds to a derivative with deriv_order order not just 1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, yes, I see what you mean now, sorry!

I don't even have the deriv_order information at this point anymore. Perhaps I should attach it when IndexDerivative is created inside finite_differences.py. There it's definitely available!

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've just realized that what I need for the heuristics I have in place in PRO is the concept of depth, not the total_order (I'm not that sophisticated yet...). So I'm renaming it as "depth", which is what the current implementation represents.


def _evaluate(self, **kwargs):
expr = super()._evaluate(**kwargs)

Expand Down
2 changes: 2 additions & 0 deletions tests/test_derivatives.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,7 @@ def test_dx2(self):

term1 = f.dx2._evaluate(expand=False)
assert isinstance(term1, IndexDerivative)
assert term1.total_order == 1
term1 = term1.evaluate
assert isinstance(term1, Add) # devito.fd.Add

Expand All @@ -715,6 +716,7 @@ def test_dxdy(self):

term1 = f.dx.dy._evaluate(expand=False)
assert isinstance(term1, IndexDerivative)
assert term1.total_order == 2
term1 = term1.evaluate
assert isinstance(term1, Add) # devito.fd.Add

Expand Down