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

Implement kernel functions to fill cubed sphere halos #3547

Draft
wants to merge 77 commits into
base: main
Choose a base branch
from

Conversation

siddharthabishnu
Copy link
Contributor

This PR implements kernel functions to fill halos of the cubed sphere, enabling cubed sphere simulations to run on a single GPU.

siddharthabishnu and others added 30 commits March 1, 2024 01:23
This commit integrates some key updates from PR #3306, specifically commit
941260f on branch ncc-glw/cubed-sphere-dynamics. We have replaced the following
scripts:
(a) src/Models/HydrostaticFreeSurfaceModels/
    update_hydrostatic_free_surface_model_state.jl;
(b) src/MultiRegion/multi_region_cubed_sphere_grid.jl;
with their modified versions from the PR. The main improvement involves
utilizing the fill_paired_halo_regions! function to fill the halos of grid
metrics on conformal cubed sphere panels at center-center, face-center, and
center-face locations.
@navidcy navidcy added the performance 🏍️ So we can get the wrong answer even faster label Apr 23, 2024
@siddharthabishnu siddharthabishnu force-pushed the sb-ss/cubed-sphere-kernels branch 3 times, most recently from 6d90230 to abc4b9e Compare May 8, 2024 02:16
@siddharthabishnu
Copy link
Contributor Author

siddharthabishnu commented May 8, 2024

Replacing

@apply_regionally begin
    launch!(grid.architecture, grid, kernel_parameters,
            _fill_cubed_sphere_center_center_field_east_west_halo_regions!, field, multiregion_field, region,
            grid.connectivity.connections, Nc, Hc)
end

by

for region in number_of_regions(grid)
    launch!(grid.architecture, grid[region], kernel_parameters,
            _fill_cubed_sphere_center_center_field_east_west_halo_regions!, field[region], field.data.regional_objects, region,
            grid.connectivity.connections[region], Nc, Hc)
end 

in src/MultiRegion/cubed_sphere_boundary_conditions.jl reduces the wall time of filling only the east-west halos of a CenterField on a ConformalCubedSphereGrid with one region of 128x128 cells per panel from

julia> @btime fill_halo_regions!(c)
  711.639 μs (714 allocations: 950.66 KiB)

to

julia> @btime fill_halo_regions!(c)
  13.371 μs (61 allocations: 14.83 KiB)

Upcoming commits will incorporate modifications of this type.

@navidcy
Copy link
Collaborator

navidcy commented May 8, 2024

I'm wondering if the loop:

for region in number_of_regions(grid)
...
end

can be done in parallel.

@simone-silvestri
Copy link
Collaborator

I would not incorporate those modifications but rather try to understand why that happens. The only difference there is the use of getregion instead of indexing with [region]. But getregion is intended to be basically just an indexing for the variables you have there, so it means that there is a problem with getregion, maybe a missing @inline somewhere?

In the end, with apply_regionally what happens under the hood is just this:

    for (r, dev) in enumerate(devs)
        switch_device!(dev)
        regional_func!((getregion(arg, r) for arg in args)...; (getregion(kwarg, r) for kwarg in kwargs)...)
    end

In this case regional_func! is the launch! function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cubed sphere 🧊🌎 GPU 👾 Where Oceananigans gets its powers from performance 🏍️ So we can get the wrong answer even faster
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants