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

add lazy option to wave-op-mpi #185

Merged
merged 8 commits into from
Nov 27, 2021
Merged

add lazy option to wave-op-mpi #185

merged 8 commits into from
Nov 27, 2021

Conversation

matthiasdiener
Copy link
Collaborator

No description provided.

@inducer
Copy link
Owner

inducer commented Nov 25, 2021

The CI appears to be failing for now. Request review when it's ready for a look or @-mention if it needs attention.

@matthiasdiener
Copy link
Collaborator Author

This is ready for review @inducer @thomasgibson

Copy link
Collaborator

@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.

Just one last comment, then this looks good to go. It's just concerning the thaw/freeze pattern I've been conditioned to do 😅

if comm.rank == 0:
logger.info("dt = %g", dt)

t = 0
t_final = 3
istep = 0
while t < t_final:
fields = rk4_step(fields, t, dt, rhs)
fields = rk4_step(fields, t, dt, compiled_rhs)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we might need to still perform the thaw/freeze pattern as illustrated in meshmode's simple-dg example. Maybe @inducer has more to say on this?

Suggested change
fields = rk4_step(fields, t, dt, compiled_rhs)
fields = thaw(freeze(fields, actx), actx)
fields = rk4_step(fields, t, dt, compiled_rhs)

Actually, I think my suggestion might not be the optimal way. The right way is probably illustrated here: https://github.com/inducer/meshmode/blob/main/examples/simple-dg.py#L494-L496 --- meaning we just wrap the rhs evaluations in a thaw/freeze pattern.

Copy link
Collaborator Author

@matthiasdiener matthiasdiener Nov 25, 2021

Choose a reason for hiding this comment

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

Hmm, but isn't the thaw/freeze pattern due to using two different actx (like simple-dg does)?

I'm also confused why the ESDG example just thaws/freezes on the same actx:

fields = thaw(freeze(fields, actx), actx)
fields = ssprk43_step(fields, t, dt, compiled_rhs)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I was under the impression that this was necessary to keep pytato's compiler from doing some unnecessary/repeated code generation between timesteps (which is an incredibly frustrating issue itself). I recall this being an issue for mirgecom as well for the temperature solver. Perhaps I am the one misunderstanding then

If I don't do the thaw/freeze in between calls to the timestepper, I experienced repeated code-generation that kills the simulation runtime. That's the summary of my issue. And I would expect that this example likely also suffers from that. I haven't checked out this branch to run it (yet) but are you not experiencing this problem with the example as is?

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 see, you're right! Should be fixed in 3e710a8

Copy link
Collaborator

Choose a reason for hiding this comment

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

For the PytatoPyOpenCLArrayContext, if we don't do this the fields starts becoming expression as below:

# at istep = 1
fields = fields(0) + dt/6*(k1(0) + 2*k2(0) + 2*k3(0)+k4(0))
# at istep = 2
fields = fields(0) + dt/6*(k1(0) + 2*k2(0) + 2*k3(0)+k4(0)) + dt/6*(k1(dt) + 2*k2(dt) + 2*k3(dt) + k4(dt))

I.e. the expression keeps growing in size. This is a consequence of us not thunking the values onto the expression objects. I agree this is a sub-optimal user-interface (Very related: inducer/arraycontext#102).

Copy link
Collaborator

@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.

Last question on testing (sorry 😅) Otherwise I'm ready to merge this.

.github/workflows/ci.yml Outdated Show resolved Hide resolved
Copy link
Collaborator

@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.

LGTM. Thanks @matthiasdiener!

@matthiasdiener matthiasdiener merged commit 29e2256 into main Nov 27, 2021
@matthiasdiener matthiasdiener deleted the lazy-example branch November 27, 2021 00:41
Comment on lines +208 to +209
if lazy:
fields = thaw(freeze(fields, actx), actx)
Copy link
Owner

Choose a reason for hiding this comment

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

This is odd, and it shouldn't be here. What happens if you remove it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is directly related to this discussion: #185 (comment). Unresolved so we can continue the discussion there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants