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

Merged
merged 11 commits into from
Jul 10, 2024

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 86.74%. Comparing base (513fe29) to head (b306e07).

Files Patch % Lines
devito/passes/clusters/implicit.py 89.28% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2393   +/-   ##
=======================================
  Coverage   86.74%   86.74%           
=======================================
  Files         235      235           
  Lines       44542    44553   +11     
  Branches     8247     8250    +3     
=======================================
+ Hits        38637    38647   +10     
- Misses       5186     5187    +1     
  Partials      719      719           

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

@EdCaunt EdCaunt requested a review from georgebisbas June 28, 2024 15:21
@@ -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

@EdCaunt EdCaunt force-pushed the subdomainset_rework branch from aa59e18 to 27ad936 Compare July 1, 2024 08:49
@EdCaunt EdCaunt requested a review from FabioLuporini July 1, 2024 10:18
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 requested review from georgebisbas and mloubout July 2, 2024 12:50
@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

@EdCaunt EdCaunt force-pushed the subdomainset_rework branch 2 times, most recently from 14f6fb0 to e9393e7 Compare July 9, 2024 10:15
@EdCaunt EdCaunt force-pushed the subdomainset_rework branch from e9393e7 to b306e07 Compare July 10, 2024 12:20
@mloubout mloubout merged commit 03aec47 into master Jul 10, 2024
30 of 31 checks passed
@mloubout mloubout deleted the subdomainset_rework branch July 10, 2024 16:06
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.

4 participants