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

Array container support and batched (eager) communication #154

Merged
merged 50 commits into from
Dec 6, 2021

Conversation

thomasgibson
Copy link
Collaborator

@thomasgibson thomasgibson commented Aug 17, 2021

This PR modifies existing grudge routines to work on arbitrary array containers and batches eager MPI communication of containers.

Requires: inducer/arraycontext#91

grudge/trace_pair.py Outdated Show resolved Hide resolved
grudge/trace_pair.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@alexfikl alexfikl left a comment

Choose a reason for hiding this comment

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

Gave this a very quick look and left a few comments here and there, hope you don't mind!

The TracePair stuff seems a bit more complicated, so I mostly skipped it 😁

examples/wave/wave-op-mpi.py Show resolved Hide resolved
examples/wave/wave-op-mpi.py Outdated Show resolved Hide resolved
examples/wave/wave-op-mpi.py Outdated Show resolved Hide resolved
examples/wave/wave-op-mpi.py Outdated Show resolved Hide resolved
grudge/op.py Outdated Show resolved Hide resolved
grudge/op.py Outdated Show resolved Hide resolved
grudge/op.py Outdated Show resolved Hide resolved
grudge/projection.py Outdated Show resolved Hide resolved
@thomasgibson thomasgibson marked this pull request as ready for review September 16, 2021 19:09
Copy link
Collaborator Author

@thomasgibson thomasgibson left a comment

Choose a reason for hiding this comment

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

Some comments to help explain my thoughts.

grudge/trace_pair.py Outdated Show resolved Hide resolved
grudge/trace_pair.py Outdated Show resolved Hide resolved
@thomasgibson thomasgibson self-assigned this Sep 20, 2021
@thomasgibson
Copy link
Collaborator Author

thomasgibson commented Sep 21, 2021

The Mirgecom CI failure seems to be due to using the map_array_container in the operator application routines (not the distributed memory bits). Will investigate this...

Edit: I don't know if it's something fundamentally wrong with map_array_container, but for some reason, the map_array_container is attempting to serialize floats!?

@alexfikl
Copy link
Collaborator

alexfikl commented Sep 21, 2021

The Mirgecom CI failure seems to be due to using the map_array_container in the operator application routines (not the distributed memory bits). Will investigate this...

Edit: I don't know if it's something fundamentally wrong with map_array_container, but for some reason, the map_array_container is attempting to serialize floats!?

Looks like map_array_container is not catching the NotImplementedError for floats correctly and trying to deserialize them anyway. I'd say this is a bug in arraycontext.

I'll try to come up with a fix this afternoon. In the meantime, you can probably work around it by checking not isinstance(vec, DOFArray) and is_array_container(vec) before calling map_array_container (?).

EDIT: Actually, that check needs to be expanded anyway, otherwise it looks a lot like an infinite loop if you give it a float to start with?

@thomasgibson
Copy link
Collaborator Author

@alexfikl I think it was a very subtle type-checking issue! I managed to fix the mrigecom issue with this commit: 42adaf1

@thomasgibson thomasgibson changed the title Array container support Array container support and batched (eager) communication Sep 21, 2021
Copy link
Owner

@inducer inducer left a comment

Choose a reason for hiding this comment

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

Thanks for working on this! A few wrinkles (hopefully easy to answer/fix) in the communication bit, but otherwise this looks nice!

grudge/trace_pair.py Outdated Show resolved Hide resolved
grudge/trace_pair.py Outdated Show resolved Hide resolved
grudge/trace_pair.py Outdated Show resolved Hide resolved
grudge/trace_pair.py Outdated Show resolved Hide resolved
@inducer
Copy link
Owner

inducer commented Sep 23, 2021

Unsubscribing... @-mention or request review once it's ready for a look or needs attention.

grudge/trace_pair.py Outdated Show resolved Hide resolved
@thomasgibson
Copy link
Collaborator Author

@inducer when this lands, do not delete this branch; I will take care of it since I need to reset the base branch in #172

Copy link
Owner

@inducer inducer left a comment

Choose a reason for hiding this comment

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

Thanks, and sorry again about the long wait on another review. Also sorry that I've uncovered a few more things. I hope most of this is easy. There are a lot of comments here, but most of them are just about consistency in doing the same thing in multiple places. I hope you'll be able to dispatch them quickly using the "apply suggestions" feature.

grudge/op.py Show resolved Hide resolved
grudge/op.py Show resolved Hide resolved
grudge/op.py Outdated
a :class:`~meshmode.dof_array.DOFArray`\ s,
:arg vecs: an object array of
:class:`~meshmode.dof_array.DOFArray`\s or
:class:`~arraycontext.container.ArrayContainer` objects,
Copy link
Owner

Choose a reason for hiding this comment

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

I don't think _div_helper deals with anything other than object arrays.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I believe this is all cleared up in a877340. _div_helper is intentionally only working on object arrays, as the container is expected to have vector (obj array) entries.

grudge/op.py Outdated
Comment on lines 281 to 287
:arg vecs: an object array of
:class:`~meshmode.dof_array.DOFArray`\ s or
:class:`~arraycontext.container.ArrayContainer` objects,
where the last axis of the array must have length
matching the volume dimension.
:returns: a :class:`~meshmode.dof_array.DOFArray`.
:returns: a :class:`~meshmode.dof_array.DOFArray` or an
:class:`~arraycontext.container.ArrayContainer` of them.
Copy link
Owner

Choose a reason for hiding this comment

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

I don't think _div_helper deals with anything other than object arrays.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I believe this is all cleared up in a877340. _div_helper is intentionally only working on object arrays, as the container is expected to have vector (obj array) entries.

grudge/projection.py Outdated Show resolved Hide resolved
grudge/trace_pair.py Outdated Show resolved Hide resolved
grudge/trace_pair.py Outdated Show resolved Hide resolved
grudge/trace_pair.py Outdated Show resolved Hide resolved
grudge/trace_pair.py Outdated Show resolved Hide resolved
grudge/trace_pair.py Outdated Show resolved Hide resolved
@inducer
Copy link
Owner

inducer commented Nov 3, 2021

Unsubscribing... @-mention or request review once it's ready for a look or needs attention.

@thomasgibson
Copy link
Collaborator Author

@inducer This is ready for another look

@inducer
Copy link
Owner

inducer commented Dec 1, 2021

Thanks for working on this! Some proposed changes to this in #191. This LGTM (and is ready to land in my view) subject to those (or similar) changes.

* Refactor grad/weak grad to use the same helper, simplify div empty handling

* Factor out some redundant code in elementwise reductions
@inducer inducer enabled auto-merge (squash) December 6, 2021 22:56
@inducer
Copy link
Owner

inducer commented Dec 6, 2021

Thanks for seeing this through! In it goes. 🎉

@inducer inducer merged commit d48c9bc into main Dec 6, 2021
@inducer inducer deleted the thg/array-containers branch December 6, 2021 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
distributed Relating to distributed-memory support enhancement New feature or request
Projects
None yet
4 participants