-
Notifications
You must be signed in to change notification settings - Fork 257
mpi: Prevent parallel halo exchanges #2972
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
Changes from all commits
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 |
|---|---|---|
|
|
@@ -218,10 +218,10 @@ def preprocess(clusters, options=None, **kwargs): | |
| # dimension requiring a loc-index in the HaloScheme. The compiler | ||
| # will generate the non-perfect loop nest `t,f ; t,x,y,z,f`, with | ||
| # the first nest triggering all necessary halo exchanges along `f` | ||
| mapper = as_mapper(found, lambda c1: c1.ispace) | ||
| for k, v in mapper.items(): | ||
| mapper = as_mapper(found, lambda c1: (c1.ispace, c1.properties)) | ||
| for v in mapper.values(): | ||
| hs = HaloScheme.union([c1.halo_scheme for c1 in v]) | ||
| processed.append(c.rebuild(exprs=[], ispace=k, halo_scheme=hs)) | ||
| processed.append(v[0].rebuild(exprs=[], halo_scheme=hs)) | ||
|
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. Isn't this changing the type being appended to
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, if what you said were true, many many tests would fail badly
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. Ah ok, this is from me misunderstanding |
||
| processed.append(c) | ||
| else: | ||
| # Avoid ugly empty loops | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2242,6 +2242,38 @@ def test_lift_halo_update_outside_distributed(self, mode): | |
| halo_update = tloop.nodes[0].body[0].body[0].body[0] | ||
| assert isinstance(halo_update, HaloUpdateList) | ||
|
|
||
| @pytest.mark.parallel(mode=4) | ||
|
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. The incorrect code still gets generated with 1 rank of MPI fwiw. It also won't hang CI in this configuration if it does go wrong, and will instead fail on the structure tests |
||
| def test_ensure_halo_updates_within_seq_loops(self, mode): | ||
| n = 30 | ||
| grid = Grid(shape=(n, n)) | ||
|
|
||
| x, y = grid.dimensions | ||
| d = Dimension(name="d") | ||
|
|
||
| a = Function(name="a", grid=grid, space_order=8) | ||
| b = a.func(name='b') | ||
|
|
||
| g = Function(name="g", grid=grid, space_order=8, dimensions=(x, y, d), | ||
| shape=(n, n, 2)) | ||
| h = g.func(name='h') | ||
|
|
||
| eqns = [Eq(a, 0.0), | ||
|
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. Some of these equations can be dropped or simplified iirc. I had something along the lines of: eqns = [Eq(h, 1), Inc(a, h.dx + h.dy)]which also allows for the
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. yes, I know, but I don't think it hurts to leave it a little bit more convoluted, in this particular case and based on what I see while I was debugging it |
||
| Eq(h, b * g), | ||
| Inc(a, b * (h.dx + h.dy))] | ||
|
|
||
| op = Operator(eqns, opt=('advanced', {'openmp': True})) | ||
| _ = op.cfunction | ||
|
|
||
| # Check generated code -- expected one halo exchange within a sequential | ||
| # `d` loop | ||
| assert_structure(op, ['x,y', 'x,y,d', 'd', 'x,y,d'], 'xyddxyd') | ||
| iters = FindNodes(Iteration).visit(op) | ||
| assert iters[2].dim is d and iters[2].is_Parallel | ||
| assert iters[3].dim is d and iters[3].is_Sequential | ||
|
|
||
| # Probably unnecessary, but ensures there's no hanging | ||
|
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. Hanging CI is annoying at best and I agree the
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. it won't hang anyway since we run it under a timeout of 300 secs -- not sign of life in 5 mins => death |
||
| op.apply() | ||
|
|
||
| @pytest.mark.parallel(mode=4) | ||
| def test_halo_inner_dim(self, mode): | ||
| grid = Grid((11, 11, 11)) | ||
|
|
||
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.
How does
c1.propertiesend up being used here?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.
that's the actual bug fix
if you don't use the HaloTouch's properties, where the
dloop in correctly tagged as sequential, but rather reusec's properties via rebuild (main's behaviour) thendmay erroneously be tagged as parallell depending on its status incThere 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.
Oh, so the rebuild was actually changing the properties of the innermost dimension of the cluster?
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.
not quite. We were using the rebuild to create a new Cluster -- a Cluster whose sole purpose was carrying a
halo_scheme. But usingc's rebuild cause us inheriting the wrong properties