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

Removed tullio dependency #2252

Closed
wants to merge 12 commits into from
Closed

Removed tullio dependency #2252

wants to merge 12 commits into from

Conversation

simone-silvestri
Copy link
Collaborator

No description provided.

@navidcy navidcy added the package 📦 Quite meta label Feb 17, 2022
Copy link
Member

@glwagner glwagner left a comment

Choose a reason for hiding this comment

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

Daaang.

@tomchor
Copy link
Collaborator

tomchor commented Feb 17, 2022

Does this have advantages in terms of speed?

@simone-silvestri
Copy link
Collaborator Author

I don't thinks so. I'll try to benchmark it

@glwagner
Copy link
Member

Does this have advantages in terms of speed?

I think we hope the code is similar under the hood but it's hard to say without knowing more about Tullio.

This update is more general though, because it will work out of the box on distributed systems / multiple GPUs / multi region scenarios like the cubed sphere (because we will support reductions for those cases).

@francispoulin
Copy link
Collaborator

I admit that I had to look up Tullio.jl to learn that it helps with matrix operations. Good for me to know, but if it's going away then maybe no longer essential.

I gather that abs is being replaced with another version. Where does the new version come from?

Also, I remember a while ago having issues with computing norms on GPUs. Does this help with that at all?

@simone-silvestri
Copy link
Collaborator Author

abs is the classical one, I just needed to add it to the list of unary operators that can be applied as an AbstractOperation to a field. I think norm is defined for Fields but not as a "lazy" operation (i.e., it always immediately returns a value)

+ abs(v[i, j, k]) / Δyᶜᶠᶜ(i, j, k, grid)
+ abs(w[i, j, k]) / Δzᶜᶜᶠ(i, j, k, grid))
)
min_timescale = minimum(1 / (abs(u) / Δx + abs(v) / Δy + abs(w) / Δz))
Copy link
Member

@glwagner glwagner Mar 2, 2022

Choose a reason for hiding this comment

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

@simone-silvestri is this right? I think the CFL constraint applies in every direction independently.

+ abs(v[i, j, k]) / Δyᶜᶠᶜ(i, j, k, grid)
+ abs(w[i, j, k]) / Δzᶜᶜᶠ(i, j, k, grid))
)
min_timescale = minimum(1 / (abs(u) / Δx + abs(v) / Δy + abs(w) / Δz))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
min_timescale = minimum(1 / (abs(u) / Δx + abs(v) / Δy + abs(w) / Δz))
min_timescale = 1 / max(maximum(abs(u) / Δx), maximum(abs(v) / Δy), maximum(abs(w) / Δz))

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 think in this way you don't account for diagonal motion?

Copy link
Member

Choose a reason for hiding this comment

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

I guess wikipedia disagrees with me:

https://en.wikipedia.org/wiki/Courant%E2%80%93Friedrichs%E2%80%93Lewy_condition#The_two_and_general_n-dimensional_case

But I'm not sure why. I'll change the tests....

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 think it has to do with diagonal motion...

Copy link
Member

Choose a reason for hiding this comment

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

🤔

Copy link
Member

Choose a reason for hiding this comment

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

This operation is doing interpolation under the hood because of the staggered grid. What's the correct CFL condition for a staggered grid?

@glwagner
Copy link
Member

glwagner commented Mar 3, 2022

@simone-silvestri I refactored the CFL calculation so that we only have one function all the time, rather than one "ordinary" and one "accurate".

The tests still fail though. I'm not totally sure why, but I am somewhat confused how this is supposed to work on a staggered grid. I don't think we can apply wikipedia's definition; we need the definition that's correct for a C grid.

using CUDA, CUDAKernels, KernelAbstractions, Tullio
function cell_advection_timescale(grid, velocities)
u, v, w = velocities
min_timescale = 1 / maximum(abs(u) / Δx + abs(v) / Δy + abs(w) / Δz)
Copy link
Collaborator Author

@simone-silvestri simone-silvestri Mar 3, 2022

Choose a reason for hiding this comment

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

The difference between here and the tullio implementation is that here there is an implicit interpolation while the tullio version does not interpolate (just sums values at different locations)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The correct implementation should be without interpolation on a C grid. I am not entirely sure on why... i can check some references

Copy link
Member

Choose a reason for hiding this comment

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

Hmm ok! Just to clarify the Tullio implementation didn't interpolate (explicitly or implicitly). Instead it assumed it was valid to add objects at different locations, I guess. I think that's what you meant though by "implicit interpolation".

Copy link
Member

Choose a reason for hiding this comment

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

I guess this means that we need abstract operations to be a little less strict 😂

Copy link
Member

Choose a reason for hiding this comment

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

I think we can build it manually and avoid some of the auto-interpolating stuff.

@glwagner
Copy link
Member

Oy, I guess we're still defeated here.

@navidcy
Copy link
Collaborator

navidcy commented Feb 5, 2023

This smells stale… what should we do?

@glwagner
Copy link
Member

glwagner commented Feb 5, 2023

I think the conclusion is that we need to use mapreduce to avoid Tullio, but we can't use AbstractOperations (because the CFL formula involves an operation between fields at different locations, which AbstractOperations are not designed to do)

@navidcy
Copy link
Collaborator

navidcy commented Feb 5, 2023

Okie. We can close then?

@glwagner
Copy link
Member

glwagner commented Feb 5, 2023

If @simone-silvestri is ok to shelve and revisit later then yes

@simone-silvestri
Copy link
Collaborator Author

let's do it

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

Successfully merging this pull request may close these issues.

5 participants