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: Drop SubDomainSet earlier during compilation for more graceful lowering #2393

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

EdCaunt
Copy link
Contributor

@EdCaunt EdCaunt commented Jun 28, 2024

No description provided.

Copy link

codecov bot commented Jun 28, 2024

Codecov Report

Attention: Patch coverage is 94.11765% with 3 lines in your changes missing coverage. Please review.

Project coverage is 78.03%. Comparing base (f518eb3) to head (e9393e7).

Files Patch % Lines
devito/passes/clusters/implicit.py 89.28% 3 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (f518eb3) and HEAD (e9393e7). Click for more details.

HEAD has 11 uploads less than BASE
Flag BASE (f518eb3) HEAD (e9393e7)
16 5
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2393      +/-   ##
==========================================
- Coverage   86.72%   78.03%   -8.69%     
==========================================
  Files         235      235              
  Lines       44521    44442      -79     
  Branches     8242     5877    -2365     
==========================================
- Hits        38611    34682    -3929     
- Misses       5189     8982    +3793     
- Partials      721      778      +57     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -94,8 +91,12 @@ def callback(self, clusters, prefix):
processed.append(c)
continue

msdims = [msdim(i.dim) for i in c.ispace[idx:]]
Copy link
Contributor

Choose a reason for hiding this comment

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

{msdim(i.dim) for i in c.ispace[idx:]} - {None}

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 suppose the mapper is unordered, so can use a set here. Good spot

@@ -169,8 +170,12 @@ def callback(self, clusters, prefix):
except IndexError:
continue

msdims = [i.dim for i in ispace]
Copy link
Contributor

Choose a reason for hiding this comment

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

same

# Get the dynamic thickness mapper for the given MultiSubDomain
mapper, dims = lower_msd(d.msd, c)
mapper, dims = lower_msd(msdims)
# mapper, dims = lower_msd(d.msd, c)
Copy link
Contributor

Choose a reason for hiding this comment

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

leftover

for d in msdims:
# Pull out the parent MultiSubDimension if blocked etc
msds = [d for d in d._defines if d.is_MultiSub]
assert len(msds) == 1 # Sanity check. MultiSubDimensions shouldn't be nested.
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.

Just for safety before the .pop(). Means that it will throw an error rather than failing cryptically if anything does go wrong/is overlooked

f[j].data[:] = self._local_bounds[idx]

d._implicit_dimension = i_dim
d._functions = f
Copy link
Contributor

Choose a reason for hiding this comment

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

modifying d isn't great should rebuild it or create a new one

Copy link
Contributor

Choose a reason for hiding this comment

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

this is within the lazy constructor, so it's kinda acceptable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was able to shuffle things around, remove the modification, and reduce the number of lines

@mloubout mloubout added the API api (symbolics, types, ...) label Jun 28, 2024
@EdCaunt EdCaunt requested a review from mloubout June 28, 2024 16:17
Copy link
Contributor

@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.

Left some comments; note that changing the lower_msd interface will also break PRO

# to create the implicit equations. Untangling this is definitely
# possible, but not straightforward
self.msd = msd
__rargs__ = ('name', 'parent')
Copy link
Contributor

Choose a reason for hiding this comment

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

mapper, dims = lower_msd(d.msd, c)
# Get all MultiSubDimensions in the cluster and get the dynamic thickness
# mapper for the associated MultiSubDomain
mapper, dims = lower_msd({msdim(i.dim) for i in c.ispace[idx:]} - {None})
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I understand this change. If you are visiting d, why do you need its msd as well as any other nested msds ?

I don't think this is particularly clean, but besides that, I'm failing to understand 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.

lower_msd has been completely replaced. Now stands for "lower multisubdimension" and takes all the multisubdimensions present in the cluster, rather than the multisubdomain attached to the outermost dimension (all references to which have been dropped at this point).

@@ -170,7 +169,7 @@ def callback(self, clusters, prefix):
continue

# Get the dynamic thickness mapper for the given MultiSubDomain
mapper, dims = lower_msd(d.msd, c)
mapper, dims = lower_msd({i.dim for i in ispace})
Copy link
Contributor

Choose a reason for hiding this comment

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

same story as above

for j in range(2):
idx = 2*i + j
if isinstance(self._local_bounds[idx], int):
sd_func.data[:, idx] = np.full((self._n_domains,),
Copy link
Contributor

Choose a reason for hiding this comment

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

why not just sd_func.data[:, idx] = self._local_bounds[idx] ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good spot. Also removes a bunch of extra complexity

@EdCaunt EdCaunt self-assigned this Jul 2, 2024
@@ -170,7 +172,7 @@ def callback(self, clusters, prefix):
continue

# Get the dynamic thickness mapper for the given MultiSubDomain
mapper, dims = lower_msd(d.msd, c)
mapper, dims = lower_msd({i.dim for i in ispace}, c)
Copy link
Contributor

Choose a reason for hiding this comment

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

this is just ispace.itdims

Copy link
Contributor

Choose a reason for hiding this comment

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

can do in another PR

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'll get forgotten if it isn't done here, so will just do it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API api (symbolics, types, ...) compiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants