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

dsl: Remove counters for SubDomains and MultiSubDomains #2405

Closed
wants to merge 13 commits into from
Closed

Conversation

EdCaunt
Copy link
Contributor

@EdCaunt EdCaunt commented Jul 12, 2024

Remove all counters used for SubDomains and SubDomainSets, instead dynamically renaming SubDimensions during compilation using a symbol registry.

Also ships some bugfixes and tests for SubDomainSet.

Copy link

codecov bot commented Jul 12, 2024

Codecov Report

Attention: Patch coverage is 54.79452% with 33 lines in your changes missing coverage. Please review.

Project coverage is 63.05%. Comparing base (0124871) to head (5e76bdc).

Files Patch % Lines
devito/ir/equations/algorithms.py 59.64% 21 Missing and 2 partials ⚠️
devito/passes/clusters/implicit.py 28.57% 5 Missing ⚠️
devito/types/grid.py 44.44% 5 Missing ⚠️

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

HEAD has 15 uploads less than BASE
Flag BASE (0124871) HEAD (5e76bdc)
16 1
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #2405       +/-   ##
===========================================
- Coverage   86.74%   63.05%   -23.70%     
===========================================
  Files         235      148       -87     
  Lines       44553    26737    -17816     
  Branches     8250     5505     -2745     
===========================================
- Hits        38647    16858    -21789     
- Misses       5187     9028     +3841     
- Partials      719      851      +132     

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

@@ -103,7 +106,13 @@ def callback(self, clusters, prefix):
processed.append(c)
continue

exprs, thickness = make_implicit_exprs(mapper, self.sregistry)
try:
Copy link
Contributor

Choose a reason for hiding this comment

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

just an if dim in thicknesses should be fine not need for try



def _lower_exprs(expressions, subs):
def _lower_exprs(expressions, subs, **kwargs):
# FIXME: Not sure why you can get this, but not access with index
Copy link
Contributor

Choose a reason for hiding this comment

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

?

Copy link
Contributor

Choose a reason for hiding this comment

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

second

def _lower_exprs(expressions, subs):
def _lower_exprs(expressions, subs, **kwargs):
# FIXME: Not sure why you can get this, but not access with index
sregistry = kwargs.get('sregistry')
Copy link
Contributor

Choose a reason for hiding this comment

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

From below looks like it's mandatory not optional so need a valid default one not None

Copy link
Contributor

Choose a reason for hiding this comment

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

the following is OK:

def _lower_exprs(..., sregistry=None, **kwargs):
    <use sregistry>



def _lower_exprs(expressions, subs):
def _lower_exprs(expressions, subs, **kwargs):
# FIXME: Not sure why you can get this, but not access with index
Copy link
Contributor

Choose a reason for hiding this comment

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

second

def _lower_exprs(expressions, subs):
def _lower_exprs(expressions, subs, **kwargs):
# FIXME: Not sure why you can get this, but not access with index
sregistry = kwargs.get('sregistry')
Copy link
Contributor

Choose a reason for hiding this comment

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

the following is OK:

def _lower_exprs(..., sregistry=None, **kwargs):
    <use sregistry>

for expr in as_tuple(expressions):
try:
dimension_map = expr.subdomain.dimension_map
except AttributeError:
# Some Relationals may be pure SymPy objects, thus lacking the subdomain
dimension_map = {}

if sregistry and dimension_map:
Copy link
Contributor

Choose a reason for hiding this comment

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

sregistry cannot be none except for perhaps some low-level tests, in which case you may just pass a dummy one instead

rename_thicknesses(dimension_map, sregistry, rebuilt)
# Rebuild ConditionalDimensions using rebuilt subdimensions
# The expression is then rebuilt with this ConditionalDimension
expr = rebuild_cdims(expr, rebuilt)
Copy link
Contributor

Choose a reason for hiding this comment

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

imho rename_thicknesses and rebuild_cdims should all be part of the same dispatch logic; you may use a ranking system (see https://github.com/devitocodes/devito/blob/master/devito/passes/iet/engine.py#L412-L415 for an example) to ensure certain objects are rebuilt before others.

nitpicking: uniquify_symbols sounds like a better name to me

@@ -92,6 +93,8 @@ def callback(self, clusters, prefix):
d = None
if d is None:
processed.append(c)
# If no MultiSubDomain present in this cluster, then tip should be reset
tip = None
Copy link
Contributor

Choose a reason for hiding this comment

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

with thicknesses now in place, do we actually still need this tip thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it keeps track of whether consecutive expressions are on the same SubDomainSet, and avoids generating additional unnecessary thickness expressions in this case. However, it did not previously reset if there was an expression without a SubDomainSet in the middle, which meant that you could create cases where the thickness expressions were erroneously omitted.

dimensions = list(dim.functions.dimensions)
dimensions[0] = idim

# TODO: Requires a name change for some reason not to break things. Why?
Copy link
Contributor

Choose a reason for hiding this comment

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

there's a lot of TODOs here

@EdCaunt
Copy link
Contributor Author

EdCaunt commented Aug 2, 2024

Superseded by #2431

@EdCaunt EdCaunt closed this Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants