-
Notifications
You must be signed in to change notification settings - Fork 244
compiler: Enhance IR to support more advanced parlang (CUDA/HIP/SYCL) features #2748
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
Open
FabioLuporini
wants to merge
18
commits into
main
Choose a base branch
from
tma-inception-on-sched-revamp
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
cf0d41a
compiler: Add FunctionMap type
FabioLuporini 8e68691
compiler: Add ULONG to __all__
FabioLuporini f07cde0
compiler: Improve lowering of LocalObjects
FabioLuporini a627b4e
compiler: Add LocalObject._mem_shared
FabioLuporini 8fbdb9c
compiler: Add BitwiseNot and BitwiseXor
FabioLuporini fd1e579
compiler: Add LocalType._C_tag
FabioLuporini 190b5ac
compiler: Move and enhance FunctionMap
FabioLuporini c88c3a4
arch: async-loads -> async-pipe
FabioLuporini 6de6e1a
compiler: Fix IREq.__repr__
FabioLuporini bf6ec75
compiler: Generalize ideriv lowering
FabioLuporini 39e4219
compiler: Avoid CSE across Reserved keywords
FabioLuporini e154122
compiler: Introduce Terminal mixin for SymPy subclasses
FabioLuporini 18b0c0f
compiler: Pass ctx down to _map_function_on_high_bw_mem
FabioLuporini 3d3926b
compiler: Enhance _alloc_object_on_low_lat_mem
FabioLuporini b80af46
compiler: Fix abstract_object(Array)
FabioLuporini 306fc3b
compiler: Avoid spurious items in sub_iters and dirs
FabioLuporini 9e8c040
misc: Fix typo
FabioLuporini 8e55290
compiler: Pass kwargs to make_parallel
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
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ | |
| from sympy import S | ||
| import numpy as np | ||
|
|
||
| from devito.finite_differences import IndexDerivative | ||
| from devito.finite_differences import IndexDerivative, Weights | ||
| from devito.ir import Backward, Forward, Interval, IterationSpace, Queue | ||
| from devito.passes.clusters.misc import fuse | ||
| from devito.symbolics import BasicWrapperMixin, reuse_if_untouched, uxreplace | ||
|
|
@@ -94,17 +94,39 @@ def _core(expr, c, ispace, weights, reusables, mapper, **kwargs): | |
|
|
||
|
|
||
| @_core.register(Symbol) | ||
| @_core.register(Indexed) | ||
| @_core.register(BasicWrapperMixin) | ||
| def _(expr, c, ispace, weights, reusables, mapper, **kwargs): | ||
| return expr, [] | ||
|
|
||
|
|
||
| @_core.register(Indexed) | ||
| def _(expr, c, ispace, weights, reusables, mapper, **kwargs): | ||
| if not isinstance(expr.function, Weights): | ||
| return expr, [] | ||
|
|
||
| # Lower or reuse a previously lowered Weights array | ||
| sregistry = kwargs['sregistry'] | ||
| subs_user = kwargs['subs'] | ||
|
|
||
| w0 = expr.function | ||
| k = tuple(w0.weights) | ||
| try: | ||
| w = weights[k] | ||
| except KeyError: | ||
| name = sregistry.make_name(prefix='w') | ||
| dtype = infer_dtype([w0.dtype, c.dtype]) # At least np.float32 | ||
| initvalue = tuple(i.subs(subs_user) for i in k) | ||
| w = weights[k] = w0._rebuild(name=name, dtype=dtype, initvalue=initvalue) | ||
|
|
||
| rebuilt = expr._subs(w0.indexed, w.indexed) | ||
|
Contributor
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. why not just |
||
|
|
||
| return rebuilt, [] | ||
|
|
||
|
|
||
| @_core.register(IndexDerivative) | ||
| def _(expr, c, ispace, weights, reusables, mapper, **kwargs): | ||
| sregistry = kwargs['sregistry'] | ||
| options = kwargs['options'] | ||
| subs_user = kwargs['subs'] | ||
|
|
||
| try: | ||
| cbk0 = deriv_schedule_registry[options['deriv-schedule']] | ||
|
|
@@ -117,18 +139,10 @@ def _(expr, c, ispace, weights, reusables, mapper, **kwargs): | |
|
|
||
| # Create the concrete Weights array, or reuse an already existing one | ||
| # if possible | ||
| name = sregistry.make_name(prefix='w') | ||
| w0 = ideriv.weights.function | ||
| dtype = infer_dtype([w0.dtype, c.dtype]) # At least np.float32 | ||
| k = tuple(w0.weights) | ||
| try: | ||
| w = weights[k] | ||
| except KeyError: | ||
| initvalue = tuple(i.subs(subs_user) for i in k) | ||
| w = weights[k] = w0._rebuild(name=name, dtype=dtype, initvalue=initvalue) | ||
| w, _ = _core(ideriv.weights, c, ispace, weights, reusables, mapper, **kwargs) | ||
|
|
||
| # Replace the abstract Weights array with the concrete one | ||
| subs = {w0.indexed: w.indexed} | ||
| subs = {ideriv.weights.base: w.base} | ||
| init = uxreplace(init, subs) | ||
| ideriv = uxreplace(ideriv, subs) | ||
|
|
||
|
|
@@ -155,13 +169,13 @@ def _(expr, c, ispace, weights, reusables, mapper, **kwargs): | |
| ispace1 = IterationSpace.union(ispace, ispace0, relations=extra) | ||
|
|
||
| # The Symbol that will hold the result of the IndexDerivative computation | ||
| # NOTE: created before recurring so that we ultimately get a sound ordering | ||
| # NOTE: created before recursing so that we ultimately get a sound ordering | ||
| try: | ||
| s = reusables.pop() | ||
| assert np.can_cast(s.dtype, dtype) | ||
| assert np.can_cast(s.dtype, w.dtype) | ||
| except KeyError: | ||
| name = sregistry.make_name(prefix='r') | ||
| s = Symbol(name=name, dtype=dtype) | ||
| s = Symbol(name=name, dtype=w.dtype) | ||
|
|
||
| # Go inside `expr` and recursively lower any nested IndexDerivatives | ||
| expr, processed = _core(expr, c, ispace1, weights, reusables, mapper, **kwargs) | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
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.
Would having a hashable items attribute like we use in some other classes clean this up a little?