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

Use new CV capabilities via arraycontext #355

Merged
merged 28 commits into from
Jun 10, 2021
Merged

Use new CV capabilities via arraycontext #355

merged 28 commits into from
Jun 10, 2021

Conversation

MTCam
Copy link
Member

@MTCam MTCam commented May 22, 2021

It is regretful this is such a giant haul, but it turns out this was something real hard to do incrementally.

Copy link
Contributor

@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 so much for taking this on, this is great! Two thoughts from a quick scroll below.

@@ -313,6 +312,30 @@ def join_conserved(dim, mass, energy, momentum,
return result


def create_conserved(dim, mass, energy, momentum, species_mass=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this needed? Couldn't we just call the ConservedVars constructor?

Copy link
Member Author

Choose a reason for hiding this comment

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

Can we overload the constructor and retain the shape and structure validation?

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair point!

There's __post_init__ in a dataclass (docs), but revalidating on every object construction is an easy way to get really slow code. I'm warming to having an explicit function that does this. I've tended to call these make_xxx. (examples: make_kernel in loopy, make_xxx in pytato)

Copy link
Member Author

Choose a reason for hiding this comment

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

I hope this helps a little. (d012fba)

mirgecom/euler.py Show resolved Hide resolved
@inducer
Copy link
Contributor

inducer commented May 22, 2021

And: I'm super supportive of trying to get this in super ASAP, to avoid a huge conflict nightmare.

mirgecom/flux.py Outdated
Comment on lines 77 to 78
return flux_avg.join() @ normal - 0.5*lam*(cv_tpair.ext.join()
- cv_tpair.int.join())
Copy link
Member Author

Choose a reason for hiding this comment

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

These joins are after:

return flux_avg @ normal - 0.5*lam*(cv_tpair.ext - cv_tpair.int)

gave this error:

E ValueError: matmul: Input operand 0 does not have enough dimensions (has 0, gufunc core with signature (n?,k),(k,m?)->(n?,m?) requires 1)

After using the "join" of flux_avg:

return flux_avg.join() @ normal - 0.5*lam*(cv_tpair.ext - cv_tpair.int)

this error:

E TypeError: unsupported operand type(s) for *: 'DOFArray' and 'ConservedVars'

Copy link
Contributor

Choose a reason for hiding this comment

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

Great question! inducer/arraycontext#12

Copy link
Contributor

Choose a reason for hiding this comment

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

As of inducer/arraycontext#15, this should now be doable. Note that you may need to tweak some of the arguments to with_container_arithmetic. See the tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

@MTCam MTCam added the enhancement New feature or request label May 23, 2021
Base automatically changed from cv-actx to main June 5, 2021 05:21
@MTCam MTCam marked this pull request as ready for review June 9, 2021 19:48
@MTCam
Copy link
Member Author

MTCam commented Jun 9, 2021

Ok, I've spent some time rolling these changes all the way up the Y1 tower - and everything only improves with it. I still regret this PR is so giant, but the changes are mostly trivial - and where they are not trivial they improve the code.

Hopefully not a terribly painful review.

Copy link
Contributor

@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, this looks great! A few notes below, otherwise good to go. FWIW, this was pretty painless to review.

mirgecom/simutil.py Outdated Show resolved Hide resolved
test/test_bc.py Outdated Show resolved Hide resolved
test/test_filter.py Show resolved Hide resolved
test/test_euler.py Show resolved Hide resolved
test/test_euler.py Show resolved Hide resolved
test/test_init.py Show resolved Hide resolved
@MTCam
Copy link
Member Author

MTCam commented Jun 10, 2021

Narrowly avoided a gitastrophy.

@MTCam MTCam merged commit 1f8b3cb into main Jun 10, 2021
@MTCam MTCam deleted the huck-up-to-cv branch June 10, 2021 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants