Skip to content

Commit

Permalink
Remove fill_halo_regions! specific kwargs from launch! (#3922)
Browse files Browse the repository at this point in the history
* some changes

* fixed?
  • Loading branch information
simone-silvestri authored Nov 14, 2024
1 parent 9111a8f commit dd82211
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
22 changes: 12 additions & 10 deletions src/BoundaryConditions/fill_halo_regions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ function fill_halo_regions!(c::MaybeTupledData, boundary_conditions, indices, lo
return nothing
end

function fill_halo_event!(c, fill_halos!, bcs, indices, loc, arch, grid, args...; kwargs...)
function fill_halo_event!(c, fill_halos!, bcs, indices, loc, arch, grid, args...;
async = false, # This kwargs is specific to DistributedGrids, here is does nothing
kwargs...)

# Calculate size and offset of the fill_halo kernel
# We assume that the kernel size is the same for west and east boundaries,
Expand Down Expand Up @@ -295,45 +297,45 @@ end
##### Kernel launchers for single-sided fill_halos
#####

fill_west_halo!(c, bc, size, offset, loc, arch, grid, args...; kwargs...) =
fill_west_halo!(c, bc, size, offset, loc, arch, grid, args...; only_local_halos = false, kwargs...) =
launch!(arch, grid, KernelParameters(size, offset),
_fill_only_west_halo!, c, bc, loc, grid, Tuple(args); kwargs...)

fill_east_halo!(c, bc, size, offset, loc, arch, grid, args...; kwargs...) =
fill_east_halo!(c, bc, size, offset, loc, arch, grid, args...; only_local_halos = false, kwargs...) =
launch!(arch, grid, KernelParameters(size, offset),
_fill_only_east_halo!, c, bc, loc, grid, Tuple(args); kwargs...)

fill_south_halo!(c, bc, size, offset, loc, arch, grid, args...; kwargs...) =
fill_south_halo!(c, bc, size, offset, loc, arch, grid, args...; only_local_halos = false, kwargs...) =
launch!(arch, grid, KernelParameters(size, offset),
_fill_only_south_halo!, c, bc, loc, grid, Tuple(args); kwargs...)

fill_north_halo!(c, bc, size, offset, loc, arch, grid, args...; kwargs...) =
fill_north_halo!(c, bc, size, offset, loc, arch, grid, args...; only_local_halos = false, kwargs...) =
launch!(arch, grid, KernelParameters(size, offset),
_fill_only_north_halo!, c, bc, loc, grid, Tuple(args); kwargs...)

fill_bottom_halo!(c, bc, size, offset, loc, arch, grid, args...; kwargs...) =
fill_bottom_halo!(c, bc, size, offset, loc, arch, grid, args...; only_local_halos = false, kwargs...) =
launch!(arch, grid, KernelParameters(size, offset),
_fill_only_bottom_halo!, c, bc, loc, grid, Tuple(args); kwargs...)

fill_top_halo!(c, bc, size, offset, loc, arch, grid, args...; kwargs...) =
fill_top_halo!(c, bc, size, offset, loc, arch, grid, args...; only_local_halos = false, kwargs...) =
launch!(arch, grid, KernelParameters(size, offset),
_fill_only_top_halo!, c, bc, loc, grid, Tuple(args); kwargs...)

#####
##### Kernel launchers for double-sided fill_halos
#####

function fill_west_and_east_halo!(c, west_bc, east_bc, size, offset, loc, arch, grid, args...; kwargs...)
function fill_west_and_east_halo!(c, west_bc, east_bc, size, offset, loc, arch, grid, args...; only_local_halos = false, kwargs...)
return launch!(arch, grid, KernelParameters(size, offset),
_fill_west_and_east_halo!, c, west_bc, east_bc, loc, grid, Tuple(args); kwargs...)
end

function fill_south_and_north_halo!(c, south_bc, north_bc, size, offset, loc, arch, grid, args...; kwargs...)
function fill_south_and_north_halo!(c, south_bc, north_bc, size, offset, loc, arch, grid, args...; only_local_halos = false, kwargs...)
return launch!(arch, grid, KernelParameters(size, offset),
_fill_south_and_north_halo!, c, south_bc, north_bc, loc, grid, Tuple(args); kwargs...)
end

function fill_bottom_and_top_halo!(c, bottom_bc, top_bc, size, offset, loc, arch, grid, args...; kwargs...)
function fill_bottom_and_top_halo!(c, bottom_bc, top_bc, size, offset, loc, arch, grid, args...; only_local_halos = false, kwargs...)
return launch!(arch, grid, KernelParameters(size, offset),
_fill_bottom_and_top_halo!, c, bottom_bc, top_bc, loc, grid, Tuple(args); kwargs...)
end
Expand Down
6 changes: 3 additions & 3 deletions src/BoundaryConditions/fill_halo_regions_periodic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ end

@inline fix_halo_offsets(o, co) = co > 0 ? o - co : o # Windowed fields have only positive offsets to correct

function fill_west_and_east_halo!(c, ::PBCT, ::PBCT, size, offset, loc, arch, grid, args...; kw...)
function fill_west_and_east_halo!(c, ::PBCT, ::PBCT, size, offset, loc, arch, grid, args...; only_local_halos = false, kw...)
c_parent, yz_size, offset = parent_size_and_offset(c, 2, 3, size, offset)
launch!(arch, grid, KernelParameters(yz_size, offset), fill_periodic_west_and_east_halo!, c_parent, Val(grid.Hx), grid.Nx; kw...)
return nothing
end

function fill_south_and_north_halo!(c, ::PBCT, ::PBCT, size, offset, loc, arch, grid, args...; kw...)
function fill_south_and_north_halo!(c, ::PBCT, ::PBCT, size, offset, loc, arch, grid, args...; only_local_halos = false, kw...)
c_parent, xz_size, offset = parent_size_and_offset(c, 1, 3, size, offset)
launch!(arch, grid, KernelParameters(xz_size, offset), fill_periodic_south_and_north_halo!, c_parent, Val(grid.Hy), grid.Ny; kw...)
return nothing
end

function fill_bottom_and_top_halo!(c, ::PBCT, ::PBCT, size, offset, loc, arch, grid, args...; kw...)
function fill_bottom_and_top_halo!(c, ::PBCT, ::PBCT, size, offset, loc, arch, grid, args...; only_local_halos = false, kw...)
c_parent, xy_size, offset = parent_size_and_offset(c, 1, 2, size, offset)
launch!(arch, grid, KernelParameters(xy_size, offset), fill_periodic_bottom_and_top_halo!, c_parent, Val(grid.Hz), grid.Nz; kw...)
return nothing
Expand Down
5 changes: 1 addition & 4 deletions src/Utils/kernel_launching.jl
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,7 @@ end
@inline function _launch!(arch, grid, workspec, kernel!, first_kernel_arg, other_kernel_args...;
exclude_periphery = false,
reduced_dimensions = (),
active_cells_map = nothing,
# TODO: these two kwargs do nothing:
only_local_halos = false,
async = false)
active_cells_map = nothing)

location = Oceananigans.location(first_kernel_arg)

Expand Down

0 comments on commit dd82211

Please sign in to comment.