Repository navigation
mpi: Fix halos of SubDomain Functions next to empty ranks #3099
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
base: main
Are you sure you want to change the base?
Changes from all commits
61b3374
b428b0e
9366d40
2ed4bc6
ba9d60d
0be3f47
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -705,6 +705,14 @@ def neighborhood(self): | |
|
|
||
| return ret | ||
|
|
||
| @cached_property | ||
| def _obj_neighborhood(self): | ||
| # The neighborhood is determined by the SubDomain thicknesses, hence the | ||
| # name. E.g., `nb_x0_7` for `{x: ('middle', 0, 7), y: y}` | ||
| name = ''.join(f'_{d.root.name}{d.ltkn.value}_{d.rtkn.value}' | ||
| for d in self.dimensions if d.is_Sub) | ||
| return MPINeighborhood(self.neighborhood, name=f'nb{name}') | ||
|
|
||
| @cached_property | ||
| def rank_populated(self): | ||
| """Constant symbol for a switch indicating that data is allocated on this rank""" | ||
|
|
@@ -852,14 +860,15 @@ def _arg_values(self, *args, **kwargs): | |
| class MPINeighborhood(CompositeObject): | ||
|
|
||
| __rargs__ = ('neighborhood',) | ||
| __rkwargs__ = ('name',) | ||
|
|
||
| def __init__(self, neighborhood): | ||
| def __init__(self, neighborhood, name='nb'): | ||
|
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. Maybe a better default name, since
Contributor
Author
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. The current default name is |
||
| self._neighborhood = neighborhood | ||
|
|
||
| self._entries = [i for i in neighborhood if isinstance(i, tuple)] | ||
|
|
||
| fields = [(''.join(j.name[0] for j in i), c_int) for i in self.entries] | ||
| super().__init__('nb', 'neighborhood', fields) | ||
| super().__init__(name, 'neighborhood', fields) | ||
|
|
||
| @property | ||
| def entries(self): | ||
|
|
@@ -894,12 +903,11 @@ def _arg_defaults(self): | |
| return values | ||
|
|
||
| def _arg_values(self, *args, **kwargs): | ||
| grid = kwargs.get('grid') | ||
| # Update `nb` based on object attached to `grid` | ||
| if grid is not None: | ||
| return grid.distributor._obj_neighborhood._arg_defaults() | ||
| else: | ||
| return self._arg_defaults() | ||
| # Use `nb` as provided by the (possibly overriding) Grid or SubDomain. | ||
| # E.g., an override may be defined on a new Grid | ||
| if self.name in kwargs.get('args', {}): | ||
| return {} | ||
|
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. shouldn't it be the usual
Contributor
Author
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. No, since it should only fire here if the override/default has not already been processed by either |
||
| return self._arg_defaults() | ||
|
|
||
|
|
||
| class CustomTopology(DimensionTuple): | ||
|
|
||
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.
why
ltkn/rtkn.valueinstead of.nameThere 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.
It's not mandatory to give subdomains unique names, although I agree that this solution is kinda inelegant