-
Notifications
You must be signed in to change notification settings - Fork 201
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
Improve active cells map kernels #3918
Comments
Can you implement such a feature like you implemented offsets, eg defining an Oceananigans.jl/src/Utils/kernel_launching.jl Line 357 in 9111a8f
|
I'm not even sure we need masking as is, but agree, it would be nice to consider masking as a convenience for output rather than something we need to do while the simulation runs. |
We could try, but the map is an |
Why is that, can you elaborate? |
The offsets is passed as a type parameter in the NDRange argument of the kernel here The problem is that an active map is an AbstractArray so we cannot pass it through type parameters, but it should be stored in the |
Currently, if we build an immersed grid with
active_cells_map = true
, specific kernels compute only on the map provided by the grid. This is very beneficial, but the implementation is a bit clunky, requiring to pass theactive_cells_map
and define two different kernels, for example:Oceananigans.jl/src/Models/NonhydrostaticModels/compute_nonhydrostatic_tendencies.jl
Lines 145 to 155 in 9111a8f
Since the implementation is a bit clunky, we restrict this behavior to the largest performance-critical kernels that are seldom called during time stepping. Otherwise, the code base would explode.
However, launching kernels only on the active cells is a low-hanging fruit for really speeding up the code, and most kernels in Oceananigans could benefit from it. This calls for a more implicit implementation that does not require defining two different kernels. There might be some way to pass a vector of indices to the kernel configuration and launch a one-dimensional kernel that iterates over that map.
That way, we could automatically compute everything on active cells if
active_cells_map = true
without bloating the code base. We could even avoid masking fields that live on a grid with an active map.I think @vchuravy mentioned launching kernels on a map some time ago.
This is probably more of an issue for KernelAbstraction than for Oceananigans, but I just want to see what people think.
The text was updated successfully, but these errors were encountered: