From 279e4c43d7039487be4cd268489c865b2d56a66f Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Tue, 12 Nov 2024 16:39:36 +0100 Subject: [PATCH 01/60] support for MappedFunctions --- kernel_maps.jl | 0 ...ute_hydrostatic_free_surface_tendencies.jl | 29 ++----- src/Utils/kernel_launching.jl | 87 ++++++++++++++++--- 3 files changed, 81 insertions(+), 35 deletions(-) create mode 100644 kernel_maps.jl diff --git a/kernel_maps.jl b/kernel_maps.jl new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl index 82c71b05dd..e61ef7dfa5 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl @@ -96,7 +96,6 @@ function compute_hydrostatic_free_surface_tendency_contributions!(model, kernel_ compute_hydrostatic_free_surface_Gc!, c_tendency, grid, - active_cells_map, args; active_cells_map) end @@ -161,12 +160,12 @@ function compute_hydrostatic_momentum_tendencies!(model, velocities, kernel_para launch!(arch, grid, kernel_parameters, compute_hydrostatic_free_surface_Gu!, model.timestepper.Gⁿ.u, grid, - active_cells_map, u_kernel_args; + u_kernel_args; active_cells_map) launch!(arch, grid, kernel_parameters, compute_hydrostatic_free_surface_Gv!, model.timestepper.Gⁿ.v, grid, - active_cells_map, v_kernel_args; + v_kernel_args; active_cells_map) compute_free_surface_tendency!(grid, model, :xy) @@ -200,45 +199,27 @@ end ##### """ Calculate the right-hand-side of the u-velocity equation. """ -@kernel function compute_hydrostatic_free_surface_Gu!(Gu, grid, ::Nothing, args) +@kernel function compute_hydrostatic_free_surface_Gu!(Gu, grid, args) i, j, k = @index(Global, NTuple) @inbounds Gu[i, j, k] = hydrostatic_free_surface_u_velocity_tendency(i, j, k, grid, args...) end -@kernel function compute_hydrostatic_free_surface_Gu!(Gu, grid, active_cells_map, args) - idx = @index(Global, Linear) - i, j, k = active_linear_index_to_tuple(idx, active_cells_map) - @inbounds Gu[i, j, k] = hydrostatic_free_surface_u_velocity_tendency(i, j, k, grid, args...) -end - """ Calculate the right-hand-side of the v-velocity equation. """ -@kernel function compute_hydrostatic_free_surface_Gv!(Gv, grid, ::Nothing, args) +@kernel function compute_hydrostatic_free_surface_Gv!(Gv, grid, args) i, j, k = @index(Global, NTuple) @inbounds Gv[i, j, k] = hydrostatic_free_surface_v_velocity_tendency(i, j, k, grid, args...) end -@kernel function compute_hydrostatic_free_surface_Gv!(Gv, grid, active_cells_map, args) - idx = @index(Global, Linear) - i, j, k = active_linear_index_to_tuple(idx, active_cells_map) - @inbounds Gv[i, j, k] = hydrostatic_free_surface_v_velocity_tendency(i, j, k, grid, args...) -end - ##### ##### Tendency calculators for tracers ##### """ Calculate the right-hand-side of the tracer advection-diffusion equation. """ -@kernel function compute_hydrostatic_free_surface_Gc!(Gc, grid, ::Nothing, args) +@kernel function compute_hydrostatic_free_surface_Gc!(Gc, grid, args) i, j, k = @index(Global, NTuple) @inbounds Gc[i, j, k] = hydrostatic_free_surface_tracer_tendency(i, j, k, grid, args...) end -@kernel function compute_hydrostatic_free_surface_Gc!(Gc, grid, active_cells_map, args) - idx = @index(Global, Linear) - i, j, k = active_linear_index_to_tuple(idx, active_cells_map) - @inbounds Gc[i, j, k] = hydrostatic_free_surface_tracer_tendency(i, j, k, grid, args...) -end - ##### ##### Tendency calculators for an explicit free surface ##### diff --git a/src/Utils/kernel_launching.jl b/src/Utils/kernel_launching.jl index 3625ae7632..6231e6be23 100644 --- a/src/Utils/kernel_launching.jl +++ b/src/Utils/kernel_launching.jl @@ -7,6 +7,7 @@ using Oceananigans.Architectures using Oceananigans.Grids using Oceananigans.Grids: AbstractGrid using Base: @pure +using KernelAbstractions: Kernel import Oceananigans import KernelAbstractions: get, expand @@ -80,6 +81,18 @@ end contiguousrange(range::NTuple{N, Int}, offset::NTuple{N, Int}) where N = Tuple(1+o:r+o for (r, o) in zip(range, offset)) flatten_reduced_dimensions(worksize, dims) = Tuple(d ∈ dims ? 1 : worksize[d] for d = 1:3) +#### +#### Internal utility to launch a function mapped on an index_map +#### + +struct MappedFunction{M} <: Function + f::Function + index_map::M +end + +@inline (m::MappedFunction)(_ctx_) = m.f(_ctx_) +@inline (m::MappedFunction)(_ctx_, args...) = m.f(_ctx_, args...) + # Support for 1D heuristic_workgroup(Wx) = min(Wx, 256) @@ -238,9 +251,20 @@ the architecture `arch`. dev = Architectures.device(arch) loop = kernel!(dev, workgroup, worksize) + + # Map out the function to use active_cells_map + # as an index map + if !isnothing(active_cells_map) + func = MappedFunction(loop.f, active_cells_map) + param = get_kernel_parameters(loop) + M = typeof(func) + loop = Kernel{param..., M}(dev, func) + end + return loop, worksize end +@inline get_kernel_parameters(k::Kernel{A, B, C}) where {A, B, C} = A, B, C """ launch!(arch, grid, workspec, kernel!, kernel_args...; kw...) @@ -272,10 +296,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) @@ -320,6 +341,13 @@ using KernelAbstractions: Kernel using KernelAbstractions.NDIteration: _Size, StaticSize using KernelAbstractions.NDIteration: NDRange +using KernelAbstractions.NDIteration +using KernelAbstractions: ndrange, workgroupsize +import KernelAbstractions: partition + +using KernelAbstractions: CompilerMetadata +import KernelAbstractions: __ndrange, __groupsize + struct OffsetStaticSize{S} <: _Size function OffsetStaticSize{S}() where S new{S::Tuple{Vararg}}() @@ -369,13 +397,6 @@ const OffsetNDRange{N} = NDRange{N, <:StaticSize, <:StaticSize, <:Any, <:KernelO return CartesianIndex(nI) end -using KernelAbstractions.NDIteration -using KernelAbstractions: ndrange, workgroupsize -import KernelAbstractions: partition - -using KernelAbstractions: CompilerMetadata -import KernelAbstractions: __ndrange, __groupsize - @inline __ndrange(::CompilerMetadata{NDRange}) where {NDRange<:OffsetStaticSize} = CartesianIndices(get(NDRange)) @inline __groupsize(cm::CompilerMetadata{NDRange}) where {NDRange<:OffsetStaticSize} = size(__ndrange(cm)) @@ -413,3 +434,47 @@ function partition(kernel::OffsetKernel, inrange, ingroupsize) return iterspace, dynamic end +##### +##### Utilities for Mapped kernels +##### + +struct IndexMap{M} + index_map :: M +end + +const MappedNDRange{N} = NDRange{N, <:StaticSize, <:StaticSize, <:Any, <:IndexMap} where N + +# NDRange has been modified to have offsets in place of workitems: Remember, dynamic offset kernels are not possible with this extension!! +# TODO: maybe don't do this +@inline function expand(ndrange::MappedNDRange{N}, groupidx::CartesianIndex{N}, idx::CartesianIndex{N}) where {N} + nI = ntuple(Val(N)) do I + Base.@_inline_meta + offsets = workitems(ndrange) + stride = size(offsets, I) + gidx = groupidx.I[I] + @inbounds ndrange.workitems.index_map[(gidx - 1) * stride + idx.I[I]] + end + return CartesianIndex(nI...) +end + +const MappedKernel = Kernel{<:Any, <:Any, <:Any, <:MappedFunction} + +# Extending the partition function to include offsets in NDRange: note that in this case the +# offsets take the place of the DynamicWorkitems which we assume is not needed in static kernels +function partition(kernel::MappedKernel, inrange, ingroupsize) + static_workgroupsize = workgroupsize(kernel) + + # Calculate the static NDRange and WorkgroupSize + index_map = kernel.f.index_map + range = length(index_map) + groupsize = get(static_workgroupsize) + + blocks, groupsize, dynamic = NDIteration.partition(range, groupsize) + + static_blocks = StaticSize{blocks} + static_workgroupsize = StaticSize{groupsize} # we might have padded workgroupsize + + iterspace = NDRange{length(range), static_blocks, static_workgroupsize}(blocks, IndexMap(index_map)) + + return iterspace, dynamic +end From 6182e346a056739533e7ac7727a8cf704a48c6db Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Tue, 12 Nov 2024 16:49:01 +0100 Subject: [PATCH 02/60] remove double kernels everywhere --- .../hydrostatic_free_surface_ab2_step.jl | 1 - .../split_explicit_free_surface_kernels.jl | 21 +--------- ...ore_hydrostatic_free_surface_tendencies.jl | 1 - .../compute_nonhydrostatic_tendencies.jl | 39 ++++--------------- 4 files changed, 10 insertions(+), 52 deletions(-) diff --git a/src/Models/HydrostaticFreeSurfaceModels/hydrostatic_free_surface_ab2_step.jl b/src/Models/HydrostaticFreeSurfaceModels/hydrostatic_free_surface_ab2_step.jl index c76ac3b525..9cbb8e271f 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/hydrostatic_free_surface_ab2_step.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/hydrostatic_free_surface_ab2_step.jl @@ -1,7 +1,6 @@ using Oceananigans.Fields: location using Oceananigans.TimeSteppers: ab2_step_field! using Oceananigans.TurbulenceClosures: implicit_step! -using Oceananigans.ImmersedBoundaries: retrieve_interior_active_cells_map, retrieve_surface_active_cells_map import Oceananigans.TimeSteppers: ab2_step! diff --git a/src/Models/HydrostaticFreeSurfaceModels/split_explicit_free_surface_kernels.jl b/src/Models/HydrostaticFreeSurfaceModels/split_explicit_free_surface_kernels.jl index 0042755123..786f99e129 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/split_explicit_free_surface_kernels.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/split_explicit_free_surface_kernels.jl @@ -133,7 +133,7 @@ end # Barotropic Model Kernels # u_Δz = u * Δz -@kernel function _barotropic_mode_kernel!(U, V, grid, ::Nothing, u, v) +@kernel function _barotropic_mode_kernel!(U, V, grid, u, v) i, j = @index(Global, NTuple) k_top = grid.Nz+1 @@ -146,26 +146,9 @@ end end end -# Barotropic Model Kernels -# u_Δz = u * Δz -@kernel function _barotropic_mode_kernel!(U, V, grid, active_cells_map, u, v) - idx = @index(Global, Linear) - i, j = active_linear_index_to_tuple(idx, active_cells_map) - k_top = grid.Nz+1 - - @inbounds U[i, j, k_top-1] = Δzᶠᶜᶜ(i, j, 1, grid) * u[i, j, 1] - @inbounds V[i, j, k_top-1] = Δzᶜᶠᶜ(i, j, 1, grid) * v[i, j, 1] - - for k in 2:grid.Nz - @inbounds U[i, j, k_top-1] += Δzᶠᶜᶜ(i, j, k, grid) * u[i, j, k] - @inbounds V[i, j, k_top-1] += Δzᶜᶠᶜ(i, j, k, grid) * v[i, j, k] - end -end - @inline function compute_barotropic_mode!(U, V, grid, u, v) active_cells_map = retrieve_surface_active_cells_map(grid) - - launch!(architecture(grid), grid, :xy, _barotropic_mode_kernel!, U, V, grid, active_cells_map, u, v; active_cells_map) + launch!(architecture(grid), grid, :xy, _barotropic_mode_kernel!, U, V, grid, u, v; active_cells_map) return nothing end diff --git a/src/Models/HydrostaticFreeSurfaceModels/store_hydrostatic_free_surface_tendencies.jl b/src/Models/HydrostaticFreeSurfaceModels/store_hydrostatic_free_surface_tendencies.jl index a84d03e13f..089370fdd9 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/store_hydrostatic_free_surface_tendencies.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/store_hydrostatic_free_surface_tendencies.jl @@ -4,7 +4,6 @@ using Oceananigans.TimeSteppers: store_field_tendencies! using Oceananigans: prognostic_fields using Oceananigans.Grids: AbstractGrid -using Oceananigans.ImmersedBoundaries: retrieve_interior_active_cells_map using Oceananigans.Utils: launch! diff --git a/src/Models/NonhydrostaticModels/compute_nonhydrostatic_tendencies.jl b/src/Models/NonhydrostaticModels/compute_nonhydrostatic_tendencies.jl index ffa7865bb2..67bcbbbb98 100644 --- a/src/Models/NonhydrostaticModels/compute_nonhydrostatic_tendencies.jl +++ b/src/Models/NonhydrostaticModels/compute_nonhydrostatic_tendencies.jl @@ -103,15 +103,15 @@ function compute_interior_tendency_contributions!(model, kernel_parameters; acti exclude_periphery = true launch!(arch, grid, kernel_parameters, compute_Gu!, - tendencies.u, grid, active_cells_map, u_kernel_args; + tendencies.u, grid, u_kernel_args; active_cells_map, exclude_periphery) launch!(arch, grid, kernel_parameters, compute_Gv!, - tendencies.v, grid, active_cells_map, v_kernel_args; + tendencies.v, grid, v_kernel_args; active_cells_map, exclude_periphery) launch!(arch, grid, kernel_parameters, compute_Gw!, - tendencies.w, grid, active_cells_map, w_kernel_args; + tendencies.w, grid, w_kernel_args; active_cells_map, exclude_periphery) start_tracer_kernel_args = (advection, closure) @@ -131,7 +131,7 @@ function compute_interior_tendency_contributions!(model, kernel_parameters; acti forcing, clock) launch!(arch, grid, kernel_parameters, compute_Gc!, - c_tendency, grid, active_cells_map, args; + c_tendency, grid, args; active_cells_map) end @@ -143,57 +143,34 @@ end ##### """ Calculate the right-hand-side of the u-velocity equation. """ -@kernel function compute_Gu!(Gu, grid, ::Nothing, args) +@kernel function compute_Gu!(Gu, grid, args) i, j, k = @index(Global, NTuple) @inbounds Gu[i, j, k] = u_velocity_tendency(i, j, k, grid, args...) end -@kernel function compute_Gu!(Gu, grid, interior_map, args) - idx = @index(Global, Linear) - i, j, k = active_linear_index_to_tuple(idx, interior_map) - @inbounds Gu[i, j, k] = u_velocity_tendency(i, j, k, grid, args...) -end - """ Calculate the right-hand-side of the v-velocity equation. """ -@kernel function compute_Gv!(Gv, grid, ::Nothing, args) +@kernel function compute_Gv!(Gv, grid, args) i, j, k = @index(Global, NTuple) @inbounds Gv[i, j, k] = v_velocity_tendency(i, j, k, grid, args...) end -@kernel function compute_Gv!(Gv, grid, interior_map, args) - idx = @index(Global, Linear) - i, j, k = active_linear_index_to_tuple(idx, interior_map) - @inbounds Gv[i, j, k] = v_velocity_tendency(i, j, k, grid, args...) -end - """ Calculate the right-hand-side of the w-velocity equation. """ -@kernel function compute_Gw!(Gw, grid, ::Nothing, args) +@kernel function compute_Gw!(Gw, grid, args) i, j, k = @index(Global, NTuple) @inbounds Gw[i, j, k] = w_velocity_tendency(i, j, k, grid, args...) end -@kernel function compute_Gw!(Gw, grid, interior_map, args) - idx = @index(Global, Linear) - i, j, k = active_linear_index_to_tuple(idx, interior_map) - @inbounds Gw[i, j, k] = w_velocity_tendency(i, j, k, grid, args...) -end ##### ##### Tracer(s) ##### """ Calculate the right-hand-side of the tracer advection-diffusion equation. """ -@kernel function compute_Gc!(Gc, grid, ::Nothing, args) +@kernel function compute_Gc!(Gc, grid, args) i, j, k = @index(Global, NTuple) @inbounds Gc[i, j, k] = tracer_tendency(i, j, k, grid, args...) end -@kernel function compute_Gc!(Gc, grid, interior_map, args) - idx = @index(Global, Linear) - i, j, k = active_linear_index_to_tuple(idx, interior_map) - @inbounds Gc[i, j, k] = tracer_tendency(i, j, k, grid, args...) -end - ##### ##### Boundary contributions to tendencies due to user-prescribed fluxes ##### From 5545605ae1631221fb88d7530e06bde8df6bc2f2 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Tue, 12 Nov 2024 16:55:18 +0100 Subject: [PATCH 03/60] make sure also GPU works --- src/Utils/kernel_launching.jl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Utils/kernel_launching.jl b/src/Utils/kernel_launching.jl index 6231e6be23..c81a31369f 100644 --- a/src/Utils/kernel_launching.jl +++ b/src/Utils/kernel_launching.jl @@ -6,6 +6,7 @@ using Oceananigans: location using Oceananigans.Architectures using Oceananigans.Grids using Oceananigans.Grids: AbstractGrid +using Adapt using Base: @pure using KernelAbstractions: Kernel @@ -90,6 +91,9 @@ struct MappedFunction{M} <: Function index_map::M end +Adapt.adapt_structure(to, m::MappedFunction) = + MappedFunction(Adapt.adapt(to, m.f), Adapt.adapt(to, m.index_map)) + @inline (m::MappedFunction)(_ctx_) = m.f(_ctx_) @inline (m::MappedFunction)(_ctx_, args...) = m.f(_ctx_, args...) From e239dbed09bdf899e7bda469cafab9d3e0822154 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Tue, 12 Nov 2024 16:59:30 +0100 Subject: [PATCH 04/60] make sure there is no return in the function --- src/Utils/kernel_launching.jl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Utils/kernel_launching.jl b/src/Utils/kernel_launching.jl index c81a31369f..7b1409b392 100644 --- a/src/Utils/kernel_launching.jl +++ b/src/Utils/kernel_launching.jl @@ -94,8 +94,13 @@ end Adapt.adapt_structure(to, m::MappedFunction) = MappedFunction(Adapt.adapt(to, m.f), Adapt.adapt(to, m.index_map)) -@inline (m::MappedFunction)(_ctx_) = m.f(_ctx_) -@inline (m::MappedFunction)(_ctx_, args...) = m.f(_ctx_, args...) +@inline function (m::MappedFunction)(_ctx_) + m.f(_ctx_) +end + +@inline function (m::MappedFunction)(_ctx_, args...) + m.f(_ctx_, args...) +end # Support for 1D heuristic_workgroup(Wx) = min(Wx, 256) From 32e0c524eb617a75da7ff1841db4a3c0cdfa1f17 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Tue, 12 Nov 2024 17:00:15 +0100 Subject: [PATCH 05/60] return nothing --- src/Utils/kernel_launching.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Utils/kernel_launching.jl b/src/Utils/kernel_launching.jl index 7b1409b392..9084639507 100644 --- a/src/Utils/kernel_launching.jl +++ b/src/Utils/kernel_launching.jl @@ -96,10 +96,12 @@ Adapt.adapt_structure(to, m::MappedFunction) = @inline function (m::MappedFunction)(_ctx_) m.f(_ctx_) + return nothing end @inline function (m::MappedFunction)(_ctx_, args...) m.f(_ctx_, args...) + return nothing end # Support for 1D From 0b56304b347c5961b920aaa50b50600b4bfd69ba Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Tue, 12 Nov 2024 17:26:44 +0100 Subject: [PATCH 06/60] adapt for GPU usage --- src/BoundaryConditions/fill_halo_regions.jl | 6 ++++- src/Utils/kernel_launching.jl | 28 ++++++++++++--------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/BoundaryConditions/fill_halo_regions.jl b/src/BoundaryConditions/fill_halo_regions.jl index fa380e7029..50ed69ef46 100644 --- a/src/BoundaryConditions/fill_halo_regions.jl +++ b/src/BoundaryConditions/fill_halo_regions.jl @@ -46,7 +46,11 @@ const MaybeTupledData = Union{OffsetArray, NTuple{<:Any, OffsetArray}} "Fill halo regions in ``x``, ``y``, and ``z`` for a given field's data." function fill_halo_regions!(c::MaybeTupledData, boundary_conditions, indices, loc, grid, args...; - fill_boundary_normal_velocities = true, kwargs...) + fill_boundary_normal_velocities = true, + only_local_halos = false, # Only valid for `DistributedGrids`, we throw it away here + async = false, # Only valid for `DistributedGrids`, we throw it away here + kwargs...) + arch = architecture(grid) if fill_boundary_normal_velocities diff --git a/src/Utils/kernel_launching.jl b/src/Utils/kernel_launching.jl index 9084639507..9ca6fb5371 100644 --- a/src/Utils/kernel_launching.jl +++ b/src/Utils/kernel_launching.jl @@ -86,8 +86,8 @@ flatten_reduced_dimensions(worksize, dims) = Tuple(d ∈ dims ? 1 : worksize[d] #### Internal utility to launch a function mapped on an index_map #### -struct MappedFunction{M} <: Function - f::Function +struct MappedFunction{F, M} <: Function + f::F index_map::M end @@ -453,19 +453,21 @@ struct IndexMap{M} index_map :: M end +Adapt.adapt_structure(to, m::IndexMap) = IndexMap(Adapt.adapt(to, m.index_map)) + const MappedNDRange{N} = NDRange{N, <:StaticSize, <:StaticSize, <:Any, <:IndexMap} where N -# NDRange has been modified to have offsets in place of workitems: Remember, dynamic offset kernels are not possible with this extension!! +# NDRange has been modified to include an index_map in place of workitems: R +# Remember, dynamic offset kernels are not possible with this extension!! +# Also, mapped kernels work only with a 1D kernel and a 1D map, it is not possible to launch a ND kernel. # TODO: maybe don't do this -@inline function expand(ndrange::MappedNDRange{N}, groupidx::CartesianIndex{N}, idx::CartesianIndex{N}) where {N} - nI = ntuple(Val(N)) do I - Base.@_inline_meta - offsets = workitems(ndrange) - stride = size(offsets, I) - gidx = groupidx.I[I] - @inbounds ndrange.workitems.index_map[(gidx - 1) * stride + idx.I[I]] - end - return CartesianIndex(nI...) +@inline function expand(ndrange::MappedNDRange, groupidx::CartesianIndex{N}, idx::CartesianIndex{N}) + Base.@_inline_meta + offsets = workitems(ndrange) + stride = size(offsets, I) + gidx = groupidx.I[I] + @inbounds ndrange.workitems.index_map[(gidx - 1) * stride + idx.I[I]] + return CartesianIndex(nI) end const MappedKernel = Kernel{<:Any, <:Any, <:Any, <:MappedFunction} @@ -478,6 +480,7 @@ function partition(kernel::MappedKernel, inrange, ingroupsize) # Calculate the static NDRange and WorkgroupSize index_map = kernel.f.index_map range = length(index_map) + arch = Oceananigans.Architectures.architecture(index_map) groupsize = get(static_workgroupsize) blocks, groupsize, dynamic = NDIteration.partition(range, groupsize) @@ -485,6 +488,7 @@ function partition(kernel::MappedKernel, inrange, ingroupsize) static_blocks = StaticSize{blocks} static_workgroupsize = StaticSize{groupsize} # we might have padded workgroupsize + index_map = Oceananigans.Architectures.convert_args(arch, index_map) iterspace = NDRange{length(range), static_blocks, static_workgroupsize}(blocks, IndexMap(index_map)) return iterspace, dynamic From 052f56e5c272de60c9cbac2e94833541c88df320 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Tue, 12 Nov 2024 17:43:28 +0100 Subject: [PATCH 07/60] not sure about the GPU --- src/Utils/kernel_launching.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Utils/kernel_launching.jl b/src/Utils/kernel_launching.jl index 9ca6fb5371..41e4770dee 100644 --- a/src/Utils/kernel_launching.jl +++ b/src/Utils/kernel_launching.jl @@ -461,12 +461,12 @@ const MappedNDRange{N} = NDRange{N, <:StaticSize, <:StaticSize, <:Any, <:IndexMa # Remember, dynamic offset kernels are not possible with this extension!! # Also, mapped kernels work only with a 1D kernel and a 1D map, it is not possible to launch a ND kernel. # TODO: maybe don't do this -@inline function expand(ndrange::MappedNDRange, groupidx::CartesianIndex{N}, idx::CartesianIndex{N}) +@inline function expand(ndrange::MappedNDRange, groupidx::CartesianIndex, idx::CartesianIndex) Base.@_inline_meta offsets = workitems(ndrange) - stride = size(offsets, I) - gidx = groupidx.I[I] - @inbounds ndrange.workitems.index_map[(gidx - 1) * stride + idx.I[I]] + stride = size(offsets, 1) + gidx = groupidx.I[1] + @inbounds ndrange.workitems.index_map[(gidx - 1) * stride + idx.I[1]] return CartesianIndex(nI) end From d0d56ac02dc785a81b01d2dd0bcf605f625f78f7 Mon Sep 17 00:00:00 2001 From: simone-silvestri Date: Tue, 12 Nov 2024 12:47:31 -0500 Subject: [PATCH 08/60] hmmm --- src/Utils/kernel_launching.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Utils/kernel_launching.jl b/src/Utils/kernel_launching.jl index 41e4770dee..667f6ab1ea 100644 --- a/src/Utils/kernel_launching.jl +++ b/src/Utils/kernel_launching.jl @@ -466,7 +466,7 @@ const MappedNDRange{N} = NDRange{N, <:StaticSize, <:StaticSize, <:Any, <:IndexMa offsets = workitems(ndrange) stride = size(offsets, 1) gidx = groupidx.I[1] - @inbounds ndrange.workitems.index_map[(gidx - 1) * stride + idx.I[1]] + nI = @inbounds ndrange.workitems.index_map[(gidx - 1) * stride + idx.I[1]] return CartesianIndex(nI) end From 7e41737b458c00e8767f31caba685d683a4c6fe0 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Tue, 12 Nov 2024 19:56:08 +0100 Subject: [PATCH 09/60] probably like this it will work on the GPU? --- src/Utils/kernel_launching.jl | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Utils/kernel_launching.jl b/src/Utils/kernel_launching.jl index 41e4770dee..65025f0b37 100644 --- a/src/Utils/kernel_launching.jl +++ b/src/Utils/kernel_launching.jl @@ -88,11 +88,11 @@ flatten_reduced_dimensions(worksize, dims) = Tuple(d ∈ dims ? 1 : worksize[d] struct MappedFunction{F, M} <: Function f::F - index_map::M + imap::M end Adapt.adapt_structure(to, m::MappedFunction) = - MappedFunction(Adapt.adapt(to, m.f), Adapt.adapt(to, m.index_map)) + MappedFunction(Adapt.adapt(to, m.f), Adapt.adapt(to, m.imap)) @inline function (m::MappedFunction)(_ctx_) m.f(_ctx_) @@ -466,11 +466,18 @@ const MappedNDRange{N} = NDRange{N, <:StaticSize, <:StaticSize, <:Any, <:IndexMa offsets = workitems(ndrange) stride = size(offsets, 1) gidx = groupidx.I[1] - @inbounds ndrange.workitems.index_map[(gidx - 1) * stride + idx.I[1]] + tI = (gidx - 1) * stride + idx.I[1] + nI = ndrange.workitems.index_map[tI] return CartesianIndex(nI) end -const MappedKernel = Kernel{<:Any, <:Any, <:Any, <:MappedFunction} +const MappedKernel{D} = Kernel{D, <:Any, <:Any, <:MappedFunction} where D + +# Override the getproperty to make sure we get the correct properties +@inline getproperty(k::MappedKernel, prop::Symbol) = get_mapped_property(k, Val(prop)) + +@inline get_mapped_property(k, ::Val{:imap}) = k.f.imap +@inline get_mapped_property(k, ::Val{:f}) = k.f.f # Extending the partition function to include offsets in NDRange: note that in this case the # offsets take the place of the DynamicWorkitems which we assume is not needed in static kernels @@ -478,7 +485,7 @@ function partition(kernel::MappedKernel, inrange, ingroupsize) static_workgroupsize = workgroupsize(kernel) # Calculate the static NDRange and WorkgroupSize - index_map = kernel.f.index_map + index_map = getproperty(kernel, :imap) range = length(index_map) arch = Oceananigans.Architectures.architecture(index_map) groupsize = get(static_workgroupsize) @@ -492,4 +499,4 @@ function partition(kernel::MappedKernel, inrange, ingroupsize) iterspace = NDRange{length(range), static_blocks, static_workgroupsize}(blocks, IndexMap(index_map)) return iterspace, dynamic -end +end \ No newline at end of file From 130a3571732bbe3d28de5dc388591ec71352efe8 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Tue, 12 Nov 2024 21:35:57 +0100 Subject: [PATCH 10/60] some cleanup plus testing a test? --- src/Utils/kernel_launching.jl | 39 ++++++++++++++--------------------- test.jl | 18 ++++++++++++++++ 2 files changed, 33 insertions(+), 24 deletions(-) create mode 100644 test.jl diff --git a/src/Utils/kernel_launching.jl b/src/Utils/kernel_launching.jl index b158fe09a4..436cde1037 100644 --- a/src/Utils/kernel_launching.jl +++ b/src/Utils/kernel_launching.jl @@ -87,20 +87,15 @@ flatten_reduced_dimensions(worksize, dims) = Tuple(d ∈ dims ? 1 : worksize[d] #### struct MappedFunction{F, M} <: Function - f::F - imap::M + func::F + index_map::M end Adapt.adapt_structure(to, m::MappedFunction) = - MappedFunction(Adapt.adapt(to, m.f), Adapt.adapt(to, m.imap)) - -@inline function (m::MappedFunction)(_ctx_) - m.f(_ctx_) - return nothing -end + MappedFunction(Adapt.adapt(to, m.func), Adapt.adapt(to, m.index_map)) @inline function (m::MappedFunction)(_ctx_, args...) - m.f(_ctx_, args...) + m.func(_ctx_, args...) return nothing end @@ -251,6 +246,7 @@ the architecture `arch`. location = nothing, active_cells_map = nothing) + if !isnothing(active_cells_map) # everything else is irrelevant workgroup = min(length(active_cells_map), 256) worksize = length(active_cells_map) @@ -263,19 +259,16 @@ the architecture `arch`. dev = Architectures.device(arch) loop = kernel!(dev, workgroup, worksize) - # Map out the function to use active_cells_map - # as an index map + # Map out the function to use active_cells_map as an index map if !isnothing(active_cells_map) - func = MappedFunction(loop.f, active_cells_map) - param = get_kernel_parameters(loop) - M = typeof(func) - loop = Kernel{param..., M}(dev, func) + func = MappedFunction(loop.f, active_cells_map) + loop = Kernel{get_kernel_parameters(loop)..., typeof(func)}(dev, func) end return loop, worksize end -@inline get_kernel_parameters(k::Kernel{A, B, C}) where {A, B, C} = A, B, C +@inline get_kernel_parameters(::Kernel{Dev, B, W}) where {Dev, B, W} = Dev, B, W """ launch!(arch, grid, workspec, kernel!, kernel_args...; kw...) @@ -347,8 +340,6 @@ end ##### # TODO: when offsets are implemented in KA so that we can call `kernel(dev, group, size, offsets)`, remove all of this - -using KernelAbstractions: Kernel using KernelAbstractions.NDIteration: _Size, StaticSize using KernelAbstractions.NDIteration: NDRange @@ -450,14 +441,14 @@ end ##### struct IndexMap{M} - imap :: M + index_map :: M end Adapt.adapt_structure(to, m::IndexMap) = IndexMap(Adapt.adapt(to, m.index_map)) const MappedNDRange{N} = NDRange{N, <:StaticSize, <:StaticSize, <:Any, <:IndexMap} where N -# NDRange has been modified to include an index_map in place of workitems: R +# NDRange has been modified to include an index_map in place of workitems. # Remember, dynamic offset kernels are not possible with this extension!! # Also, mapped kernels work only with a 1D kernel and a 1D map, it is not possible to launch a ND kernel. # TODO: maybe don't do this @@ -467,7 +458,7 @@ const MappedNDRange{N} = NDRange{N, <:StaticSize, <:StaticSize, <:Any, <:IndexMa stride = size(offsets, 1) gidx = groupidx.I[1] tI = (gidx - 1) * stride + idx.I[1] - nI = ndrange.workitems.imap[tI] + nI = ndrange.workitems.index_map[tI] return CartesianIndex(nI) end @@ -476,8 +467,8 @@ const MappedKernel{D} = Kernel{D, <:Any, <:Any, <:MappedFunction} where D # Override the getproperty to make sure we get the correct properties @inline getproperty(k::MappedKernel, prop::Symbol) = get_mapped_property(k, Val(prop)) -@inline get_mapped_property(k, ::Val{:imap}) = k.f.imap -@inline get_mapped_property(k, ::Val{:f}) = k.f.f +@inline get_mapped_property(k, ::Val{:index_map}) = k.f.index_map +@inline get_mapped_property(k, ::Val{:func}) = k.f.func # Extending the partition function to include offsets in NDRange: note that in this case the # offsets take the place of the DynamicWorkitems which we assume is not needed in static kernels @@ -485,7 +476,7 @@ function partition(kernel::MappedKernel, inrange, ingroupsize) static_workgroupsize = workgroupsize(kernel) # Calculate the static NDRange and WorkgroupSize - index_map = getproperty(kernel, :imap) + index_map = getproperty(kernel, :index_map) range = length(index_map) arch = Oceananigans.Architectures.architecture(index_map) groupsize = get(static_workgroupsize) diff --git a/test.jl b/test.jl new file mode 100644 index 0000000000..70239fa292 --- /dev/null +++ b/test.jl @@ -0,0 +1,18 @@ +using Revise +using Oceananigans +using Oceananigans.Utils + +using KernelAbstractions: @index, @kernel + +arch = CPU() + +@kernel function _test_indices(a) + i, j, k = @index(Global, NTuple) + a[i, j, k] = i + j + k +end + +grid = RectilinearGrid(arch, size = (3, 3, 3), extent = (1, 1, 1)) +array = zeros(arch, 3, 3, 3) +imap = on_architecture(arch, [(i, j, k) for i in 1:3, j in 1:3, k in 1:2]) + +launch!(arch, grid_cpu, :xyz, _test_indices, array; active_cells_map = imap) \ No newline at end of file From 3be13dd0860740de74fa91b5df2532a623df1ed9 Mon Sep 17 00:00:00 2001 From: simone-silvestri Date: Tue, 12 Nov 2024 18:40:50 -0500 Subject: [PATCH 11/60] works on gpu, to fix the dynamic check --- src/Utils/kernel_launching.jl | 91 +++++++++++++++++++++-------------- 1 file changed, 56 insertions(+), 35 deletions(-) diff --git a/src/Utils/kernel_launching.jl b/src/Utils/kernel_launching.jl index 436cde1037..02473f0d5b 100644 --- a/src/Utils/kernel_launching.jl +++ b/src/Utils/kernel_launching.jl @@ -12,6 +12,7 @@ using KernelAbstractions: Kernel import Oceananigans import KernelAbstractions: get, expand +import Base struct KernelParameters{S, O} end @@ -82,23 +83,12 @@ end contiguousrange(range::NTuple{N, Int}, offset::NTuple{N, Int}) where N = Tuple(1+o:r+o for (r, o) in zip(range, offset)) flatten_reduced_dimensions(worksize, dims) = Tuple(d ∈ dims ? 1 : worksize[d] for d = 1:3) -#### -#### Internal utility to launch a function mapped on an index_map -#### - +# Internal utility to launch a function mapped on an index_map struct MappedFunction{F, M} <: Function func::F index_map::M end -Adapt.adapt_structure(to, m::MappedFunction) = - MappedFunction(Adapt.adapt(to, m.func), Adapt.adapt(to, m.index_map)) - -@inline function (m::MappedFunction)(_ctx_, args...) - m.func(_ctx_, args...) - return nothing -end - # Support for 1D heuristic_workgroup(Wx) = min(Wx, 256) @@ -440,35 +430,41 @@ end ##### Utilities for Mapped kernels ##### -struct IndexMap{M} - index_map :: M -end - -Adapt.adapt_structure(to, m::IndexMap) = IndexMap(Adapt.adapt(to, m.index_map)) +struct IndexMap end -const MappedNDRange{N} = NDRange{N, <:StaticSize, <:StaticSize, <:Any, <:IndexMap} where N +const MappedNDRange{N} = NDRange{N, <:StaticSize, <:StaticSize, <:IndexMap, <:AbstractArray} where N # NDRange has been modified to include an index_map in place of workitems. # Remember, dynamic offset kernels are not possible with this extension!! # Also, mapped kernels work only with a 1D kernel and a 1D map, it is not possible to launch a ND kernel. # TODO: maybe don't do this -@inline function expand(ndrange::MappedNDRange, groupidx::CartesianIndex, idx::CartesianIndex) - Base.@_inline_meta - offsets = workitems(ndrange) - stride = size(offsets, 1) - gidx = groupidx.I[1] - tI = (gidx - 1) * stride + idx.I[1] - nI = ndrange.workitems.index_map[tI] - return CartesianIndex(nI) +@inline function expand(ndrange::MappedNDRange, groupidx::CartesianIndex{N}, idx::CartesianIndex{N}) where N + nI = ntuple(Val(N)) do I + Base.@_inline_meta + offsets = workitems(ndrange) + stride = size(offsets, I) + gidx = groupidx.I[I] + ndrange.workitems[(gidx - 1) * stride + idx.I[I]] + end + return CartesianIndex(nI...) end const MappedKernel{D} = Kernel{D, <:Any, <:Any, <:MappedFunction} where D -# Override the getproperty to make sure we get the correct properties -@inline getproperty(k::MappedKernel, prop::Symbol) = get_mapped_property(k, Val(prop)) +# Override the getproperty to make sure we launch the correct function in the kernel +@inline Base.getproperty(k::MappedKernel, prop::Symbol) = get_mapped_kernel_property(k, Val(prop)) + +@inline get_mapped_kernel_property(k, ::Val{prop}) where prop = getfield(k, prop) +@inline get_mapped_kernel_property(k, ::Val{:index_map}) = getfield(getfield(k, :f), :index_map) +@inline get_mapped_kernel_property(k, ::Val{:f}) = getfield(getfield(k, :f), :func) -@inline get_mapped_property(k, ::Val{:index_map}) = k.f.index_map -@inline get_mapped_property(k, ::Val{:func}) = k.f.func +Adapt.adapt_structure(to, cm::CompilerMetadata{N, C}) where {N, C} = + CompilerMetadata{N, C}(Adapt.adapt(to, cm.groupindex), + Adapt.adapt(to, cm.ndrange), + Adapt.adapt(to, cm.iterspace)) + +Adapt.adapt_structure(to, ndrange::NDRange{N, B, W}) where {N, B, W} = + NDRange{N, B, W}(Adapt.adapt(to, ndrange.blocks), Adapt.adapt(to, ndrange.workitems)) # Extending the partition function to include offsets in NDRange: note that in this case the # offsets take the place of the DynamicWorkitems which we assume is not needed in static kernels @@ -476,9 +472,8 @@ function partition(kernel::MappedKernel, inrange, ingroupsize) static_workgroupsize = workgroupsize(kernel) # Calculate the static NDRange and WorkgroupSize - index_map = getproperty(kernel, :index_map) + index_map = kernel.index_map range = length(index_map) - arch = Oceananigans.Architectures.architecture(index_map) groupsize = get(static_workgroupsize) blocks, groupsize, dynamic = NDIteration.partition(range, groupsize) @@ -486,8 +481,34 @@ function partition(kernel::MappedKernel, inrange, ingroupsize) static_blocks = StaticSize{blocks} static_workgroupsize = StaticSize{groupsize} # we might have padded workgroupsize - index_map = Oceananigans.Architectures.convert_args(arch, index_map) - iterspace = NDRange{length(range), static_blocks, static_workgroupsize}(blocks, IndexMap(index_map)) + iterspace = NDRange{length(range), static_blocks, static_workgroupsize}(IndexMap(), index_map) return iterspace, dynamic -end \ No newline at end of file +end + +using KernelAbstractions: CompilerMetadata, NoDynamicCheck +using CUDA: CUDABackend + +import KernelAbstractions: mkcontext, __dynamic_checkbounds, __validindex + +# Very dangerous override of mkcontext which will not work if we are not +# carefull with making sure that indices are correct when launching a `MappedKernel` +# TODO: Definitely change this with options below +function mkcontext(kernel::Kernel{CUDABackend}, _ndrange, iterspace::MappedNDRange) + return CompilerMetadata{ndrange(kernel), NoDynamicCheck}(_ndrange, iterspace) +end + +# Alternative to the above to fix: +# const MappedCompilerMetadata = CompilerMetadata{<:Any, <:Any, <:Any, <:Any, <:MappedNDRange} + +# @inline __ndrange(cm::MappedCompilerMetadata) = cm.iterspace + +# @inline function __validindex(ctx::MappedCompilerMetadata, idx::CartesianIndex) +# # Turns this into a noop for code where we can turn of checkbounds of +# if __dynamic_checkbounds(ctx) +# I = @inbounds expand(__iterspace(ctx), __groupindex(ctx), idx) +# return I in __ndrange(ctx) +# else +# return true +# end +# end \ No newline at end of file From 64cad183deccf3fd500422ec7868c5551904eb24 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Wed, 13 Nov 2024 08:36:26 +0100 Subject: [PATCH 12/60] move lwargs --- src/BoundaryConditions/fill_halo_regions.jl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/BoundaryConditions/fill_halo_regions.jl b/src/BoundaryConditions/fill_halo_regions.jl index 50ed69ef46..c36c9c3fbf 100644 --- a/src/BoundaryConditions/fill_halo_regions.jl +++ b/src/BoundaryConditions/fill_halo_regions.jl @@ -47,8 +47,6 @@ const MaybeTupledData = Union{OffsetArray, NTuple{<:Any, OffsetArray}} "Fill halo regions in ``x``, ``y``, and ``z`` for a given field's data." function fill_halo_regions!(c::MaybeTupledData, boundary_conditions, indices, loc, grid, args...; fill_boundary_normal_velocities = true, - only_local_halos = false, # Only valid for `DistributedGrids`, we throw it away here - async = false, # Only valid for `DistributedGrids`, we throw it away here kwargs...) arch = architecture(grid) @@ -68,7 +66,10 @@ 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...; + only_local_halos = false, # Only valid for `DistributedGrids`, we throw it away here + async = false, # Only valid for `DistributedGrids`, we throw it away here + kwargs...) # Calculate size and offset of the fill_halo kernel # We assume that the kernel size is the same for west and east boundaries, From 333bfd707056483e19f99c4fca1ea28a8a78f9e2 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Wed, 13 Nov 2024 09:12:08 +0100 Subject: [PATCH 13/60] kwarg management --- src/BoundaryConditions/fill_halo_regions.jl | 28 +++++++++++++-------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/BoundaryConditions/fill_halo_regions.jl b/src/BoundaryConditions/fill_halo_regions.jl index c36c9c3fbf..686f91fd6f 100644 --- a/src/BoundaryConditions/fill_halo_regions.jl +++ b/src/BoundaryConditions/fill_halo_regions.jl @@ -67,7 +67,6 @@ function fill_halo_regions!(c::MaybeTupledData, boundary_conditions, indices, lo end function fill_halo_event!(c, fill_halos!, bcs, indices, loc, arch, grid, args...; - only_local_halos = false, # Only valid for `DistributedGrids`, we throw it away here async = false, # Only valid for `DistributedGrids`, we throw it away here kwargs...) @@ -300,27 +299,27 @@ 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...) @@ -328,17 +327,26 @@ fill_top_halo!(c, bc, size, offset, loc, arch, grid, 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, # Only valid for `DistributedGrids`, we throw it away here + 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, # Only valid for `DistributedGrids`, we throw it away here + 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, # Only valid for `DistributedGrids`, we throw it away here + kwargs...) + return launch!(arch, grid, KernelParameters(size, offset), _fill_bottom_and_top_halo!, c, bottom_bc, top_bc, loc, grid, Tuple(args); kwargs...) end From e069051e1926705e620abd8ab93b2b2bcd068a44 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Wed, 13 Nov 2024 09:33:39 +0100 Subject: [PATCH 14/60] reduce time for tridiagonal solve --- src/Solvers/batched_tridiagonal_solver.jl | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/Solvers/batched_tridiagonal_solver.jl b/src/Solvers/batched_tridiagonal_solver.jl index 2886847938..4e9aca12f3 100644 --- a/src/Solvers/batched_tridiagonal_solver.jl +++ b/src/Solvers/batched_tridiagonal_solver.jl @@ -99,13 +99,16 @@ Press William, H., Teukolsky Saul, A., Vetterling William, T., & Flannery Brian, """ function solve!(ϕ, solver::BatchedTridiagonalSolver, rhs, args...) - launch_config = if solver.tridiagonal_direction isa XDirection - :yz - elseif solver.tridiagonal_direction isa YDirection - :xz - elseif solver.tridiagonal_direction isa ZDirection - :xy - end + if solver.tridiagonal_direction isa XDirection + launch_config = :yz + active_cells_map = nothing + elseif solver.tridiagonal_direction isa YDirection + launch_config = :xz + active_cells_map = nothing + elseif solver.tridiagonal_direction isa ZDirection + launch_config = :xy + active_cells_map = retrieve_surface_active_cells_map(grid) + end launch!(architecture(solver), solver.grid, launch_config, solve_batched_tridiagonal_system_kernel!, ϕ, @@ -117,7 +120,8 @@ function solve!(ϕ, solver::BatchedTridiagonalSolver, rhs, args...) solver.grid, solver.parameters, Tuple(args), - solver.tridiagonal_direction) + solver.tridiagonal_direction; + active_cells_map) return nothing end From f0a887a4094b31f4121d6269198988f8dc48d3fc Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Wed, 13 Nov 2024 13:06:24 +0100 Subject: [PATCH 15/60] see if tests pass (especially distributed where we have active_cells) --- src/BoundaryConditions/fill_halo_regions_periodic.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/BoundaryConditions/fill_halo_regions_periodic.jl b/src/BoundaryConditions/fill_halo_regions_periodic.jl index 890b9c2fba..edd97528fa 100644 --- a/src/BoundaryConditions/fill_halo_regions_periodic.jl +++ b/src/BoundaryConditions/fill_halo_regions_periodic.jl @@ -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 From 7b33e7a417b9ecaa54497221f35c651c549eabcf Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Wed, 13 Nov 2024 13:52:05 +0100 Subject: [PATCH 16/60] bugfix --- src/Solvers/batched_tridiagonal_solver.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Solvers/batched_tridiagonal_solver.jl b/src/Solvers/batched_tridiagonal_solver.jl index 4e9aca12f3..83cb5b2236 100644 --- a/src/Solvers/batched_tridiagonal_solver.jl +++ b/src/Solvers/batched_tridiagonal_solver.jl @@ -1,5 +1,6 @@ using Oceananigans.Architectures: on_architecture using Oceananigans.Grids: XDirection, YDirection, ZDirection +using Oceananigans.ImmersedBoundaries: retrieve_surface_active_cells_map import Oceananigans.Architectures: architecture From 26194f320df8e03a02bc4bca0f03a7134a271ff0 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Wed, 13 Nov 2024 14:45:17 +0100 Subject: [PATCH 17/60] grid from solver --- src/Solvers/batched_tridiagonal_solver.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Solvers/batched_tridiagonal_solver.jl b/src/Solvers/batched_tridiagonal_solver.jl index 83cb5b2236..4f756ca3ac 100644 --- a/src/Solvers/batched_tridiagonal_solver.jl +++ b/src/Solvers/batched_tridiagonal_solver.jl @@ -108,7 +108,7 @@ function solve!(ϕ, solver::BatchedTridiagonalSolver, rhs, args...) active_cells_map = nothing elseif solver.tridiagonal_direction isa ZDirection launch_config = :xy - active_cells_map = retrieve_surface_active_cells_map(grid) + active_cells_map = retrieve_surface_active_cells_map(solver.grid) end launch!(architecture(solver), solver.grid, launch_config, From 0b70d31f29bbc4a951ea03f5a5fe20de19347670 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Thu, 28 Nov 2024 10:21:05 +0100 Subject: [PATCH 18/60] this should work --- src/Utils/kernel_launching.jl | 40 +++++++++++++++++------------------ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/Utils/kernel_launching.jl b/src/Utils/kernel_launching.jl index 02473f0d5b..3103993d78 100644 --- a/src/Utils/kernel_launching.jl +++ b/src/Utils/kernel_launching.jl @@ -486,29 +486,29 @@ function partition(kernel::MappedKernel, inrange, ingroupsize) return iterspace, dynamic end -using KernelAbstractions: CompilerMetadata, NoDynamicCheck +using KernelAbstractions: NoDynamicCheck using CUDA: CUDABackend import KernelAbstractions: mkcontext, __dynamic_checkbounds, __validindex -# Very dangerous override of mkcontext which will not work if we are not -# carefull with making sure that indices are correct when launching a `MappedKernel` -# TODO: Definitely change this with options below -function mkcontext(kernel::Kernel{CUDABackend}, _ndrange, iterspace::MappedNDRange) - return CompilerMetadata{ndrange(kernel), NoDynamicCheck}(_ndrange, iterspace) -end +# # Very dangerous override of mkcontext which will not work if we are not +# # carefull with making sure that indices are correct when launching a `MappedKernel` +# # TODO: Definitely change this with options below +# function mkcontext(kernel::Kernel{CUDABackend}, _ndrange, iterspace::MappedNDRange) +# return CompilerMetadata{ndrange(kernel), NoDynamicCheck}(_ndrange, iterspace) +# end # Alternative to the above to fix: -# const MappedCompilerMetadata = CompilerMetadata{<:Any, <:Any, <:Any, <:Any, <:MappedNDRange} - -# @inline __ndrange(cm::MappedCompilerMetadata) = cm.iterspace - -# @inline function __validindex(ctx::MappedCompilerMetadata, idx::CartesianIndex) -# # Turns this into a noop for code where we can turn of checkbounds of -# if __dynamic_checkbounds(ctx) -# I = @inbounds expand(__iterspace(ctx), __groupindex(ctx), idx) -# return I in __ndrange(ctx) -# else -# return true -# end -# end \ No newline at end of file +const MappedCompilerMetadata = CompilerMetadata{<:Any, <:Any, <:Any, <:Any, <:MappedNDRange} + +@inline __ndrange(cm::MappedCompilerMetadata) = cm.iterspace + +@inline function __validindex(ctx::MappedCompilerMetadata, idx::CartesianIndex) + # Turns this into a noop for code where we can turn of checkbounds of + if __dynamic_checkbounds(ctx) + index = @inbounds expand(__iterspace(ctx), __groupindex(ctx), idx) + return index.I in __ndrange(ctx) + else + return true + end +end \ No newline at end of file From c620492afadb400ef7d6f2a5ca1446bffec41463 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Thu, 28 Nov 2024 10:23:08 +0100 Subject: [PATCH 19/60] typo --- src/Utils/kernel_launching.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Utils/kernel_launching.jl b/src/Utils/kernel_launching.jl index 3103993d78..1d7bff2966 100644 --- a/src/Utils/kernel_launching.jl +++ b/src/Utils/kernel_launching.jl @@ -492,7 +492,7 @@ using CUDA: CUDABackend import KernelAbstractions: mkcontext, __dynamic_checkbounds, __validindex # # Very dangerous override of mkcontext which will not work if we are not -# # carefull with making sure that indices are correct when launching a `MappedKernel` +# # careful with making sure that indices are correct when launching a `MappedKernel` # # TODO: Definitely change this with options below # function mkcontext(kernel::Kernel{CUDABackend}, _ndrange, iterspace::MappedNDRange) # return CompilerMetadata{ndrange(kernel), NoDynamicCheck}(_ndrange, iterspace) From 3d3587824e255523fd9fe5455566929f74ca4dce Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Tue, 10 Dec 2024 10:57:39 +0100 Subject: [PATCH 20/60] extend surface map in halos --- src/ImmersedBoundaries/active_cells_map.jl | 11 ++++++++--- src/Utils/kernel_launching.jl | 8 -------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/ImmersedBoundaries/active_cells_map.jl b/src/ImmersedBoundaries/active_cells_map.jl index ce1d186eb8..fc80310a2a 100644 --- a/src/ImmersedBoundaries/active_cells_map.jl +++ b/src/ImmersedBoundaries/active_cells_map.jl @@ -103,6 +103,7 @@ function compute_active_z_columns(ibg) is_immersed_column = KernelFunctionOperation{Center, Center, Nothing}(active_column, ibg, active_cells_in_column) active_z_columns = Field{Center, Center, Nothing}(ibg, Bool) set!(active_z_columns, is_immersed_column) + fill_halo_regions!(active_z_columns) return active_z_columns end @@ -176,9 +177,13 @@ map_interior_active_cells(ibg) = interior_active_indices(ibg; parameters = :xyz) # computation only on active `columns` function map_active_z_columns(ibg) active_cells_field = compute_active_z_columns(ibg) - interior_cells = on_architecture(CPU(), interior(active_cells_field, :, :, 1)) - - full_indices = findall(interior_cells) + + Hx, Hy, _ = halo_size(ibg) + Nx, Ny, _ = size(ibg) + + # Limit to -H+2:N+H-1 + surface_cells = on_architecture(CPU(), active_cells_field.data)[-Hx+2:Nx+Hx-1, -Hy+2:Ny+Hy-1, 1] + full_indices = findall(surface_cells) Nx, Ny, _ = size(ibg) # Reduce the size of the active_cells_map (originally a tuple of Int64) diff --git a/src/Utils/kernel_launching.jl b/src/Utils/kernel_launching.jl index 1d7bff2966..d4e643976f 100644 --- a/src/Utils/kernel_launching.jl +++ b/src/Utils/kernel_launching.jl @@ -491,14 +491,6 @@ using CUDA: CUDABackend import KernelAbstractions: mkcontext, __dynamic_checkbounds, __validindex -# # Very dangerous override of mkcontext which will not work if we are not -# # careful with making sure that indices are correct when launching a `MappedKernel` -# # TODO: Definitely change this with options below -# function mkcontext(kernel::Kernel{CUDABackend}, _ndrange, iterspace::MappedNDRange) -# return CompilerMetadata{ndrange(kernel), NoDynamicCheck}(_ndrange, iterspace) -# end - -# Alternative to the above to fix: const MappedCompilerMetadata = CompilerMetadata{<:Any, <:Any, <:Any, <:Any, <:MappedNDRange} @inline __ndrange(cm::MappedCompilerMetadata) = cm.iterspace From 3609931a49a3cc57dabf3e3d9e07281582d88e3d Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Tue, 10 Dec 2024 11:09:53 +0100 Subject: [PATCH 21/60] this should work? --- src/Utils/kernel_launching.jl | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/Utils/kernel_launching.jl b/src/Utils/kernel_launching.jl index d4e643976f..729929dd58 100644 --- a/src/Utils/kernel_launching.jl +++ b/src/Utils/kernel_launching.jl @@ -491,15 +491,26 @@ using CUDA: CUDABackend import KernelAbstractions: mkcontext, __dynamic_checkbounds, __validindex -const MappedCompilerMetadata = CompilerMetadata{<:Any, <:Any, <:Any, <:Any, <:MappedNDRange} +const MappedCompilerMetadata = CompilerMetadata{<:StaticSize, <:Any, <:Any, <:Any, <:MappedNDRange} -@inline __ndrange(cm::MappedCompilerMetadata) = cm.iterspace +@inline linear_ndrange(::MappedCompilerMetadata{NDRange}) where NDRange = CartesianIndices(get(NDRange)) + +@inline function linear_index(ndrange::MappedNDRange, groupidx::CartesianIndex{N}, idx::CartesianIndex{N}) where N + nI = ntuple(Val(N)) do I + Base.@_inline_meta + offsets = workitems(ndrange) + stride = size(offsets, I) + gidx = groupidx.I[I] + (gidx - 1) * stride + idx.I[I] + end + return CartesianIndex(nI) +end @inline function __validindex(ctx::MappedCompilerMetadata, idx::CartesianIndex) # Turns this into a noop for code where we can turn of checkbounds of if __dynamic_checkbounds(ctx) - index = @inbounds expand(__iterspace(ctx), __groupindex(ctx), idx) - return index.I in __ndrange(ctx) + index = @inbounds linear_index(__iterspace(ctx), __groupindex(ctx), idx) + return index.I in linear_ndrange(ctx) else return true end From 01b71c180eb2dabad875009272965b1f50c7137a Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Tue, 10 Dec 2024 11:25:10 +0100 Subject: [PATCH 22/60] works maybe --- src/Utils/kernel_launching.jl | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Utils/kernel_launching.jl b/src/Utils/kernel_launching.jl index 729929dd58..724989525a 100644 --- a/src/Utils/kernel_launching.jl +++ b/src/Utils/kernel_launching.jl @@ -493,24 +493,23 @@ import KernelAbstractions: mkcontext, __dynamic_checkbounds, __validindex const MappedCompilerMetadata = CompilerMetadata{<:StaticSize, <:Any, <:Any, <:Any, <:MappedNDRange} -@inline linear_ndrange(::MappedCompilerMetadata{NDRange}) where NDRange = CartesianIndices(get(NDRange)) +@inline linear_ndrange(cm::MappedCompilerMetadata) = length(cm.ndrange.workitems) +# Mapped kernels are always 1D @inline function linear_index(ndrange::MappedNDRange, groupidx::CartesianIndex{N}, idx::CartesianIndex{N}) where N - nI = ntuple(Val(N)) do I - Base.@_inline_meta - offsets = workitems(ndrange) - stride = size(offsets, I) - gidx = groupidx.I[I] - (gidx - 1) * stride + idx.I[I] - end - return CartesianIndex(nI) + offsets = workitems(ndrange) + stride = size(offsets, 1) + gidx = groupidx.I[1] + return (gidx - 1) * stride + idx.I[1] end +# instead to check whether the index is valid in the index map, we need to +# check whether the index is valid by checking the size of the index map @inline function __validindex(ctx::MappedCompilerMetadata, idx::CartesianIndex) # Turns this into a noop for code where we can turn of checkbounds of if __dynamic_checkbounds(ctx) index = @inbounds linear_index(__iterspace(ctx), __groupindex(ctx), idx) - return index.I in linear_ndrange(ctx) + return index ≤ linear_ndrange(ctx) else return true end From bfcf4499e571c940e4c206261a8e0edb4c7374f0 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Tue, 10 Dec 2024 11:56:48 +0100 Subject: [PATCH 23/60] should speed up a lot --- .../distributed_immersed_boundaries.jl | 31 +++++++------ .../step_split_explicit_free_surface.jl | 23 +++++++--- ...ompute_hydrostatic_free_surface_buffers.jl | 36 +++++++++------ .../compute_w_from_continuity.jl | 4 +- ...te_hydrostatic_free_surface_model_state.jl | 22 +++++---- ...ompute_nonhydrostatic_buffer_tendencies.jl | 46 ++++--------------- ...nterleave_communication_and_computation.jl | 12 ++--- .../catke_vertical_diffusivity.jl | 5 +- .../time_step_catke_equation.jl | 6 +-- 9 files changed, 89 insertions(+), 96 deletions(-) diff --git a/src/DistributedComputations/distributed_immersed_boundaries.jl b/src/DistributedComputations/distributed_immersed_boundaries.jl index 01ffb3d67b..001c0626e3 100644 --- a/src/DistributedComputations/distributed_immersed_boundaries.jl +++ b/src/DistributedComputations/distributed_immersed_boundaries.jl @@ -121,28 +121,31 @@ function map_interior_active_cells(ibg::ImmersedBoundaryGrid{<:Any, <:Any, <:Any Nx, Ny, Nz = size(ibg) Hx, Hy, _ = halo_size(ibg) - x_boundary = (Hx, Ny, Nz) - y_boundary = (Nx, Hy, Nz) - - left_offsets = (0, 0, 0) - right_x_offsets = (Nx-Hx, 0, 0) - right_y_offsets = (0, Ny-Hy, 0) + west_boundary = (0:Hx, 1:Ny, 1:Nz) + east_boundary = (Nx-Hx+1:Nx+1, 1:Ny, 1:Nz) + south_boundary = (1:Nx, 0:Hy, 1:Nz) + north_boundary = (1:Nx, Ny-Hy+1:Ny+1, 1:Nz) include_west = !isa(ibg, XFlatGrid) && (Rx != 1) && !(Tx == RightConnected) include_east = !isa(ibg, XFlatGrid) && (Rx != 1) && !(Tx == LeftConnected) include_south = !isa(ibg, YFlatGrid) && (Ry != 1) && !(Ty == RightConnected) include_north = !isa(ibg, YFlatGrid) && (Ry != 1) && !(Ty == LeftConnected) - west_halo_dependent_cells = include_west ? interior_active_indices(ibg; parameters = KernelParameters(x_boundary, left_offsets)) : nothing - east_halo_dependent_cells = include_east ? interior_active_indices(ibg; parameters = KernelParameters(x_boundary, right_x_offsets)) : nothing - south_halo_dependent_cells = include_south ? interior_active_indices(ibg; parameters = KernelParameters(y_boundary, left_offsets)) : nothing - north_halo_dependent_cells = include_north ? interior_active_indices(ibg; parameters = KernelParameters(y_boundary, right_y_offsets)) : nothing + west_halo_dependent_cells = interior_active_indices(ibg; parameters = KernelParameters(west_boundary)) + east_halo_dependent_cells = interior_active_indices(ibg; parameters = KernelParameters(east_boundary)) + south_halo_dependent_cells = interior_active_indices(ibg; parameters = KernelParameters(south_boundary)) + north_halo_dependent_cells = interior_active_indices(ibg; parameters = KernelParameters(north_boundary)) + + west_halo_dependent_cells = ifelse(include_west , west_halo_dependent_cells , nothing) + east_halo_dependent_cells = ifelse(include_east , east_halo_dependent_cells , nothing) + south_halo_dependent_cells = ifelse(include_south, south_halo_dependent_cells, nothing) + north_halo_dependent_cells = ifelse(include_north, north_halo_dependent_cells, nothing) - nx = Rx == 1 ? Nx : (Tx == RightConnected || Tx == LeftConnected ? Nx - Hx : Nx - 2Hx) - ny = Ry == 1 ? Ny : (Ty == RightConnected || Ty == LeftConnected ? Ny - Hy : Ny - 2Hy) + nx = Rx == 1 ? Nx : (Tx == RightConnected || Tx == LeftConnected ? Nx - Hx + 1 : Nx - 2Hx + 2) + ny = Ry == 1 ? Ny : (Ty == RightConnected || Ty == LeftConnected ? Ny - Hy + 1 : Ny - 2Hy + 2) - ox = Rx == 1 || Tx == RightConnected ? 0 : Hx - oy = Ry == 1 || Ty == RightConnected ? 0 : Hy + ox = Rx == 1 || Tx == RightConnected ? 0 : Hx - 1 + oy = Ry == 1 || Ty == RightConnected ? 0 : Hy - 1 halo_independent_cells = interior_active_indices(ibg; parameters = KernelParameters((nx, ny, Nz), (ox, oy, 0))) diff --git a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl index 655e2e9068..880d65132f 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl @@ -70,8 +70,10 @@ function iterate_split_explicit!(free_surface, grid, GUⁿ, GVⁿ, Δτᴮ, weig U, V = free_surface.barotropic_velocities η̅, U̅, V̅ = state.η, state.U, state.V - free_surface_kernel!, _ = configure_kernel(arch, grid, parameters, _split_explicit_free_surface!) - barotropic_velocity_kernel!, _ = configure_kernel(arch, grid, parameters, _split_explicit_barotropic_velocity!) + active_cells_map = retrieve_surface_active_cells_map(grid) + + η_kernel!, _ = configure_kernel(arch, grid, parameters, _split_explicit_free_surface!; active_cells_map) + U_kernel!, _ = configure_kernel(arch, grid, parameters, _split_explicit_barotropic_velocity!; active_cells_map) η_args = (grid, Δτᴮ, η, U, V, timestepper) @@ -89,11 +91,18 @@ function iterate_split_explicit!(free_surface, grid, GUⁿ, GVⁿ, Δτᴮ, weig converted_η_args = convert_args(arch, η_args) converted_U_args = convert_args(arch, U_args) - @unroll for substep in 1:Nsubsteps - Base.@_inline_meta - averaging_weight = weights[substep] - free_surface_kernel!(converted_η_args...) - barotropic_velocity_kernel!(averaging_weight, converted_U_args...) + # We convert the kernels for the same reason (they might contain a surface map) + GC.@preserve η_kernel!, U_kernel! begin + + converted_η_kernel! = convert_args(arch, η_kernel!) + converted_U_kernel! = convert_args(arch, U_kernel!) + + @unroll for substep in 1:Nsubsteps + Base.@_inline_meta + averaging_weight = weights[substep] + converted_η_kernel!(converted_η_args...) + converted_U_kernel!(averaging_weight, converted_U_args...) + end end end diff --git a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_buffers.jl b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_buffers.jl index 7dc110d662..c0f3d2fef6 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_buffers.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_buffers.jl @@ -4,8 +4,6 @@ using Oceananigans.Grids: halo_size using Oceananigans.DistributedComputations: DistributedActiveCellsIBG using Oceananigans.ImmersedBoundaries: retrieve_interior_active_cells_map using Oceananigans.Models.NonhydrostaticModels: buffer_tendency_kernel_parameters, - buffer_p_kernel_parameters, - buffer_κ_kernel_parameters, buffer_parameters # We assume here that top/bottom BC are always synchronized (no partitioning in z) @@ -13,13 +11,6 @@ function compute_buffer_tendencies!(model::HydrostaticFreeSurfaceModel) grid = model.grid arch = architecture(grid) - w_parameters = buffer_w_kernel_parameters(grid, arch) - p_parameters = buffer_p_kernel_parameters(grid, arch) - κ_parameters = buffer_κ_kernel_parameters(grid, model.closure, arch) - - # We need new values for `w`, `p` and `κ` - compute_auxiliaries!(model; w_parameters, p_parameters, κ_parameters) - # parameters for communicating North / South / East / West side compute_buffer_tendency_contributions!(grid, arch, model) @@ -27,23 +18,40 @@ function compute_buffer_tendencies!(model::HydrostaticFreeSurfaceModel) end function compute_buffer_tendency_contributions!(grid, arch, model) + + params3D = buffer_surface_kernel_parameters(grid, arch) + params3D = buffer_tendency_kernel_parameters(grid, model.closure, arch) + + # We need new values for `w`, `p` and `κ` + compute_auxiliaries!(model, grid, arch; params2D, params3D, active_cells_map=nothing) + kernel_parameters = buffer_tendency_kernel_parameters(grid, arch) - compute_hydrostatic_free_surface_tendency_contributions!(model, kernel_parameters) + compute_hydrostatic_free_surface_tendency_contributions!(model, params3D) return nothing end function compute_buffer_tendency_contributions!(grid::DistributedActiveCellsIBG, arch, model) maps = grid.interior_active_cells - - for (name, map) in zip(keys(maps), maps) + + # We do not need 3D parameters, they are in the active map + params2D = buffer_surface_kernel_parameters(grid, arch) + + for (idx, name) in enumerate((:west_halo_dependent_cells, + :east_halo_dependent_cells, + :south_halo_dependent_cells, + :north_halo_dependent_cells)) + + map = maps[name] # If there exists a buffer map, then we compute the buffer contributions. If not, the # buffer contributions have already been calculated. We exclude the interior because it has # already been calculated - compute_buffer = (name != :interior) && !isnothing(map) + compute_buffer = !isnothing(map) if compute_buffer active_cells_map = retrieve_interior_active_cells_map(grid, Val(name)) + compute_auxiliaries!(model; params2D=params2D[idx], params3D=:xyz, active_cells_map) + compute_hydrostatic_free_surface_tendency_contributions!(model, :xyz; active_cells_map) end end @@ -52,7 +60,7 @@ function compute_buffer_tendency_contributions!(grid::DistributedActiveCellsIBG, end # w needs computing in the range - H + 1 : 0 and N - 1 : N + H - 1 -function buffer_w_kernel_parameters(grid, arch) +function buffer_surface_kernel_parameters(grid, arch) Nx, Ny, _ = size(grid) Hx, Hy, _ = halo_size(grid) diff --git a/src/Models/HydrostaticFreeSurfaceModels/compute_w_from_continuity.jl b/src/Models/HydrostaticFreeSurfaceModels/compute_w_from_continuity.jl index 927489cf50..6249c2080f 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/compute_w_from_continuity.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/compute_w_from_continuity.jl @@ -15,7 +15,7 @@ w^{n+1} = -∫ [∂/∂x (u^{n+1}) + ∂/∂y (v^{n+1})] dz compute_w_from_continuity!(model; kwargs...) = compute_w_from_continuity!(model.velocities, model.architecture, model.grid; kwargs...) -compute_w_from_continuity!(velocities, arch, grid; parameters = w_kernel_parameters(grid)) = +compute_w_from_continuity!(velocities, arch, grid; parameters = surface_kernel_parameters(grid)) = launch!(arch, grid, parameters, _compute_w_from_continuity!, velocities, grid) @kernel function _compute_w_from_continuity!(U, grid) @@ -33,7 +33,7 @@ end # extend w kernel to compute also the boundaries # If Flat, do not calculate on halos! -@inline function w_kernel_parameters(grid) +@inline function surface_kernel_parameters(grid) Nx, Ny, _ = size(grid) Hx, Hy, _ = halo_size(grid) Tx, Ty, _ = topology(grid) diff --git a/src/Models/HydrostaticFreeSurfaceModels/update_hydrostatic_free_surface_model_state.jl b/src/Models/HydrostaticFreeSurfaceModels/update_hydrostatic_free_surface_model_state.jl index 89aa0d6ab8..55176fbcbc 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/update_hydrostatic_free_surface_model_state.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/update_hydrostatic_free_surface_model_state.jl @@ -70,20 +70,22 @@ function mask_immersed_model_fields!(model, grid) return nothing end -function compute_auxiliaries!(model::HydrostaticFreeSurfaceModel; w_parameters = tuple(w_kernel_parameters(model.grid)), - p_parameters = tuple(p_kernel_parameters(model.grid)), - κ_parameters = tuple(:xyz)) +function compute_auxiliaries!(model::HydrostaticFreeSurfaceModel, grid, arch; + params2D = surface_kernel_parameters(grid), + params3D = interior_tendency_kernel_parameters(arch, grid), + active_cells_map = retrieve_interior_active_cells_map(grid, Val(:interior))) grid = model.grid closure = model.closure diffusivity = model.diffusivity_fields - for (wpar, ppar, κpar) in zip(w_parameters, p_parameters, κ_parameters) - compute_w_from_continuity!(model; parameters = wpar) - compute_diffusivities!(diffusivity, closure, model; parameters = κpar) - update_hydrostatic_pressure!(model.pressure.pHY′, architecture(grid), - grid, model.buoyancy, model.tracers; - parameters = ppar) - end + compute_w_from_continuity!(model; parameters = params2D) + + update_hydrostatic_pressure!(model.pressure.pHY′, architecture(grid), + grid, model.buoyancy, model.tracers; + parameters = params2D) + + compute_diffusivities!(diffusivity, closure, model; parameters=params3D, active_cells_map) + return nothing end diff --git a/src/Models/NonhydrostaticModels/compute_nonhydrostatic_buffer_tendencies.jl b/src/Models/NonhydrostaticModels/compute_nonhydrostatic_buffer_tendencies.jl index 6e439ed7a4..8ecc2ba499 100644 --- a/src/Models/NonhydrostaticModels/compute_nonhydrostatic_buffer_tendencies.jl +++ b/src/Models/NonhydrostaticModels/compute_nonhydrostatic_buffer_tendencies.jl @@ -11,14 +11,13 @@ function compute_buffer_tendencies!(model::NonhydrostaticModel) grid = model.grid arch = architecture(grid) - p_parameters = buffer_p_kernel_parameters(grid, arch) - κ_parameters = buffer_κ_kernel_parameters(grid, model.closure, arch) - + params2D = buffer_surface_kernel_parameters(grid, arch) + params3D = buffer_tendency_kernel_parameters(grid, arch) + # We need new values for `p` and `κ` - compute_auxiliaries!(model; p_parameters, κ_parameters) + compute_auxiliaries!(model, grid, arch; params2D, params3D) # parameters for communicating North / South / East / West side - kernel_parameters = buffer_tendency_kernel_parameters(grid, arch) compute_interior_tendency_contributions!(model, kernel_parameters) return nothing @@ -29,39 +28,10 @@ function buffer_tendency_kernel_parameters(grid, arch) Nx, Ny, Nz = size(grid) Hx, Hy, _ = halo_size(grid) - param_west = (1:Hx, 1:Ny, 1:Nz) - param_east = (Nx-Hx+1:Nx, 1:Ny, 1:Nz) - param_south = (1:Nx, 1:Hy, 1:Nz) - param_north = (1:Nx, Ny-Hy+1:Ny, 1:Nz) - - params = (param_west, param_east, param_south, param_north) - return buffer_parameters(params, grid, arch) -end - -# p needs computing in the range 0 : 0 and N + 1 : N + 1 -function buffer_p_kernel_parameters(grid, arch) - Nx, Ny, _ = size(grid) - - param_west = (0:0, 1:Ny) - param_east = (Nx+1:Nx+1, 1:Ny) - param_south = (1:Nx, 0:0) - param_north = (1:Nx, Ny+1:Ny+1) - - params = (param_west, param_east, param_south, param_north) - return buffer_parameters(params, grid, arch) -end - -# diffusivities need recomputing in the range 0 : B and N - B + 1 : N + 1 -function buffer_κ_kernel_parameters(grid, closure, arch) - Nx, Ny, Nz = size(grid) - - Bx = required_halo_size_x(closure) - By = required_halo_size_y(closure) - - param_west = (0:Bx, 1:Ny, 1:Nz) - param_east = (Nx-Bx+1:Nx+1, 1:Ny, 1:Nz) - param_south = (1:Nx, 0:By, 1:Nz) - param_north = (1:Nx, Ny-By+1:Ny+1, 1:Nz) + param_west = (0:Hx, 1:Ny, 1:Nz) + param_east = (Nx-Hx+1:Nx+1, 1:Ny, 1:Nz) + param_south = (1:Nx, 0:Hy, 1:Nz) + param_north = (1:Nx, Ny-Hy+1:Ny+1, 1:Nz) params = (param_west, param_east, param_south, param_north) return buffer_parameters(params, grid, arch) diff --git a/src/Models/interleave_communication_and_computation.jl b/src/Models/interleave_communication_and_computation.jl index 3a0a98b1af..6f37856e75 100644 --- a/src/Models/interleave_communication_and_computation.jl +++ b/src/Models/interleave_communication_and_computation.jl @@ -46,22 +46,22 @@ function interior_tendency_kernel_parameters(arch::Distributed, grid) Sx = if local_x Nx elseif one_sided_x - Nx - Hx + Nx - Hx + 1 else # two sided - Nx - 2Hx + Nx - 2Hx + 2 end Sy = if local_y Ny elseif one_sided_y - Ny - Hy + Ny - Hy + 1 else # two sided - Ny - 2Hy + Ny - 2Hy + 2 end # Offsets - Ox = Rx == 1 || Tx == RightConnected ? 0 : Hx - Oy = Ry == 1 || Ty == RightConnected ? 0 : Hy + Ox = Rx == 1 || Tx == RightConnected ? 0 : Hx - 1 + Oy = Ry == 1 || Ty == RightConnected ? 0 : Hy - 1 sizes = (Sx, Sy, Nz) offsets = (Ox, Oy, 0) diff --git a/src/TurbulenceClosures/turbulence_closure_implementations/TKEBasedVerticalDiffusivities/catke_vertical_diffusivity.jl b/src/TurbulenceClosures/turbulence_closure_implementations/TKEBasedVerticalDiffusivities/catke_vertical_diffusivity.jl index 4847a3802a..6e958eaa3a 100644 --- a/src/TurbulenceClosures/turbulence_closure_implementations/TKEBasedVerticalDiffusivities/catke_vertical_diffusivity.jl +++ b/src/TurbulenceClosures/turbulence_closure_implementations/TKEBasedVerticalDiffusivities/catke_vertical_diffusivity.jl @@ -177,7 +177,8 @@ end @inline viscosity_location(::FlavorOfCATKE) = (c, c, f) @inline diffusivity_location(::FlavorOfCATKE) = (c, c, f) -function compute_diffusivities!(diffusivities, closure::FlavorOfCATKE, model; parameters = :xyz) +function compute_diffusivities!(diffusivities, closure::FlavorOfCATKE, model; + parameters = :xyz, active_cells_map = nothing) arch = model.architecture grid = model.grid @@ -193,7 +194,7 @@ function compute_diffusivities!(diffusivities, closure::FlavorOfCATKE, model; pa # Compute e at the current time: # * update tendency Gⁿ using current and previous velocity field # * use tridiagonal solve to take an implicit step - time_step_catke_equation!(model) + time_step_catke_equation!(model; parameters, active_cells_map) end # Update "previous velocities" diff --git a/src/TurbulenceClosures/turbulence_closure_implementations/TKEBasedVerticalDiffusivities/time_step_catke_equation.jl b/src/TurbulenceClosures/turbulence_closure_implementations/TKEBasedVerticalDiffusivities/time_step_catke_equation.jl index 9cf74fcc5b..8206f4b690 100644 --- a/src/TurbulenceClosures/turbulence_closure_implementations/TKEBasedVerticalDiffusivities/time_step_catke_equation.jl +++ b/src/TurbulenceClosures/turbulence_closure_implementations/TKEBasedVerticalDiffusivities/time_step_catke_equation.jl @@ -9,7 +9,7 @@ using CUDA get_time_step(closure::CATKEVerticalDiffusivity) = closure.tke_time_step -function time_step_catke_equation!(model) +function time_step_catke_equation!(model; parameters, active_cells_map) # TODO: properly handle closure tuples if model.closure isa Tuple @@ -54,12 +54,12 @@ function time_step_catke_equation!(model) # Compute the linear implicit component of the RHS (diffusivities, L) # and step forward - launch!(arch, grid, :xyz, + launch!(arch, grid, parameters, substep_turbulent_kinetic_energy!, κe, Le, grid, closure, model.velocities, previous_velocities, # try this soon: model.velocities, model.velocities, model.tracers, model.buoyancy, diffusivity_fields, - Δτ, χ, Gⁿe, G⁻e) + Δτ, χ, Gⁿe, G⁻e; active_cells_map) # Good idea? # previous_time = model.clock.time - Δt From e1ad82d549639e5ffde15b1bb7d434ced01f1c82 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Tue, 10 Dec 2024 12:04:01 +0100 Subject: [PATCH 24/60] precompiles --- .../step_split_explicit_free_surface.jl | 4 ++-- ...compute_hydrostatic_free_surface_tendencies.jl | 12 +----------- .../update_nonhydrostatic_model_state.jl | 15 ++++++++------- 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl index 880d65132f..9ab3617926 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl @@ -92,8 +92,8 @@ function iterate_split_explicit!(free_surface, grid, GUⁿ, GVⁿ, Δτᴮ, weig converted_U_args = convert_args(arch, U_args) # We convert the kernels for the same reason (they might contain a surface map) - GC.@preserve η_kernel!, U_kernel! begin - + GC.@preserve η_kernel! U_kernel! begin + converted_η_kernel! = convert_args(arch, η_kernel!) converted_U_kernel! = convert_args(arch, U_kernel!) diff --git a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl index c5320f289f..c14cb113da 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_tendencies.jl @@ -197,14 +197,4 @@ end @kernel function compute_hydrostatic_free_surface_Gc!(Gc, grid, args) i, j, k = @index(Global, NTuple) @inbounds Gc[i, j, k] = hydrostatic_free_surface_tracer_tendency(i, j, k, grid, args...) -end - -##### -##### Tendency calculators for an explicit free surface -##### - -""" Calculate the right-hand-side of the free surface displacement (``η``) equation. """ -@kernel function compute_hydrostatic_free_surface_Gη!(Gη, grid, args) - i, j = @index(Global, NTuple) - @inbounds Gη[i, j, grid.Nz+1] = free_surface_tendency(i, j, grid, args...) -end +end \ No newline at end of file diff --git a/src/Models/NonhydrostaticModels/update_nonhydrostatic_model_state.jl b/src/Models/NonhydrostaticModels/update_nonhydrostatic_model_state.jl index 705ca507ac..ae6d11c6d9 100644 --- a/src/Models/NonhydrostaticModels/update_nonhydrostatic_model_state.jl +++ b/src/Models/NonhydrostaticModels/update_nonhydrostatic_model_state.jl @@ -40,7 +40,7 @@ function update_state!(model::NonhydrostaticModel, callbacks=[]; compute_tendenc end # Calculate diffusivities and hydrostatic pressure - @apply_regionally compute_auxiliaries!(model) + @apply_regionally compute_auxiliaries!(model, grid, arch) fill_halo_regions!(model.diffusivity_fields; only_local_halos = true) for callback in callbacks @@ -55,15 +55,16 @@ function update_state!(model::NonhydrostaticModel, callbacks=[]; compute_tendenc return nothing end -function compute_auxiliaries!(model::NonhydrostaticModel; p_parameters = tuple(p_kernel_parameters(model.grid)), - κ_parameters = tuple(:xyz)) +function compute_auxiliaries!(model::NonhydrostaticModel, grid, arch; + params2D = surface_kernel_parameters(grid), + params3D = interior_tendency_kernel_parameters(arch, grid)) closure = model.closure diffusivity = model.diffusivity_fields - for (ppar, κpar) in zip(p_parameters, κ_parameters) - compute_diffusivities!(diffusivity, closure, model; parameters = κpar) - update_hydrostatic_pressure!(model; parameters = ppar) - end + update_hydrostatic_pressure!(model; parameters=params2D) + + compute_diffusivities!(diffusivity, closure, model; parameters=params3D) + return nothing end From c8efdb1e905286d616a90aa40b080e0efe94aeb6 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Tue, 10 Dec 2024 12:11:38 +0100 Subject: [PATCH 25/60] fixes --- ...ompute_hydrostatic_free_surface_buffers.jl | 25 ++----------------- ...ompute_nonhydrostatic_buffer_tendencies.jl | 17 +++++++++++++ 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_buffers.jl b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_buffers.jl index c0f3d2fef6..cf0c272a47 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_buffers.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_buffers.jl @@ -4,7 +4,7 @@ using Oceananigans.Grids: halo_size using Oceananigans.DistributedComputations: DistributedActiveCellsIBG using Oceananigans.ImmersedBoundaries: retrieve_interior_active_cells_map using Oceananigans.Models.NonhydrostaticModels: buffer_tendency_kernel_parameters, - buffer_parameters + buffer_surface_kernel_parameters # We assume here that top/bottom BC are always synchronized (no partitioning in z) function compute_buffer_tendencies!(model::HydrostaticFreeSurfaceModel) @@ -19,7 +19,7 @@ end function compute_buffer_tendency_contributions!(grid, arch, model) - params3D = buffer_surface_kernel_parameters(grid, arch) + params2D = buffer_surface_kernel_parameters(grid, arch) params3D = buffer_tendency_kernel_parameters(grid, model.closure, arch) # We need new values for `w`, `p` and `κ` @@ -58,24 +58,3 @@ function compute_buffer_tendency_contributions!(grid::DistributedActiveCellsIBG, return nothing end - -# w needs computing in the range - H + 1 : 0 and N - 1 : N + H - 1 -function buffer_surface_kernel_parameters(grid, arch) - Nx, Ny, _ = size(grid) - Hx, Hy, _ = halo_size(grid) - - Sx = (Hx, Ny+2) - Sy = (Nx+2, Hy) - - # Offsets in tangential direction are == -1 to - # cover the required corners - param_west = (-Hx+2:1, 0:Ny+1) - param_east = (Nx:Nx+Hx-1, 0:Ny+1) - param_south = (0:Nx+1, -Hy+2:1) - param_north = (0:Nx+1, Ny:Ny+Hy-1) - - params = (param_west, param_east, param_south, param_north) - - return buffer_parameters(params, grid, arch) -end - diff --git a/src/Models/NonhydrostaticModels/compute_nonhydrostatic_buffer_tendencies.jl b/src/Models/NonhydrostaticModels/compute_nonhydrostatic_buffer_tendencies.jl index 8ecc2ba499..c8f392d072 100644 --- a/src/Models/NonhydrostaticModels/compute_nonhydrostatic_buffer_tendencies.jl +++ b/src/Models/NonhydrostaticModels/compute_nonhydrostatic_buffer_tendencies.jl @@ -23,6 +23,23 @@ function compute_buffer_tendencies!(model::NonhydrostaticModel) return nothing end +# surface needs computing in the range - H + 1 : 0 and N - 1 : N + H - 1 +function buffer_surface_kernel_parameters(grid, arch) + Nx, Ny, _ = size(grid) + Hx, Hy, _ = halo_size(grid) + + # Offsets in tangential direction are == -1 to + # cover the required corners + param_west = (-Hx+2:1, 0:Ny+1) + param_east = (Nx:Nx+Hx-1, 0:Ny+1) + param_south = (0:Nx+1, -Hy+2:1) + param_north = (0:Nx+1, Ny:Ny+Hy-1) + + params = (param_west, param_east, param_south, param_north) + + return buffer_parameters(params, grid, arch) +end + # tendencies need computing in the range 1 : H and N - H + 1 : N function buffer_tendency_kernel_parameters(grid, arch) Nx, Ny, Nz = size(grid) From a1f09b43489f06e2d9723393536f04f30ceda8a1 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Tue, 10 Dec 2024 12:22:15 +0100 Subject: [PATCH 26/60] more corrections --- ...ompute_hydrostatic_free_surface_buffers.jl | 3 +- .../compute_w_from_continuity.jl | 20 ++----------- ...te_hydrostatic_free_surface_model_state.jl | 4 +-- .../update_nonhydrostatic_model_state.jl | 2 +- ...nterleave_communication_and_computation.jl | 28 +++++++++++++++++-- 5 files changed, 32 insertions(+), 25 deletions(-) diff --git a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_buffers.jl b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_buffers.jl index cf0c272a47..6b5983b8c6 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_buffers.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_buffers.jl @@ -50,8 +50,7 @@ function compute_buffer_tendency_contributions!(grid::DistributedActiveCellsIBG, if compute_buffer active_cells_map = retrieve_interior_active_cells_map(grid, Val(name)) - compute_auxiliaries!(model; params2D=params2D[idx], params3D=:xyz, active_cells_map) - + compute_auxiliaries!(model, grid, arch; params2D=params2D[idx], active_cells_map) compute_hydrostatic_free_surface_tendency_contributions!(model, :xyz; active_cells_map) end end diff --git a/src/Models/HydrostaticFreeSurfaceModels/compute_w_from_continuity.jl b/src/Models/HydrostaticFreeSurfaceModels/compute_w_from_continuity.jl index 6249c2080f..4b0d9d4dba 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/compute_w_from_continuity.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/compute_w_from_continuity.jl @@ -1,4 +1,5 @@ using Oceananigans.Architectures: device +using Oceananigans.Models: surface_kernel_parameters using Oceananigans.Grids: halo_size, topology using Oceananigans.Grids: XFlatGrid, YFlatGrid using Oceananigans.Operators: div_xyᶜᶜᶜ, Δzᶜᶜᶜ @@ -25,21 +26,4 @@ compute_w_from_continuity!(velocities, arch, grid; parameters = surface_kernel_p for k in 2:grid.Nz+1 @inbounds U.w[i, j, k] = U.w[i, j, k-1] - Δzᶜᶜᶜ(i, j, k-1, grid) * div_xyᶜᶜᶜ(i, j, k-1, grid, U.u, U.v) end -end - -##### -##### Size and offsets for the w kernel -##### - -# extend w kernel to compute also the boundaries -# If Flat, do not calculate on halos! -@inline function surface_kernel_parameters(grid) - Nx, Ny, _ = size(grid) - Hx, Hy, _ = halo_size(grid) - Tx, Ty, _ = topology(grid) - - ii = ifelse(Tx == Flat, 1:Nx, -Hx+2:Nx+Hx-1) - jj = ifelse(Ty == Flat, 1:Ny, -Hy+2:Ny+Hy-1) - - return KernelParameters(ii, jj) -end +end \ No newline at end of file diff --git a/src/Models/HydrostaticFreeSurfaceModels/update_hydrostatic_free_surface_model_state.jl b/src/Models/HydrostaticFreeSurfaceModels/update_hydrostatic_free_surface_model_state.jl index 55176fbcbc..f33fbcc45f 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/update_hydrostatic_free_surface_model_state.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/update_hydrostatic_free_surface_model_state.jl @@ -7,7 +7,7 @@ using Oceananigans.BoundaryConditions: update_boundary_condition! using Oceananigans.TurbulenceClosures: compute_diffusivities! using Oceananigans.ImmersedBoundaries: mask_immersed_field!, mask_immersed_field_xy!, inactive_node using Oceananigans.Models: update_model_field_time_series! -using Oceananigans.Models.NonhydrostaticModels: update_hydrostatic_pressure!, p_kernel_parameters +using Oceananigans.Models.NonhydrostaticModels: update_hydrostatic_pressure!, surface_kernel_parameters, interior_tendency_kernel_parameters using Oceananigans.Fields: replace_horizontal_vector_halos! import Oceananigans.Models.NonhydrostaticModels: compute_auxiliaries! @@ -41,7 +41,7 @@ function update_state!(model::HydrostaticFreeSurfaceModel, grid, callbacks; comp fill_halo_regions!(prognostic_fields(model), model.clock, fields(model); async = true) @apply_regionally replace_horizontal_vector_halos!(model.velocities, model.grid) - @apply_regionally compute_auxiliaries!(model) + @apply_regionally compute_auxiliaries!(model, grid, architecture(grid)) fill_halo_regions!(model.diffusivity_fields; only_local_halos = true) diff --git a/src/Models/NonhydrostaticModels/update_nonhydrostatic_model_state.jl b/src/Models/NonhydrostaticModels/update_nonhydrostatic_model_state.jl index ae6d11c6d9..35cb9ecb42 100644 --- a/src/Models/NonhydrostaticModels/update_nonhydrostatic_model_state.jl +++ b/src/Models/NonhydrostaticModels/update_nonhydrostatic_model_state.jl @@ -6,7 +6,7 @@ using Oceananigans.BoundaryConditions: update_boundary_condition! using Oceananigans.TurbulenceClosures: compute_diffusivities! using Oceananigans.Fields: compute! using Oceananigans.ImmersedBoundaries: mask_immersed_field! -using Oceananigans.Models: update_model_field_time_series! +using Oceananigans.Models: update_model_field_time_series!, surface_kernel_parameters, interior_tendency_kernel_parameters import Oceananigans.TimeSteppers: update_state! diff --git a/src/Models/interleave_communication_and_computation.jl b/src/Models/interleave_communication_and_computation.jl index 6f37856e75..55dc8aae44 100644 --- a/src/Models/interleave_communication_and_computation.jl +++ b/src/Models/interleave_communication_and_computation.jl @@ -29,7 +29,7 @@ compute_buffer_tendencies!(model) = nothing interior_tendency_kernel_parameters(arch, grid) = :xyz # fallback interior_tendency_kernel_parameters(::SynchronizedDistributed, grid) = :xyz -function interior_tendency_kernel_parameters(arch::Distributed, grid) +function interior_parameters_without_halo(arch, grid) Rx, Ry, _ = arch.ranks Hx, Hy, _ = halo_size(grid) Tx, Ty, _ = topology(grid) @@ -66,6 +66,30 @@ function interior_tendency_kernel_parameters(arch::Distributed, grid) sizes = (Sx, Sy, Nz) offsets = (Ox, Oy, 0) - return KernelParameters(sizes, offsets) + return sizes, offsets +end + +function interior_tendency_kernel_parameters(arch::Distributed, grid) + return KernelParameters(interior_parameters_without_halo(arch, grid)...) +end + +@inline surface_kernel_parameters(arch, grid) = surface_kernel_parameters(grid) +@inline surface_kernel_parameters(::SynchronizedDistributed, grid) = surface_kernel_parameters(grid) + +# extend w kernel to compute also the boundaries +# If Flat, do not calculate on halos! +@inline function surface_kernel_parameters(grid) + Nx, Ny, _ = size(grid) + Hx, Hy, _ = halo_size(grid) + Tx, Ty, _ = topology(grid) + + ii = ifelse(Tx == Flat, 1:Nx, -Hx+2:Nx+Hx-1) + jj = ifelse(Ty == Flat, 1:Ny, -Hy+2:Ny+Hy-1) + + return KernelParameters(ii, jj) end +@inline function surface_kernel_parameters(arch::Distributed, grid) + size, offset = interior_parameters_without_halo(arch, grid) + return KernelParameters(size[1:2], offset[1:2]) +end From 1c043bcf18388894f9121a5b9b151c779b2d40da Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Tue, 10 Dec 2024 12:25:33 +0100 Subject: [PATCH 27/60] probably it should work --- .../HydrostaticFreeSurfaceModels/compute_w_from_continuity.jl | 2 +- .../update_hydrostatic_free_surface_model_state.jl | 2 +- .../NonhydrostaticModels/update_hydrostatic_pressure.jl | 4 ++-- .../NonhydrostaticModels/update_nonhydrostatic_model_state.jl | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Models/HydrostaticFreeSurfaceModels/compute_w_from_continuity.jl b/src/Models/HydrostaticFreeSurfaceModels/compute_w_from_continuity.jl index 4b0d9d4dba..8a95385208 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/compute_w_from_continuity.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/compute_w_from_continuity.jl @@ -16,7 +16,7 @@ w^{n+1} = -∫ [∂/∂x (u^{n+1}) + ∂/∂y (v^{n+1})] dz compute_w_from_continuity!(model; kwargs...) = compute_w_from_continuity!(model.velocities, model.architecture, model.grid; kwargs...) -compute_w_from_continuity!(velocities, arch, grid; parameters = surface_kernel_parameters(grid)) = +compute_w_from_continuity!(velocities, arch, grid; parameters = surface_kernel_parameters(arch, grid)) = launch!(arch, grid, parameters, _compute_w_from_continuity!, velocities, grid) @kernel function _compute_w_from_continuity!(U, grid) diff --git a/src/Models/HydrostaticFreeSurfaceModels/update_hydrostatic_free_surface_model_state.jl b/src/Models/HydrostaticFreeSurfaceModels/update_hydrostatic_free_surface_model_state.jl index f33fbcc45f..7851e84418 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/update_hydrostatic_free_surface_model_state.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/update_hydrostatic_free_surface_model_state.jl @@ -71,7 +71,7 @@ function mask_immersed_model_fields!(model, grid) end function compute_auxiliaries!(model::HydrostaticFreeSurfaceModel, grid, arch; - params2D = surface_kernel_parameters(grid), + params2D = surface_kernel_parameters(arch, grid), params3D = interior_tendency_kernel_parameters(arch, grid), active_cells_map = retrieve_interior_active_cells_map(grid, Val(:interior))) diff --git a/src/Models/NonhydrostaticModels/update_hydrostatic_pressure.jl b/src/Models/NonhydrostaticModels/update_hydrostatic_pressure.jl index a35e68e63b..5b3f94c4e5 100644 --- a/src/Models/NonhydrostaticModels/update_hydrostatic_pressure.jl +++ b/src/Models/NonhydrostaticModels/update_hydrostatic_pressure.jl @@ -28,10 +28,10 @@ update_hydrostatic_pressure!(grid, model; kwargs...) = const PCB = PartialCellBottom const PCBIBG = ImmersedBoundaryGrid{<:Any, <:Any, <:Any, <:Any, <:Any, <:PCB} -update_hydrostatic_pressure!(pHY′, arch, ibg::PCBIBG, buoyancy, tracers; parameters = p_kernel_parameters(ibg.underlying_grid)) = +update_hydrostatic_pressure!(pHY′, arch, ibg::PCBIBG, buoyancy, tracers; parameters = surface_kernel_parameters(arch, ibg.underlying_grid)) = update_hydrostatic_pressure!(pHY′, arch, ibg.underlying_grid, buoyancy, tracers; parameters) -update_hydrostatic_pressure!(pHY′, arch, grid, buoyancy, tracers; parameters = p_kernel_parameters(grid)) = +update_hydrostatic_pressure!(pHY′, arch, grid, buoyancy, tracers; parameters = surface_kernel_parameters(arch, grid)) = launch!(arch, grid, parameters, _update_hydrostatic_pressure!, pHY′, grid, buoyancy, tracers) update_hydrostatic_pressure!(::Nothing, arch, grid, args...; kw...) = nothing diff --git a/src/Models/NonhydrostaticModels/update_nonhydrostatic_model_state.jl b/src/Models/NonhydrostaticModels/update_nonhydrostatic_model_state.jl index 35cb9ecb42..6898b16ecb 100644 --- a/src/Models/NonhydrostaticModels/update_nonhydrostatic_model_state.jl +++ b/src/Models/NonhydrostaticModels/update_nonhydrostatic_model_state.jl @@ -56,7 +56,7 @@ function update_state!(model::NonhydrostaticModel, callbacks=[]; compute_tendenc end function compute_auxiliaries!(model::NonhydrostaticModel, grid, arch; - params2D = surface_kernel_parameters(grid), + params2D = surface_kernel_parameters(arch, grid), params3D = interior_tendency_kernel_parameters(arch, grid)) closure = model.closure From ee98cf2e32436462213c9e3514584cb8201d3c37 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Tue, 10 Dec 2024 12:35:24 +0100 Subject: [PATCH 28/60] more corrections --- src/Utils/kernel_launching.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Utils/kernel_launching.jl b/src/Utils/kernel_launching.jl index 724989525a..eccdef2803 100644 --- a/src/Utils/kernel_launching.jl +++ b/src/Utils/kernel_launching.jl @@ -486,10 +486,10 @@ function partition(kernel::MappedKernel, inrange, ingroupsize) return iterspace, dynamic end -using KernelAbstractions: NoDynamicCheck -using CUDA: CUDABackend +# Extend the valid index function to check whether the index is valid in the index map -import KernelAbstractions: mkcontext, __dynamic_checkbounds, __validindex +using KernelAbstractions: __iterspace, __groupindex, __dynamic_checkbounds +import KernelAbstractions: __validindex const MappedCompilerMetadata = CompilerMetadata{<:StaticSize, <:Any, <:Any, <:Any, <:MappedNDRange} From 1a15fc33eff1adee3f5952fe394af61077861f9f Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Tue, 10 Dec 2024 12:47:01 +0100 Subject: [PATCH 29/60] more changes --- .../step_split_explicit_free_surface.jl | 4 ++-- .../Smagorinskys/smagorinsky.jl | 4 ++-- .../catke_vertical_diffusivity.jl | 3 ++- .../tke_dissipation_vertical_diffusivity.jl | 5 +++-- .../anisotropic_minimum_dissipation.jl | 4 ++-- .../convective_adjustment_vertical_diffusivity.jl | 4 ++-- .../isopycnal_skew_symmetric_diffusivity.jl | 4 ++-- .../leith_enstrophy_diffusivity.jl | 4 ++-- .../ri_based_vertical_diffusivity.jl | 8 +++++--- .../scalar_biharmonic_diffusivity.jl | 2 +- .../scalar_diffusivity.jl | 2 +- test/test_distributed_hydrostatic_model.jl | 2 +- 12 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl index 9ab3617926..25a74c59c0 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl @@ -100,8 +100,8 @@ function iterate_split_explicit!(free_surface, grid, GUⁿ, GVⁿ, Δτᴮ, weig @unroll for substep in 1:Nsubsteps Base.@_inline_meta averaging_weight = weights[substep] - converted_η_kernel!(converted_η_args...) - converted_U_kernel!(averaging_weight, converted_U_args...) + η_kernel!(converted_η_args...) + U_kernel!(averaging_weight, converted_U_args...) end end end diff --git a/src/TurbulenceClosures/turbulence_closure_implementations/Smagorinskys/smagorinsky.jl b/src/TurbulenceClosures/turbulence_closure_implementations/Smagorinskys/smagorinsky.jl index d7968017b0..d89a946fcc 100644 --- a/src/TurbulenceClosures/turbulence_closure_implementations/Smagorinskys/smagorinsky.jl +++ b/src/TurbulenceClosures/turbulence_closure_implementations/Smagorinskys/smagorinsky.jl @@ -105,7 +105,7 @@ end compute_coefficient_fields!(diffusivity_fields, closure, model; parameters) = nothing -function compute_diffusivities!(diffusivity_fields, closure::Smagorinsky, model; parameters = :xyz) +function compute_diffusivities!(diffusivity_fields, closure::Smagorinsky, model; parameters = :xyz, active_cells_map = nothing) arch = model.architecture grid = model.grid buoyancy = model.buoyancy @@ -115,7 +115,7 @@ function compute_diffusivities!(diffusivity_fields, closure::Smagorinsky, model; compute_coefficient_fields!(diffusivity_fields, closure, model; parameters) launch!(arch, grid, parameters, _compute_smagorinsky_viscosity!, - diffusivity_fields, grid, closure, buoyancy, velocities, tracers) + diffusivity_fields, grid, closure, buoyancy, velocities, tracers; active_cells_map) return nothing end diff --git a/src/TurbulenceClosures/turbulence_closure_implementations/TKEBasedVerticalDiffusivities/catke_vertical_diffusivity.jl b/src/TurbulenceClosures/turbulence_closure_implementations/TKEBasedVerticalDiffusivities/catke_vertical_diffusivity.jl index 6e958eaa3a..3febffd2a6 100644 --- a/src/TurbulenceClosures/turbulence_closure_implementations/TKEBasedVerticalDiffusivities/catke_vertical_diffusivity.jl +++ b/src/TurbulenceClosures/turbulence_closure_implementations/TKEBasedVerticalDiffusivities/catke_vertical_diffusivity.jl @@ -209,7 +209,8 @@ function compute_diffusivities!(diffusivities, closure::FlavorOfCATKE, model; launch!(arch, grid, parameters, compute_CATKE_diffusivities!, - diffusivities, grid, closure, velocities, tracers, buoyancy) + diffusivities, grid, closure, velocities, tracers, buoyancy; + active_cells_map) return nothing end diff --git a/src/TurbulenceClosures/turbulence_closure_implementations/TKEBasedVerticalDiffusivities/tke_dissipation_vertical_diffusivity.jl b/src/TurbulenceClosures/turbulence_closure_implementations/TKEBasedVerticalDiffusivities/tke_dissipation_vertical_diffusivity.jl index d94035e507..6fd0b00034 100644 --- a/src/TurbulenceClosures/turbulence_closure_implementations/TKEBasedVerticalDiffusivities/tke_dissipation_vertical_diffusivity.jl +++ b/src/TurbulenceClosures/turbulence_closure_implementations/TKEBasedVerticalDiffusivities/tke_dissipation_vertical_diffusivity.jl @@ -191,7 +191,7 @@ end @inline viscosity_location(::FlavorOfTD) = (c, c, f) @inline diffusivity_location(::FlavorOfTD) = (c, c, f) -function compute_diffusivities!(diffusivities, closure::FlavorOfTD, model; parameters = :xyz) +function compute_diffusivities!(diffusivities, closure::FlavorOfTD, model; parameters = :xyz, active_cells_map = nothing) arch = model.architecture grid = model.grid @@ -216,7 +216,8 @@ function compute_diffusivities!(diffusivities, closure::FlavorOfTD, model; param launch!(arch, grid, parameters, compute_TKEDissipation_diffusivities!, - diffusivities, grid, closure, velocities, tracers, buoyancy) + diffusivities, grid, closure, velocities, tracers, buoyancy; + active_cells_map) return nothing end diff --git a/src/TurbulenceClosures/turbulence_closure_implementations/anisotropic_minimum_dissipation.jl b/src/TurbulenceClosures/turbulence_closure_implementations/anisotropic_minimum_dissipation.jl index 390c96555b..eeba883a79 100644 --- a/src/TurbulenceClosures/turbulence_closure_implementations/anisotropic_minimum_dissipation.jl +++ b/src/TurbulenceClosures/turbulence_closure_implementations/anisotropic_minimum_dissipation.jl @@ -188,7 +188,7 @@ end @inbounds κₑ[i, j, k] = max(zero(FT), κˢᵍˢ) end -function compute_diffusivities!(diffusivity_fields, closure::AnisotropicMinimumDissipation, model; parameters = :xyz) +function compute_diffusivities!(diffusivity_fields, closure::AnisotropicMinimumDissipation, model; parameters=:xyz, active_cells_map=nothing) grid = model.grid arch = model.architecture velocities = model.velocities @@ -201,7 +201,7 @@ function compute_diffusivities!(diffusivity_fields, closure::AnisotropicMinimumD for (tracer_index, κₑ) in enumerate(diffusivity_fields.κₑ) @inbounds tracer = tracers[tracer_index] launch!(arch, grid, parameters, _compute_AMD_diffusivity!, - κₑ, grid, closure, tracer, Val(tracer_index), velocities) + κₑ, grid, closure, tracer, Val(tracer_index), velocities; active_cells_map) end return nothing diff --git a/src/TurbulenceClosures/turbulence_closure_implementations/convective_adjustment_vertical_diffusivity.jl b/src/TurbulenceClosures/turbulence_closure_implementations/convective_adjustment_vertical_diffusivity.jl index cfdd407523..9c7dd578cb 100644 --- a/src/TurbulenceClosures/turbulence_closure_implementations/convective_adjustment_vertical_diffusivity.jl +++ b/src/TurbulenceClosures/turbulence_closure_implementations/convective_adjustment_vertical_diffusivity.jl @@ -88,7 +88,7 @@ DiffusivityFields(grid, tracer_names, bcs, closure::FlavorOfCAVD) = (; κᶜ = Z @inline viscosity(::FlavorOfCAVD, diffusivities) = diffusivities.κᵘ @inline diffusivity(::FlavorOfCAVD, diffusivities, id) = diffusivities.κᶜ -function compute_diffusivities!(diffusivities, closure::FlavorOfCAVD, model; parameters = :xyz) +function compute_diffusivities!(diffusivities, closure::FlavorOfCAVD, model; parameters=:xyz, active_cells_map=nothing) arch = model.architecture grid = model.grid @@ -98,7 +98,7 @@ function compute_diffusivities!(diffusivities, closure::FlavorOfCAVD, model; par launch!(arch, grid, parameters, ## If we can figure out how to only precompute the "stability" of a cell: # compute_stability!, diffusivities, grid, closure, tracers, buoyancy, - compute_convective_adjustment_diffusivities!, diffusivities, grid, closure, tracers, buoyancy) + compute_convective_adjustment_diffusivities!, diffusivities, grid, closure, tracers, buoyancy, active_cells_map) return nothing end diff --git a/src/TurbulenceClosures/turbulence_closure_implementations/isopycnal_skew_symmetric_diffusivity.jl b/src/TurbulenceClosures/turbulence_closure_implementations/isopycnal_skew_symmetric_diffusivity.jl index 87f6ceff5f..7267d20cda 100644 --- a/src/TurbulenceClosures/turbulence_closure_implementations/isopycnal_skew_symmetric_diffusivity.jl +++ b/src/TurbulenceClosures/turbulence_closure_implementations/isopycnal_skew_symmetric_diffusivity.jl @@ -81,7 +81,7 @@ function DiffusivityFields(grid, tracer_names, bcs, closure::FlavorOfISSD{TD}) w end end -function compute_diffusivities!(diffusivities, closure::FlavorOfISSD, model; parameters = :xyz) +function compute_diffusivities!(diffusivities, closure::FlavorOfISSD, model; parameters = :xyz, active_cells_map = nothing) arch = model.architecture grid = model.grid @@ -89,7 +89,7 @@ function compute_diffusivities!(diffusivities, closure::FlavorOfISSD, model; par buoyancy = model.buoyancy launch!(arch, grid, parameters, - compute_tapered_R₃₃!, diffusivities.ϵ_R₃₃, grid, closure, tracers, buoyancy) + compute_tapered_R₃₃!, diffusivities.ϵ_R₃₃, grid, closure, tracers, buoyancy; active_cells_map) return nothing end diff --git a/src/TurbulenceClosures/turbulence_closure_implementations/leith_enstrophy_diffusivity.jl b/src/TurbulenceClosures/turbulence_closure_implementations/leith_enstrophy_diffusivity.jl index f640990ca6..7b87ffc1da 100644 --- a/src/TurbulenceClosures/turbulence_closure_implementations/leith_enstrophy_diffusivity.jl +++ b/src/TurbulenceClosures/turbulence_closure_implementations/leith_enstrophy_diffusivity.jl @@ -91,7 +91,7 @@ end @inbounds νₑ[i, j, k] = prefactor * dynamic_ν end -function compute_diffusivities!(diffusivity_fields, closure::TwoDimensionalLeith, model; parameters = :xyz) +function compute_diffusivities!(diffusivity_fields, closure::TwoDimensionalLeith, model; parameters=:xyz, active_cells_map=nothing) arch = model.architecture grid = model.grid velocities = model.velocities @@ -99,7 +99,7 @@ function compute_diffusivities!(diffusivity_fields, closure::TwoDimensionalLeith buoyancy = model.buoyancy launch!(arch, grid, parameters, _compute_leith_viscosity!, - diffusivity_fields.νₑ, grid, closure, buoyancy, velocities, tracers) + diffusivity_fields.νₑ, grid, closure, buoyancy, velocities, tracers; active_cells_map) return nothing end diff --git a/src/TurbulenceClosures/turbulence_closure_implementations/ri_based_vertical_diffusivity.jl b/src/TurbulenceClosures/turbulence_closure_implementations/ri_based_vertical_diffusivity.jl index 2d4b7bb2eb..cbef53feb3 100644 --- a/src/TurbulenceClosures/turbulence_closure_implementations/ri_based_vertical_diffusivity.jl +++ b/src/TurbulenceClosures/turbulence_closure_implementations/ri_based_vertical_diffusivity.jl @@ -190,7 +190,7 @@ function DiffusivityFields(grid, tracer_names, bcs, closure::FlavorOfRBVD) return (; κc, κu, Ri) end -function compute_diffusivities!(diffusivities, closure::FlavorOfRBVD, model; parameters = :xyz) +function compute_diffusivities!(diffusivities, closure::FlavorOfRBVD, model; parameters = :xyz, active_cells_map = nothing) arch = model.architecture grid = model.grid clock = model.clock @@ -208,7 +208,8 @@ function compute_diffusivities!(diffusivities, closure::FlavorOfRBVD, model; par tracers, buoyancy, top_tracer_bcs, - clock) + clock; + active_cells_map) # Use `only_local_halos` to ensure that no communication occurs during # this call to fill_halo_regions! @@ -223,7 +224,8 @@ function compute_diffusivities!(diffusivities, closure::FlavorOfRBVD, model; par tracers, buoyancy, top_tracer_bcs, - clock) + clock; + active_cells_map) return nothing end diff --git a/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl b/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl index 003fabbeea..56f866c319 100644 --- a/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl +++ b/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl @@ -101,7 +101,7 @@ end @inline viscosity(closure::ScalarBiharmonicDiffusivity, K) = closure.ν @inline diffusivity(closure::ScalarBiharmonicDiffusivity, K, ::Val{id}) where id = closure.κ[id] -compute_diffusivities!(diffusivities, closure::ScalarBiharmonicDiffusivity, args...) = nothing +compute_diffusivities!(diffusivities, closure::ScalarBiharmonicDiffusivity, args...; kwargs...) = nothing function Base.summary(closure::ScalarBiharmonicDiffusivity) F = summary(formulation(closure)) diff --git a/src/TurbulenceClosures/turbulence_closure_implementations/scalar_diffusivity.jl b/src/TurbulenceClosures/turbulence_closure_implementations/scalar_diffusivity.jl index a4f85814b8..6573fe08c1 100644 --- a/src/TurbulenceClosures/turbulence_closure_implementations/scalar_diffusivity.jl +++ b/src/TurbulenceClosures/turbulence_closure_implementations/scalar_diffusivity.jl @@ -192,7 +192,7 @@ end @inline viscosity(closure::ScalarDiffusivity, K) = closure.ν @inline diffusivity(closure::ScalarDiffusivity, K, ::Val{id}) where id = closure.κ[id] -compute_diffusivities!(diffusivities, ::ScalarDiffusivity, args...) = nothing +compute_diffusivities!(diffusivities, ::ScalarDiffusivity, args...; kwargs...) = nothing # Note: we could compute ν and κ (if they are Field): # function compute_diffusivities!(diffusivities, closure::ScalarDiffusivity, args...) diff --git a/test/test_distributed_hydrostatic_model.jl b/test/test_distributed_hydrostatic_model.jl index c11d3c5248..a84f6523d3 100644 --- a/test/test_distributed_hydrostatic_model.jl +++ b/test/test_distributed_hydrostatic_model.jl @@ -94,7 +94,7 @@ for arch in archs global_underlying_grid = reconstruct_global_grid(underlying_grid) global_immersed_grid = ImmersedBoundaryGrid(global_underlying_grid, GridFittedBottom(bottom)) - for (grid, global_grid) in zip((underlying_grid, immersed_grid, immersed_active_grid), (global_underlying_grid, global_immersed_grid, global_immersed_grid)) + for (grid, global_grid) in zip((immersed_active_grid, immersed_grid), (global_immersed_grid, global_immersed_grid)) # "s" for "serial" computation us, vs, ws, cs, ηs = solid_body_rotation_test(global_grid) From c8469ba3bbb6fc1bcf1d5b90bd6d38ae9b676280 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Tue, 10 Dec 2024 12:54:48 +0100 Subject: [PATCH 30/60] try this for the moment --- .../step_split_explicit_free_surface.jl | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl index 25a74c59c0..582ed63d8e 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl @@ -70,10 +70,8 @@ function iterate_split_explicit!(free_surface, grid, GUⁿ, GVⁿ, Δτᴮ, weig U, V = free_surface.barotropic_velocities η̅, U̅, V̅ = state.η, state.U, state.V - active_cells_map = retrieve_surface_active_cells_map(grid) - - η_kernel!, _ = configure_kernel(arch, grid, parameters, _split_explicit_free_surface!; active_cells_map) - U_kernel!, _ = configure_kernel(arch, grid, parameters, _split_explicit_barotropic_velocity!; active_cells_map) + η_kernel!, _ = configure_kernel(arch, grid, parameters, _split_explicit_free_surface!) + U_kernel!, _ = configure_kernel(arch, grid, parameters, _split_explicit_barotropic_velocity!) η_args = (grid, Δτᴮ, η, U, V, timestepper) @@ -91,18 +89,12 @@ function iterate_split_explicit!(free_surface, grid, GUⁿ, GVⁿ, Δτᴮ, weig converted_η_args = convert_args(arch, η_args) converted_U_args = convert_args(arch, U_args) - # We convert the kernels for the same reason (they might contain a surface map) - GC.@preserve η_kernel! U_kernel! begin - - converted_η_kernel! = convert_args(arch, η_kernel!) - converted_U_kernel! = convert_args(arch, U_kernel!) - @unroll for substep in 1:Nsubsteps - Base.@_inline_meta - averaging_weight = weights[substep] - η_kernel!(converted_η_args...) - U_kernel!(averaging_weight, converted_U_args...) - end + @unroll for substep in 1:Nsubsteps + Base.@_inline_meta + averaging_weight = weights[substep] + η_kernel!(converted_η_args...) + U_kernel!(averaging_weight, converted_U_args...) end end From 4373ec15ee3e39e23c53ad615583041ea69ff292 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Tue, 10 Dec 2024 13:16:02 +0100 Subject: [PATCH 31/60] remove all duplication --- .../step_split_explicit_free_surface.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl index 582ed63d8e..cad93e93d1 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl @@ -89,7 +89,6 @@ function iterate_split_explicit!(free_surface, grid, GUⁿ, GVⁿ, Δτᴮ, weig converted_η_args = convert_args(arch, η_args) converted_U_args = convert_args(arch, U_args) - @unroll for substep in 1:Nsubsteps Base.@_inline_meta averaging_weight = weights[substep] From 9b3c161545f3b91e9d052e05de332fe9a7b3b757 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Tue, 10 Dec 2024 13:16:09 +0100 Subject: [PATCH 32/60] remove all duplication --- .../barotropic_split_explicit_corrector.jl | 13 ++--------- .../compute_slow_tendencies.jl | 23 ++++--------------- .../step_split_explicit_free_surface.jl | 1 + src/Utils/kernel_launching.jl | 4 ++-- test/test_distributed_hydrostatic_model.jl | 5 ++-- 5 files changed, 11 insertions(+), 35 deletions(-) diff --git a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/barotropic_split_explicit_corrector.jl b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/barotropic_split_explicit_corrector.jl index 2b7f7845f6..b9c734a75f 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/barotropic_split_explicit_corrector.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/barotropic_split_explicit_corrector.jl @@ -1,16 +1,7 @@ # Kernels to compute the vertical integral of the velocities -@kernel function _barotropic_mode_kernel!(U, V, grid, ::Nothing, u, v) +@kernel function _barotropic_mode_kernel!(U, V, grid, u, v) i, j = @index(Global, NTuple) - barotropic_mode_kernel!(U, V, i, j, grid, u, v) -end - -@kernel function _barotropic_mode_kernel!(U, V, grid, active_cells_map, u, v) - idx = @index(Global, Linear) - i, j = active_linear_index_to_tuple(idx, active_cells_map) - barotropic_mode_kernel!(U, V, i, j, grid, u, v) -end -@inline function barotropic_mode_kernel!(U, V, i, j, grid, u, v) @inbounds U[i, j, 1] = Δzᶠᶜᶜ(i, j, 1, grid) * u[i, j, 1] @inbounds V[i, j, 1] = Δzᶜᶠᶜ(i, j, 1, grid) * v[i, j, 1] @@ -24,7 +15,7 @@ end @inline function compute_barotropic_mode!(U, V, grid, u, v) active_cells_map = retrieve_surface_active_cells_map(grid) - launch!(architecture(grid), grid, :xy, _barotropic_mode_kernel!, U, V, grid, active_cells_map, u, v; active_cells_map) + launch!(architecture(grid), grid, :xy, _barotropic_mode_kernel!, U, V, grid, u, v; active_cells_map) return nothing end diff --git a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/compute_slow_tendencies.jl b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/compute_slow_tendencies.jl index 30f327ed20..e22413e323 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/compute_slow_tendencies.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/compute_slow_tendencies.jl @@ -3,18 +3,9 @@ ##### # Calculate RHS for the barotropic time step. -@kernel function _compute_integrated_ab2_tendencies!(Gᵁ, Gⱽ, grid, ::Nothing, Gu⁻, Gv⁻, Guⁿ, Gvⁿ, χ) +@kernel function _compute_integrated_ab2_tendencies!(Gᵁ, Gⱽ, grid, Gu⁻, Gv⁻, Guⁿ, Gvⁿ, χ) i, j = @index(Global, NTuple) - ab2_integrate_tendencies!(Gᵁ, Gⱽ, i, j, grid, Gu⁻, Gv⁻, Guⁿ, Gvⁿ, χ) -end - -@kernel function _compute_integrated_ab2_tendencies!(Gᵁ, Gⱽ, grid, active_cells_map, Gu⁻, Gv⁻, Guⁿ, Gvⁿ, χ) - idx = @index(Global, Linear) - i, j = active_linear_index_to_tuple(idx, active_cells_map) - ab2_integrate_tendencies!(Gᵁ, Gⱽ, i, j, grid, Gu⁻, Gv⁻, Guⁿ, Gvⁿ, χ) -end -@inline function ab2_integrate_tendencies!(Gᵁ, Gⱽ, i, j, grid, Gu⁻, Gv⁻, Guⁿ, Gvⁿ, χ) locU = (Face(), Center(), Center()) locV = (Center(), Face(), Center()) @@ -49,7 +40,7 @@ end Gv⁻ = timestepper.G⁻.v launch!(architecture(grid), grid, :xy, _compute_integrated_ab2_tendencies!, GUⁿ, GVⁿ, grid, - active_cells_map, Gu⁻, Gv⁻, Guⁿ, Gvⁿ, timestepper.χ; active_cells_map) + Gu⁻, Gv⁻, Guⁿ, Gvⁿ, timestepper.χ; active_cells_map) return nothing end @@ -71,13 +62,7 @@ end return Gⁿ⁺¹ end -@kernel function _compute_integrated_rk3_tendencies!(GUⁿ, GVⁿ, GU⁻, GV⁻, grid, active_cells_map, Guⁿ, Gvⁿ, stage) - idx = @index(Global, Linear) - i, j = active_linear_index_to_tuple(idx, active_cells_map) - compute_integrated_rk3_tendencies!(GUⁿ, GVⁿ, GU⁻, GV⁻, i, j, grid, Guⁿ, Gvⁿ, stage) -end - -@kernel function _compute_integrated_rk3_tendencies!(GUⁿ, GVⁿ, GU⁻, GV⁻, grid, ::Nothing, Guⁿ, Gvⁿ, stage) +@kernel function _compute_integrated_rk3_tendencies!(GUⁿ, GVⁿ, GU⁻, GV⁻, grid, Guⁿ, Gvⁿ, stage) i, j = @index(Global, NTuple) compute_integrated_rk3_tendencies!(GUⁿ, GVⁿ, GU⁻, GV⁻, i, j, grid, Guⁿ, Gvⁿ, stage) end @@ -118,7 +103,7 @@ end active_cells_map = retrieve_surface_active_cells_map(grid) launch!(architecture(grid), grid, :xy, _compute_integrated_rk3_tendencies!, - GUⁿ, GVⁿ, GU⁻, GV⁻, grid, active_cells_map, Guⁿ, Gvⁿ, stage; active_cells_map) + GUⁿ, GVⁿ, GU⁻, GV⁻, grid, Guⁿ, Gvⁿ, stage; active_cells_map) return nothing end diff --git a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl index cad93e93d1..582ed63d8e 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl @@ -89,6 +89,7 @@ function iterate_split_explicit!(free_surface, grid, GUⁿ, GVⁿ, Δτᴮ, weig converted_η_args = convert_args(arch, η_args) converted_U_args = convert_args(arch, U_args) + @unroll for substep in 1:Nsubsteps Base.@_inline_meta averaging_weight = weights[substep] diff --git a/src/Utils/kernel_launching.jl b/src/Utils/kernel_launching.jl index eccdef2803..670b05c91b 100644 --- a/src/Utils/kernel_launching.jl +++ b/src/Utils/kernel_launching.jl @@ -508,8 +508,8 @@ end @inline function __validindex(ctx::MappedCompilerMetadata, idx::CartesianIndex) # Turns this into a noop for code where we can turn of checkbounds of if __dynamic_checkbounds(ctx) - index = @inbounds linear_index(__iterspace(ctx), __groupindex(ctx), idx) - return index ≤ linear_ndrange(ctx) + # index = @inbounds linear_index(__iterspace(ctx), __groupindex(ctx), idx) + return true # index ≤ linear_ndrange(ctx) else return true end diff --git a/test/test_distributed_hydrostatic_model.jl b/test/test_distributed_hydrostatic_model.jl index a84f6523d3..7c2689ab99 100644 --- a/test/test_distributed_hydrostatic_model.jl +++ b/test/test_distributed_hydrostatic_model.jl @@ -95,6 +95,8 @@ for arch in archs global_immersed_grid = ImmersedBoundaryGrid(global_underlying_grid, GridFittedBottom(bottom)) for (grid, global_grid) in zip((immersed_active_grid, immersed_grid), (global_immersed_grid, global_immersed_grid)) + @info " Testing distributed solid body rotation with architecture $arch on $(typeof(grid).name.wrapper)" + u, v, w, c, η = solid_body_rotation_test(grid) # "s" for "serial" computation us, vs, ws, cs, ηs = solid_body_rotation_test(global_grid) @@ -105,9 +107,6 @@ for arch in archs cs = interior(on_architecture(CPU(), cs)) ηs = interior(on_architecture(CPU(), ηs)) - @info " Testing distributed solid body rotation with architecture $arch on $(typeof(grid).name.wrapper)" - u, v, w, c, η = solid_body_rotation_test(grid) - cpu_arch = cpu_architecture(arch) u = interior(on_architecture(cpu_arch, u)) From ae6f6e322107db65a09b0350944e1c33e8d3f3d4 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Tue, 10 Dec 2024 14:22:00 +0100 Subject: [PATCH 33/60] add more stuff --- .../barotropic_split_explicit_corrector.jl | 2 - .../step_split_explicit_free_surface.jl | 22 +++-- src/Utils/kernel_launching.jl | 23 +++-- test/test_active_cells_map.jl | 91 +++++++++++++++++++ 4 files changed, 119 insertions(+), 19 deletions(-) create mode 100644 test/test_active_cells_map.jl diff --git a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/barotropic_split_explicit_corrector.jl b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/barotropic_split_explicit_corrector.jl index b9c734a75f..7baf568060 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/barotropic_split_explicit_corrector.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/barotropic_split_explicit_corrector.jl @@ -9,8 +9,6 @@ @inbounds U[i, j, 1] += Δzᶠᶜᶜ(i, j, k, grid) * u[i, j, k] @inbounds V[i, j, 1] += Δzᶜᶠᶜ(i, j, k, grid) * v[i, j, k] end - - return nothing end @inline function compute_barotropic_mode!(U, V, grid, u, v) diff --git a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl index 582ed63d8e..25a74c59c0 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl @@ -70,8 +70,10 @@ function iterate_split_explicit!(free_surface, grid, GUⁿ, GVⁿ, Δτᴮ, weig U, V = free_surface.barotropic_velocities η̅, U̅, V̅ = state.η, state.U, state.V - η_kernel!, _ = configure_kernel(arch, grid, parameters, _split_explicit_free_surface!) - U_kernel!, _ = configure_kernel(arch, grid, parameters, _split_explicit_barotropic_velocity!) + active_cells_map = retrieve_surface_active_cells_map(grid) + + η_kernel!, _ = configure_kernel(arch, grid, parameters, _split_explicit_free_surface!; active_cells_map) + U_kernel!, _ = configure_kernel(arch, grid, parameters, _split_explicit_barotropic_velocity!; active_cells_map) η_args = (grid, Δτᴮ, η, U, V, timestepper) @@ -89,12 +91,18 @@ function iterate_split_explicit!(free_surface, grid, GUⁿ, GVⁿ, Δτᴮ, weig converted_η_args = convert_args(arch, η_args) converted_U_args = convert_args(arch, U_args) + # We convert the kernels for the same reason (they might contain a surface map) + GC.@preserve η_kernel! U_kernel! begin + + converted_η_kernel! = convert_args(arch, η_kernel!) + converted_U_kernel! = convert_args(arch, U_kernel!) - @unroll for substep in 1:Nsubsteps - Base.@_inline_meta - averaging_weight = weights[substep] - η_kernel!(converted_η_args...) - U_kernel!(averaging_weight, converted_U_args...) + @unroll for substep in 1:Nsubsteps + Base.@_inline_meta + averaging_weight = weights[substep] + η_kernel!(converted_η_args...) + U_kernel!(averaging_weight, converted_U_args...) + end end end diff --git a/src/Utils/kernel_launching.jl b/src/Utils/kernel_launching.jl index 670b05c91b..8fc927efee 100644 --- a/src/Utils/kernel_launching.jl +++ b/src/Utils/kernel_launching.jl @@ -493,24 +493,27 @@ import KernelAbstractions: __validindex const MappedCompilerMetadata = CompilerMetadata{<:StaticSize, <:Any, <:Any, <:Any, <:MappedNDRange} -@inline linear_ndrange(cm::MappedCompilerMetadata) = length(cm.ndrange.workitems) +@inline linear_ndrange(ctx::MappedCompilerMetadata) = length(__iterspace(ctx).workitems) # Mapped kernels are always 1D @inline function linear_index(ndrange::MappedNDRange, groupidx::CartesianIndex{N}, idx::CartesianIndex{N}) where N - offsets = workitems(ndrange) - stride = size(offsets, 1) - gidx = groupidx.I[1] - return (gidx - 1) * stride + idx.I[1] + nI = Base.@_inline_meta begin + offsets = workitems(ndrange) + stride = size(offsets, 1) + gidx = groupidx.I[1] + (gidx - 1) * stride + idx.I[1] + end + return nI end -# instead to check whether the index is valid in the index map, we need to -# check whether the index is valid by checking the size of the index map +# To check whether the index is valid in the index map, we need to +# check whether the linear index is smaller than the size of the index map @inline function __validindex(ctx::MappedCompilerMetadata, idx::CartesianIndex) # Turns this into a noop for code where we can turn of checkbounds of if __dynamic_checkbounds(ctx) - # index = @inbounds linear_index(__iterspace(ctx), __groupindex(ctx), idx) - return true # index ≤ linear_ndrange(ctx) + index = @inbounds linear_index(__iterspace(ctx), __groupindex(ctx), idx) + return index ≤ linear_ndrange(ctx) else - return true + return false end end \ No newline at end of file diff --git a/test/test_active_cells_map.jl b/test/test_active_cells_map.jl new file mode 100644 index 0000000000..eb1fc78d45 --- /dev/null +++ b/test/test_active_cells_map.jl @@ -0,0 +1,91 @@ +include("dependencies_for_runtests.jl") + +using Oceananigans.Operators: hack_cosd + +function Δ_min(grid) + Δx_min = minimum_xspacing(grid, Center(), Center(), Center()) + Δy_min = minimum_yspacing(grid, Center(), Center(), Center()) + return min(Δx_min, Δy_min) +end + +@inline Gaussian(x, y, L) = exp(-(x^2 + y^2) / L^2) + +function solid_body_rotation_test(grid) + + free_surface = SplitExplicitFreeSurface(grid; substeps = 5, gravitational_acceleration = 1) + coriolis = HydrostaticSphericalCoriolis(rotation_rate = 1) + + model = HydrostaticFreeSurfaceModel(; grid, + momentum_advection = VectorInvariant(), + free_surface = free_surface, + coriolis = coriolis, + tracers = :c, + tracer_advection = WENO(), + buoyancy = nothing, + closure = nothing) + + g = model.free_surface.gravitational_acceleration + R = grid.radius + Ω = model.coriolis.rotation_rate + + uᵢ(λ, φ, z) = 0.1 * cosd(φ) * sind(λ) + ηᵢ(λ, φ, z) = (R * Ω * 0.1 + 0.1^2 / 2) * sind(φ)^2 / g * sind(λ) + + # Gaussian leads to values with O(1e-60), + # too small for repetible testing. We cap it at 0.1 + cᵢ(λ, φ, z) = max(Gaussian(λ, φ - 5, 10), 0.1) + vᵢ(λ, φ, z) = 0.1 + + set!(model, u=uᵢ, η=ηᵢ, c=cᵢ) + + Δt = 0.1 * Δ_min(grid) / sqrt(g * grid.Lz) + + simulation = Simulation(model; Δt, stop_iteration = 10) + run!(simulation) + + return merge(model.velocities, model.tracers, (; η = model.free_surface.η)) +end + +Nx = 32 +Ny = 32 + +for arch in archs + @testset "Active cells map solid body rotation" begin + underlying_grid = LatitudeLongitudeGrid(arch, size = (Nx, Ny, 10), + halo = (4, 4, 4), + latitude = (-80, 80), + longitude = (-160, 160), + z = (-10, 0), + radius = 1, + topology=(Bounded, Bounded, Bounded)) + + bottom(λ, φ) = - rand() * 5 - 5 + + immersed_grid = ImmersedBoundaryGrid(underlying_grid, GridFittedBottom(bottom)) + immersed_active_grid = ImmersedBoundaryGrid(underlying_grid, GridFittedBottom(bottom); active_cells_map = true) + + ua, va, wa, ca, ηa = solid_body_rotation_test(immersed_active_grid) + u, v, w, c, η = solid_body_rotation_test(immersed_grid) + + ua = interior(on_architecture(CPU(), ua)) + va = interior(on_architecture(CPU(), va)) + wa = interior(on_architecture(CPU(), wa)) + ca = interior(on_architecture(CPU(), ca)) + ηa = interior(on_architecture(CPU(), ηa)) + + u = interior(on_architecture(CPU(), u)) + v = interior(on_architecture(CPU(), v)) + w = interior(on_architecture(CPU(), w)) + c = interior(on_architecture(CPU(), c)) + η = interior(on_architecture(CPU(), η)) + + atol = eps(eltype(immersed_grid)) + rtol = sqrt(eps(eltype(immersed_grid))) + + @test all(isapprox(u, ua; atol, rtol)) + @test all(isapprox(v, va; atol, rtol)) + @test all(isapprox(w, wa; atol, rtol)) + @test all(isapprox(c, ca; atol, rtol)) + @test all(isapprox(η, ηa; atol, rtol)) + end +end From ff80a8eadbfb14f1b163d90123034da503482fa7 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Tue, 10 Dec 2024 14:40:14 +0100 Subject: [PATCH 34/60] better --- test/test_active_cells_map.jl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/test_active_cells_map.jl b/test/test_active_cells_map.jl index eb1fc78d45..da9fccdfd6 100644 --- a/test/test_active_cells_map.jl +++ b/test/test_active_cells_map.jl @@ -59,10 +59,14 @@ for arch in archs radius = 1, topology=(Bounded, Bounded, Bounded)) - bottom(λ, φ) = - rand() * 5 - 5 - - immersed_grid = ImmersedBoundaryGrid(underlying_grid, GridFittedBottom(bottom)) - immersed_active_grid = ImmersedBoundaryGrid(underlying_grid, GridFittedBottom(bottom); active_cells_map = true) + # Make sure the bottom is the same + bottom_height = zeros(Nx, Ny) + for i in 1:Nx, j in 1:Ny + bottom_height[i, j] = - rand() * 5 - 5 + end + + immersed_grid = ImmersedBoundaryGrid(underlying_grid, GridFittedBottom(bottom_height)) + immersed_active_grid = ImmersedBoundaryGrid(underlying_grid, GridFittedBottom(bottom_height); active_cells_map = true) ua, va, wa, ca, ηa = solid_body_rotation_test(immersed_active_grid) u, v, w, c, η = solid_body_rotation_test(immersed_grid) From f9ae12e4a9b08f185f56cada39efe119d0675e0d Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Wed, 11 Dec 2024 11:04:10 +0100 Subject: [PATCH 35/60] try new test --- ...nterleave_communication_and_computation.jl | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/Models/interleave_communication_and_computation.jl b/src/Models/interleave_communication_and_computation.jl index 55dc8aae44..0ad01c2d57 100644 --- a/src/Models/interleave_communication_and_computation.jl +++ b/src/Models/interleave_communication_and_computation.jl @@ -26,8 +26,15 @@ complete_communication_and_compute_buffer!(model, grid, arch) = nothing compute_buffer_tendencies!(model) = nothing """ Kernel parameters for computing interior tendencies. """ -interior_tendency_kernel_parameters(arch, grid) = :xyz # fallback -interior_tendency_kernel_parameters(::SynchronizedDistributed, grid) = :xyz +function interior_tendency_kernel_parameters(arch, grid) + Nx, Ny, Nz = size(grid) + return KernelParameters(0:Nx+1, 0:Ny+1, 1:Nz) +end + +function interior_tendency_kernel_parameters(::SynchronizedDistributed, grid) + Nx, Ny, Nz = size(grid) + return KernelParameters(0:Nx+1, 0:Ny+1, 1:Nz) +end function interior_parameters_without_halo(arch, grid) Rx, Ry, _ = arch.ranks @@ -44,24 +51,24 @@ function interior_parameters_without_halo(arch, grid) # Sizes Sx = if local_x - Nx + Nx + 2 elseif one_sided_x - Nx - Hx + 1 + Nx - Hx + 2 else # two sided Nx - 2Hx + 2 end Sy = if local_y - Ny + Ny + 2 elseif one_sided_y - Ny - Hy + 1 + Ny - Hy + 2 else # two sided Ny - 2Hy + 2 end # Offsets - Ox = Rx == 1 || Tx == RightConnected ? 0 : Hx - 1 - Oy = Ry == 1 || Ty == RightConnected ? 0 : Hy - 1 + Ox = Rx == 1 || Tx == RightConnected ? -1 : Hx-1 + Oy = Ry == 1 || Ty == RightConnected ? -1 : Hy-1 sizes = (Sx, Sy, Nz) offsets = (Ox, Oy, 0) From af143aa9d4d917d17fde8551acc8e3f7398ad6f5 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Wed, 11 Dec 2024 11:08:41 +0100 Subject: [PATCH 36/60] This works, we optimize performance later --- src/BoundaryConditions/fill_halo_regions.jl | 4 +- .../distributed_immersed_boundaries.jl | 31 +++++----- src/ImmersedBoundaries/active_cells_map.jl | 11 +--- .../step_split_explicit_free_surface.jl | 23 +++----- ...ompute_hydrostatic_free_surface_buffers.jl | 56 ++++++++++++------- .../compute_w_from_continuity.jl | 22 +++++++- ...te_hydrostatic_free_surface_model_state.jl | 17 +++--- ...ompute_nonhydrostatic_buffer_tendencies.jl | 55 +++++++++++------- .../update_hydrostatic_pressure.jl | 4 +- .../update_nonhydrostatic_model_state.jl | 17 +++--- ...nterleave_communication_and_computation.jl | 55 ++++-------------- .../Smagorinskys/smagorinsky.jl | 4 +- .../catke_vertical_diffusivity.jl | 8 +-- .../time_step_catke_equation.jl | 6 +- .../tke_dissipation_vertical_diffusivity.jl | 5 +- .../anisotropic_minimum_dissipation.jl | 4 +- ...vective_adjustment_vertical_diffusivity.jl | 4 +- .../isopycnal_skew_symmetric_diffusivity.jl | 4 +- .../leith_enstrophy_diffusivity.jl | 4 +- .../ri_based_vertical_diffusivity.jl | 8 +-- .../scalar_biharmonic_diffusivity.jl | 2 +- .../scalar_diffusivity.jl | 2 +- 22 files changed, 166 insertions(+), 180 deletions(-) diff --git a/src/BoundaryConditions/fill_halo_regions.jl b/src/BoundaryConditions/fill_halo_regions.jl index ad2b6d1558..7ac3e79ea5 100644 --- a/src/BoundaryConditions/fill_halo_regions.jl +++ b/src/BoundaryConditions/fill_halo_regions.jl @@ -46,9 +46,7 @@ const MaybeTupledData = Union{OffsetArray, NTuple{<:Any, OffsetArray}} "Fill halo regions in ``x``, ``y``, and ``z`` for a given field's data." function fill_halo_regions!(c::MaybeTupledData, boundary_conditions, indices, loc, grid, args...; - fill_boundary_normal_velocities = true, - kwargs...) - + fill_boundary_normal_velocities = true, kwargs...) arch = architecture(grid) if fill_boundary_normal_velocities diff --git a/src/DistributedComputations/distributed_immersed_boundaries.jl b/src/DistributedComputations/distributed_immersed_boundaries.jl index 001c0626e3..01ffb3d67b 100644 --- a/src/DistributedComputations/distributed_immersed_boundaries.jl +++ b/src/DistributedComputations/distributed_immersed_boundaries.jl @@ -121,31 +121,28 @@ function map_interior_active_cells(ibg::ImmersedBoundaryGrid{<:Any, <:Any, <:Any Nx, Ny, Nz = size(ibg) Hx, Hy, _ = halo_size(ibg) - west_boundary = (0:Hx, 1:Ny, 1:Nz) - east_boundary = (Nx-Hx+1:Nx+1, 1:Ny, 1:Nz) - south_boundary = (1:Nx, 0:Hy, 1:Nz) - north_boundary = (1:Nx, Ny-Hy+1:Ny+1, 1:Nz) + x_boundary = (Hx, Ny, Nz) + y_boundary = (Nx, Hy, Nz) + + left_offsets = (0, 0, 0) + right_x_offsets = (Nx-Hx, 0, 0) + right_y_offsets = (0, Ny-Hy, 0) include_west = !isa(ibg, XFlatGrid) && (Rx != 1) && !(Tx == RightConnected) include_east = !isa(ibg, XFlatGrid) && (Rx != 1) && !(Tx == LeftConnected) include_south = !isa(ibg, YFlatGrid) && (Ry != 1) && !(Ty == RightConnected) include_north = !isa(ibg, YFlatGrid) && (Ry != 1) && !(Ty == LeftConnected) - west_halo_dependent_cells = interior_active_indices(ibg; parameters = KernelParameters(west_boundary)) - east_halo_dependent_cells = interior_active_indices(ibg; parameters = KernelParameters(east_boundary)) - south_halo_dependent_cells = interior_active_indices(ibg; parameters = KernelParameters(south_boundary)) - north_halo_dependent_cells = interior_active_indices(ibg; parameters = KernelParameters(north_boundary)) - - west_halo_dependent_cells = ifelse(include_west , west_halo_dependent_cells , nothing) - east_halo_dependent_cells = ifelse(include_east , east_halo_dependent_cells , nothing) - south_halo_dependent_cells = ifelse(include_south, south_halo_dependent_cells, nothing) - north_halo_dependent_cells = ifelse(include_north, north_halo_dependent_cells, nothing) + west_halo_dependent_cells = include_west ? interior_active_indices(ibg; parameters = KernelParameters(x_boundary, left_offsets)) : nothing + east_halo_dependent_cells = include_east ? interior_active_indices(ibg; parameters = KernelParameters(x_boundary, right_x_offsets)) : nothing + south_halo_dependent_cells = include_south ? interior_active_indices(ibg; parameters = KernelParameters(y_boundary, left_offsets)) : nothing + north_halo_dependent_cells = include_north ? interior_active_indices(ibg; parameters = KernelParameters(y_boundary, right_y_offsets)) : nothing - nx = Rx == 1 ? Nx : (Tx == RightConnected || Tx == LeftConnected ? Nx - Hx + 1 : Nx - 2Hx + 2) - ny = Ry == 1 ? Ny : (Ty == RightConnected || Ty == LeftConnected ? Ny - Hy + 1 : Ny - 2Hy + 2) + nx = Rx == 1 ? Nx : (Tx == RightConnected || Tx == LeftConnected ? Nx - Hx : Nx - 2Hx) + ny = Ry == 1 ? Ny : (Ty == RightConnected || Ty == LeftConnected ? Ny - Hy : Ny - 2Hy) - ox = Rx == 1 || Tx == RightConnected ? 0 : Hx - 1 - oy = Ry == 1 || Ty == RightConnected ? 0 : Hy - 1 + ox = Rx == 1 || Tx == RightConnected ? 0 : Hx + oy = Ry == 1 || Ty == RightConnected ? 0 : Hy halo_independent_cells = interior_active_indices(ibg; parameters = KernelParameters((nx, ny, Nz), (ox, oy, 0))) diff --git a/src/ImmersedBoundaries/active_cells_map.jl b/src/ImmersedBoundaries/active_cells_map.jl index fc80310a2a..ce1d186eb8 100644 --- a/src/ImmersedBoundaries/active_cells_map.jl +++ b/src/ImmersedBoundaries/active_cells_map.jl @@ -103,7 +103,6 @@ function compute_active_z_columns(ibg) is_immersed_column = KernelFunctionOperation{Center, Center, Nothing}(active_column, ibg, active_cells_in_column) active_z_columns = Field{Center, Center, Nothing}(ibg, Bool) set!(active_z_columns, is_immersed_column) - fill_halo_regions!(active_z_columns) return active_z_columns end @@ -177,13 +176,9 @@ map_interior_active_cells(ibg) = interior_active_indices(ibg; parameters = :xyz) # computation only on active `columns` function map_active_z_columns(ibg) active_cells_field = compute_active_z_columns(ibg) - - Hx, Hy, _ = halo_size(ibg) - Nx, Ny, _ = size(ibg) - - # Limit to -H+2:N+H-1 - surface_cells = on_architecture(CPU(), active_cells_field.data)[-Hx+2:Nx+Hx-1, -Hy+2:Ny+Hy-1, 1] - full_indices = findall(surface_cells) + interior_cells = on_architecture(CPU(), interior(active_cells_field, :, :, 1)) + + full_indices = findall(interior_cells) Nx, Ny, _ = size(ibg) # Reduce the size of the active_cells_map (originally a tuple of Int64) diff --git a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl index 25a74c59c0..655e2e9068 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/step_split_explicit_free_surface.jl @@ -70,10 +70,8 @@ function iterate_split_explicit!(free_surface, grid, GUⁿ, GVⁿ, Δτᴮ, weig U, V = free_surface.barotropic_velocities η̅, U̅, V̅ = state.η, state.U, state.V - active_cells_map = retrieve_surface_active_cells_map(grid) - - η_kernel!, _ = configure_kernel(arch, grid, parameters, _split_explicit_free_surface!; active_cells_map) - U_kernel!, _ = configure_kernel(arch, grid, parameters, _split_explicit_barotropic_velocity!; active_cells_map) + free_surface_kernel!, _ = configure_kernel(arch, grid, parameters, _split_explicit_free_surface!) + barotropic_velocity_kernel!, _ = configure_kernel(arch, grid, parameters, _split_explicit_barotropic_velocity!) η_args = (grid, Δτᴮ, η, U, V, timestepper) @@ -91,18 +89,11 @@ function iterate_split_explicit!(free_surface, grid, GUⁿ, GVⁿ, Δτᴮ, weig converted_η_args = convert_args(arch, η_args) converted_U_args = convert_args(arch, U_args) - # We convert the kernels for the same reason (they might contain a surface map) - GC.@preserve η_kernel! U_kernel! begin - - converted_η_kernel! = convert_args(arch, η_kernel!) - converted_U_kernel! = convert_args(arch, U_kernel!) - - @unroll for substep in 1:Nsubsteps - Base.@_inline_meta - averaging_weight = weights[substep] - η_kernel!(converted_η_args...) - U_kernel!(averaging_weight, converted_U_args...) - end + @unroll for substep in 1:Nsubsteps + Base.@_inline_meta + averaging_weight = weights[substep] + free_surface_kernel!(converted_η_args...) + barotropic_velocity_kernel!(averaging_weight, converted_U_args...) end end diff --git a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_buffers.jl b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_buffers.jl index 6b5983b8c6..7dc110d662 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_buffers.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_buffers.jl @@ -4,13 +4,22 @@ using Oceananigans.Grids: halo_size using Oceananigans.DistributedComputations: DistributedActiveCellsIBG using Oceananigans.ImmersedBoundaries: retrieve_interior_active_cells_map using Oceananigans.Models.NonhydrostaticModels: buffer_tendency_kernel_parameters, - buffer_surface_kernel_parameters + buffer_p_kernel_parameters, + buffer_κ_kernel_parameters, + buffer_parameters # We assume here that top/bottom BC are always synchronized (no partitioning in z) function compute_buffer_tendencies!(model::HydrostaticFreeSurfaceModel) grid = model.grid arch = architecture(grid) + w_parameters = buffer_w_kernel_parameters(grid, arch) + p_parameters = buffer_p_kernel_parameters(grid, arch) + κ_parameters = buffer_κ_kernel_parameters(grid, model.closure, arch) + + # We need new values for `w`, `p` and `κ` + compute_auxiliaries!(model; w_parameters, p_parameters, κ_parameters) + # parameters for communicating North / South / East / West side compute_buffer_tendency_contributions!(grid, arch, model) @@ -18,42 +27,47 @@ function compute_buffer_tendencies!(model::HydrostaticFreeSurfaceModel) end function compute_buffer_tendency_contributions!(grid, arch, model) - - params2D = buffer_surface_kernel_parameters(grid, arch) - params3D = buffer_tendency_kernel_parameters(grid, model.closure, arch) - - # We need new values for `w`, `p` and `κ` - compute_auxiliaries!(model, grid, arch; params2D, params3D, active_cells_map=nothing) - kernel_parameters = buffer_tendency_kernel_parameters(grid, arch) - compute_hydrostatic_free_surface_tendency_contributions!(model, params3D) + compute_hydrostatic_free_surface_tendency_contributions!(model, kernel_parameters) return nothing end function compute_buffer_tendency_contributions!(grid::DistributedActiveCellsIBG, arch, model) maps = grid.interior_active_cells - - # We do not need 3D parameters, they are in the active map - params2D = buffer_surface_kernel_parameters(grid, arch) - - for (idx, name) in enumerate((:west_halo_dependent_cells, - :east_halo_dependent_cells, - :south_halo_dependent_cells, - :north_halo_dependent_cells)) - - map = maps[name] + + for (name, map) in zip(keys(maps), maps) # If there exists a buffer map, then we compute the buffer contributions. If not, the # buffer contributions have already been calculated. We exclude the interior because it has # already been calculated - compute_buffer = !isnothing(map) + compute_buffer = (name != :interior) && !isnothing(map) if compute_buffer active_cells_map = retrieve_interior_active_cells_map(grid, Val(name)) - compute_auxiliaries!(model, grid, arch; params2D=params2D[idx], active_cells_map) compute_hydrostatic_free_surface_tendency_contributions!(model, :xyz; active_cells_map) end end return nothing end + +# w needs computing in the range - H + 1 : 0 and N - 1 : N + H - 1 +function buffer_w_kernel_parameters(grid, arch) + Nx, Ny, _ = size(grid) + Hx, Hy, _ = halo_size(grid) + + Sx = (Hx, Ny+2) + Sy = (Nx+2, Hy) + + # Offsets in tangential direction are == -1 to + # cover the required corners + param_west = (-Hx+2:1, 0:Ny+1) + param_east = (Nx:Nx+Hx-1, 0:Ny+1) + param_south = (0:Nx+1, -Hy+2:1) + param_north = (0:Nx+1, Ny:Ny+Hy-1) + + params = (param_west, param_east, param_south, param_north) + + return buffer_parameters(params, grid, arch) +end + diff --git a/src/Models/HydrostaticFreeSurfaceModels/compute_w_from_continuity.jl b/src/Models/HydrostaticFreeSurfaceModels/compute_w_from_continuity.jl index 8a95385208..927489cf50 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/compute_w_from_continuity.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/compute_w_from_continuity.jl @@ -1,5 +1,4 @@ using Oceananigans.Architectures: device -using Oceananigans.Models: surface_kernel_parameters using Oceananigans.Grids: halo_size, topology using Oceananigans.Grids: XFlatGrid, YFlatGrid using Oceananigans.Operators: div_xyᶜᶜᶜ, Δzᶜᶜᶜ @@ -16,7 +15,7 @@ w^{n+1} = -∫ [∂/∂x (u^{n+1}) + ∂/∂y (v^{n+1})] dz compute_w_from_continuity!(model; kwargs...) = compute_w_from_continuity!(model.velocities, model.architecture, model.grid; kwargs...) -compute_w_from_continuity!(velocities, arch, grid; parameters = surface_kernel_parameters(arch, grid)) = +compute_w_from_continuity!(velocities, arch, grid; parameters = w_kernel_parameters(grid)) = launch!(arch, grid, parameters, _compute_w_from_continuity!, velocities, grid) @kernel function _compute_w_from_continuity!(U, grid) @@ -26,4 +25,21 @@ compute_w_from_continuity!(velocities, arch, grid; parameters = surface_kernel_p for k in 2:grid.Nz+1 @inbounds U.w[i, j, k] = U.w[i, j, k-1] - Δzᶜᶜᶜ(i, j, k-1, grid) * div_xyᶜᶜᶜ(i, j, k-1, grid, U.u, U.v) end -end \ No newline at end of file +end + +##### +##### Size and offsets for the w kernel +##### + +# extend w kernel to compute also the boundaries +# If Flat, do not calculate on halos! +@inline function w_kernel_parameters(grid) + Nx, Ny, _ = size(grid) + Hx, Hy, _ = halo_size(grid) + Tx, Ty, _ = topology(grid) + + ii = ifelse(Tx == Flat, 1:Nx, -Hx+2:Nx+Hx-1) + jj = ifelse(Ty == Flat, 1:Ny, -Hy+2:Ny+Hy-1) + + return KernelParameters(ii, jj) +end diff --git a/src/Models/HydrostaticFreeSurfaceModels/update_hydrostatic_free_surface_model_state.jl b/src/Models/HydrostaticFreeSurfaceModels/update_hydrostatic_free_surface_model_state.jl index 907cac6bb2..e96f53cb45 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/update_hydrostatic_free_surface_model_state.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/update_hydrostatic_free_surface_model_state.jl @@ -7,7 +7,7 @@ using Oceananigans.BoundaryConditions: update_boundary_condition! using Oceananigans.TurbulenceClosures: compute_diffusivities! using Oceananigans.ImmersedBoundaries: mask_immersed_field!, mask_immersed_field_xy!, inactive_node using Oceananigans.Models: update_model_field_time_series! -using Oceananigans.Models.NonhydrostaticModels: update_hydrostatic_pressure!, surface_kernel_parameters, interior_tendency_kernel_parameters +using Oceananigans.Models.NonhydrostaticModels: update_hydrostatic_pressure!, p_kernel_parameters using Oceananigans.Fields: replace_horizontal_vector_halos!, tupled_fill_halo_regions! import Oceananigans.Models.NonhydrostaticModels: compute_auxiliaries! @@ -42,7 +42,7 @@ function update_state!(model::HydrostaticFreeSurfaceModel, grid, callbacks; comp tupled_fill_halo_regions!(prognostic_fields(model), grid, model.clock, fields(model), async=true) @apply_regionally replace_horizontal_vector_halos!(model.velocities, model.grid) - @apply_regionally compute_auxiliaries!(model, grid, architecture(grid)) + @apply_regionally compute_auxiliaries!(model) fill_halo_regions!(model.diffusivity_fields; only_local_halos = true) @@ -71,10 +71,9 @@ function mask_immersed_model_fields!(model, grid) return nothing end -function compute_auxiliaries!(model::HydrostaticFreeSurfaceModel, grid, arch; - params2D = surface_kernel_parameters(arch, grid), - params3D = interior_tendency_kernel_parameters(arch, grid), - active_cells_map = retrieve_interior_active_cells_map(grid, Val(:interior))) +function compute_auxiliaries!(model::HydrostaticFreeSurfaceModel; w_parameters = w_kernel_parameters(model.grid), + p_parameters = p_kernel_parameters(model.grid), + κ_parameters = :xyz) grid = model.grid closure = model.closure @@ -86,11 +85,11 @@ function compute_auxiliaries!(model::HydrostaticFreeSurfaceModel, grid, arch; arch = architecture(grid) # Advance diagnostic quantities - compute_w_from_continuity!(model; parameters = params2D) - update_hydrostatic_pressure!(P, arch, grid, buoyancy, tracers; parameters = params2D) + compute_w_from_continuity!(model; parameters = w_parameters) + update_hydrostatic_pressure!(P, arch, grid, buoyancy, tracers; parameters = p_parameters) # Update closure diffusivities - compute_diffusivities!(diffusivity, closure, model; parameters=params3D, active_cells_map) + compute_diffusivities!(diffusivity, closure, model; parameters = κ_parameters) return nothing end diff --git a/src/Models/NonhydrostaticModels/compute_nonhydrostatic_buffer_tendencies.jl b/src/Models/NonhydrostaticModels/compute_nonhydrostatic_buffer_tendencies.jl index c8f392d072..6e439ed7a4 100644 --- a/src/Models/NonhydrostaticModels/compute_nonhydrostatic_buffer_tendencies.jl +++ b/src/Models/NonhydrostaticModels/compute_nonhydrostatic_buffer_tendencies.jl @@ -11,44 +11,57 @@ function compute_buffer_tendencies!(model::NonhydrostaticModel) grid = model.grid arch = architecture(grid) - params2D = buffer_surface_kernel_parameters(grid, arch) - params3D = buffer_tendency_kernel_parameters(grid, arch) - + p_parameters = buffer_p_kernel_parameters(grid, arch) + κ_parameters = buffer_κ_kernel_parameters(grid, model.closure, arch) + # We need new values for `p` and `κ` - compute_auxiliaries!(model, grid, arch; params2D, params3D) + compute_auxiliaries!(model; p_parameters, κ_parameters) # parameters for communicating North / South / East / West side + kernel_parameters = buffer_tendency_kernel_parameters(grid, arch) compute_interior_tendency_contributions!(model, kernel_parameters) return nothing end -# surface needs computing in the range - H + 1 : 0 and N - 1 : N + H - 1 -function buffer_surface_kernel_parameters(grid, arch) - Nx, Ny, _ = size(grid) - Hx, Hy, _ = halo_size(grid) +# tendencies need computing in the range 1 : H and N - H + 1 : N +function buffer_tendency_kernel_parameters(grid, arch) + Nx, Ny, Nz = size(grid) + Hx, Hy, _ = halo_size(grid) - # Offsets in tangential direction are == -1 to - # cover the required corners - param_west = (-Hx+2:1, 0:Ny+1) - param_east = (Nx:Nx+Hx-1, 0:Ny+1) - param_south = (0:Nx+1, -Hy+2:1) - param_north = (0:Nx+1, Ny:Ny+Hy-1) + param_west = (1:Hx, 1:Ny, 1:Nz) + param_east = (Nx-Hx+1:Nx, 1:Ny, 1:Nz) + param_south = (1:Nx, 1:Hy, 1:Nz) + param_north = (1:Nx, Ny-Hy+1:Ny, 1:Nz) params = (param_west, param_east, param_south, param_north) + return buffer_parameters(params, grid, arch) +end +# p needs computing in the range 0 : 0 and N + 1 : N + 1 +function buffer_p_kernel_parameters(grid, arch) + Nx, Ny, _ = size(grid) + + param_west = (0:0, 1:Ny) + param_east = (Nx+1:Nx+1, 1:Ny) + param_south = (1:Nx, 0:0) + param_north = (1:Nx, Ny+1:Ny+1) + + params = (param_west, param_east, param_south, param_north) return buffer_parameters(params, grid, arch) end -# tendencies need computing in the range 1 : H and N - H + 1 : N -function buffer_tendency_kernel_parameters(grid, arch) +# diffusivities need recomputing in the range 0 : B and N - B + 1 : N + 1 +function buffer_κ_kernel_parameters(grid, closure, arch) Nx, Ny, Nz = size(grid) - Hx, Hy, _ = halo_size(grid) - param_west = (0:Hx, 1:Ny, 1:Nz) - param_east = (Nx-Hx+1:Nx+1, 1:Ny, 1:Nz) - param_south = (1:Nx, 0:Hy, 1:Nz) - param_north = (1:Nx, Ny-Hy+1:Ny+1, 1:Nz) + Bx = required_halo_size_x(closure) + By = required_halo_size_y(closure) + + param_west = (0:Bx, 1:Ny, 1:Nz) + param_east = (Nx-Bx+1:Nx+1, 1:Ny, 1:Nz) + param_south = (1:Nx, 0:By, 1:Nz) + param_north = (1:Nx, Ny-By+1:Ny+1, 1:Nz) params = (param_west, param_east, param_south, param_north) return buffer_parameters(params, grid, arch) diff --git a/src/Models/NonhydrostaticModels/update_hydrostatic_pressure.jl b/src/Models/NonhydrostaticModels/update_hydrostatic_pressure.jl index 5b3f94c4e5..a35e68e63b 100644 --- a/src/Models/NonhydrostaticModels/update_hydrostatic_pressure.jl +++ b/src/Models/NonhydrostaticModels/update_hydrostatic_pressure.jl @@ -28,10 +28,10 @@ update_hydrostatic_pressure!(grid, model; kwargs...) = const PCB = PartialCellBottom const PCBIBG = ImmersedBoundaryGrid{<:Any, <:Any, <:Any, <:Any, <:Any, <:PCB} -update_hydrostatic_pressure!(pHY′, arch, ibg::PCBIBG, buoyancy, tracers; parameters = surface_kernel_parameters(arch, ibg.underlying_grid)) = +update_hydrostatic_pressure!(pHY′, arch, ibg::PCBIBG, buoyancy, tracers; parameters = p_kernel_parameters(ibg.underlying_grid)) = update_hydrostatic_pressure!(pHY′, arch, ibg.underlying_grid, buoyancy, tracers; parameters) -update_hydrostatic_pressure!(pHY′, arch, grid, buoyancy, tracers; parameters = surface_kernel_parameters(arch, grid)) = +update_hydrostatic_pressure!(pHY′, arch, grid, buoyancy, tracers; parameters = p_kernel_parameters(grid)) = launch!(arch, grid, parameters, _update_hydrostatic_pressure!, pHY′, grid, buoyancy, tracers) update_hydrostatic_pressure!(::Nothing, arch, grid, args...; kw...) = nothing diff --git a/src/Models/NonhydrostaticModels/update_nonhydrostatic_model_state.jl b/src/Models/NonhydrostaticModels/update_nonhydrostatic_model_state.jl index 6898b16ecb..705ca507ac 100644 --- a/src/Models/NonhydrostaticModels/update_nonhydrostatic_model_state.jl +++ b/src/Models/NonhydrostaticModels/update_nonhydrostatic_model_state.jl @@ -6,7 +6,7 @@ using Oceananigans.BoundaryConditions: update_boundary_condition! using Oceananigans.TurbulenceClosures: compute_diffusivities! using Oceananigans.Fields: compute! using Oceananigans.ImmersedBoundaries: mask_immersed_field! -using Oceananigans.Models: update_model_field_time_series!, surface_kernel_parameters, interior_tendency_kernel_parameters +using Oceananigans.Models: update_model_field_time_series! import Oceananigans.TimeSteppers: update_state! @@ -40,7 +40,7 @@ function update_state!(model::NonhydrostaticModel, callbacks=[]; compute_tendenc end # Calculate diffusivities and hydrostatic pressure - @apply_regionally compute_auxiliaries!(model, grid, arch) + @apply_regionally compute_auxiliaries!(model) fill_halo_regions!(model.diffusivity_fields; only_local_halos = true) for callback in callbacks @@ -55,16 +55,15 @@ function update_state!(model::NonhydrostaticModel, callbacks=[]; compute_tendenc return nothing end -function compute_auxiliaries!(model::NonhydrostaticModel, grid, arch; - params2D = surface_kernel_parameters(arch, grid), - params3D = interior_tendency_kernel_parameters(arch, grid)) +function compute_auxiliaries!(model::NonhydrostaticModel; p_parameters = tuple(p_kernel_parameters(model.grid)), + κ_parameters = tuple(:xyz)) closure = model.closure diffusivity = model.diffusivity_fields - update_hydrostatic_pressure!(model; parameters=params2D) - - compute_diffusivities!(diffusivity, closure, model; parameters=params3D) - + for (ppar, κpar) in zip(p_parameters, κ_parameters) + compute_diffusivities!(diffusivity, closure, model; parameters = κpar) + update_hydrostatic_pressure!(model; parameters = ppar) + end return nothing end diff --git a/src/Models/interleave_communication_and_computation.jl b/src/Models/interleave_communication_and_computation.jl index 0ad01c2d57..3a0a98b1af 100644 --- a/src/Models/interleave_communication_and_computation.jl +++ b/src/Models/interleave_communication_and_computation.jl @@ -26,17 +26,10 @@ complete_communication_and_compute_buffer!(model, grid, arch) = nothing compute_buffer_tendencies!(model) = nothing """ Kernel parameters for computing interior tendencies. """ -function interior_tendency_kernel_parameters(arch, grid) - Nx, Ny, Nz = size(grid) - return KernelParameters(0:Nx+1, 0:Ny+1, 1:Nz) -end - -function interior_tendency_kernel_parameters(::SynchronizedDistributed, grid) - Nx, Ny, Nz = size(grid) - return KernelParameters(0:Nx+1, 0:Ny+1, 1:Nz) -end +interior_tendency_kernel_parameters(arch, grid) = :xyz # fallback +interior_tendency_kernel_parameters(::SynchronizedDistributed, grid) = :xyz -function interior_parameters_without_halo(arch, grid) +function interior_tendency_kernel_parameters(arch::Distributed, grid) Rx, Ry, _ = arch.ranks Hx, Hy, _ = halo_size(grid) Tx, Ty, _ = topology(grid) @@ -51,52 +44,28 @@ function interior_parameters_without_halo(arch, grid) # Sizes Sx = if local_x - Nx + 2 + Nx elseif one_sided_x - Nx - Hx + 2 + Nx - Hx else # two sided - Nx - 2Hx + 2 + Nx - 2Hx end Sy = if local_y - Ny + 2 + Ny elseif one_sided_y - Ny - Hy + 2 + Ny - Hy else # two sided - Ny - 2Hy + 2 + Ny - 2Hy end # Offsets - Ox = Rx == 1 || Tx == RightConnected ? -1 : Hx-1 - Oy = Ry == 1 || Ty == RightConnected ? -1 : Hy-1 + Ox = Rx == 1 || Tx == RightConnected ? 0 : Hx + Oy = Ry == 1 || Ty == RightConnected ? 0 : Hy sizes = (Sx, Sy, Nz) offsets = (Ox, Oy, 0) - return sizes, offsets -end - -function interior_tendency_kernel_parameters(arch::Distributed, grid) - return KernelParameters(interior_parameters_without_halo(arch, grid)...) + return KernelParameters(sizes, offsets) end -@inline surface_kernel_parameters(arch, grid) = surface_kernel_parameters(grid) -@inline surface_kernel_parameters(::SynchronizedDistributed, grid) = surface_kernel_parameters(grid) - -# extend w kernel to compute also the boundaries -# If Flat, do not calculate on halos! -@inline function surface_kernel_parameters(grid) - Nx, Ny, _ = size(grid) - Hx, Hy, _ = halo_size(grid) - Tx, Ty, _ = topology(grid) - - ii = ifelse(Tx == Flat, 1:Nx, -Hx+2:Nx+Hx-1) - jj = ifelse(Ty == Flat, 1:Ny, -Hy+2:Ny+Hy-1) - - return KernelParameters(ii, jj) -end - -@inline function surface_kernel_parameters(arch::Distributed, grid) - size, offset = interior_parameters_without_halo(arch, grid) - return KernelParameters(size[1:2], offset[1:2]) -end diff --git a/src/TurbulenceClosures/turbulence_closure_implementations/Smagorinskys/smagorinsky.jl b/src/TurbulenceClosures/turbulence_closure_implementations/Smagorinskys/smagorinsky.jl index d89a946fcc..d7968017b0 100644 --- a/src/TurbulenceClosures/turbulence_closure_implementations/Smagorinskys/smagorinsky.jl +++ b/src/TurbulenceClosures/turbulence_closure_implementations/Smagorinskys/smagorinsky.jl @@ -105,7 +105,7 @@ end compute_coefficient_fields!(diffusivity_fields, closure, model; parameters) = nothing -function compute_diffusivities!(diffusivity_fields, closure::Smagorinsky, model; parameters = :xyz, active_cells_map = nothing) +function compute_diffusivities!(diffusivity_fields, closure::Smagorinsky, model; parameters = :xyz) arch = model.architecture grid = model.grid buoyancy = model.buoyancy @@ -115,7 +115,7 @@ function compute_diffusivities!(diffusivity_fields, closure::Smagorinsky, model; compute_coefficient_fields!(diffusivity_fields, closure, model; parameters) launch!(arch, grid, parameters, _compute_smagorinsky_viscosity!, - diffusivity_fields, grid, closure, buoyancy, velocities, tracers; active_cells_map) + diffusivity_fields, grid, closure, buoyancy, velocities, tracers) return nothing end diff --git a/src/TurbulenceClosures/turbulence_closure_implementations/TKEBasedVerticalDiffusivities/catke_vertical_diffusivity.jl b/src/TurbulenceClosures/turbulence_closure_implementations/TKEBasedVerticalDiffusivities/catke_vertical_diffusivity.jl index 3febffd2a6..4847a3802a 100644 --- a/src/TurbulenceClosures/turbulence_closure_implementations/TKEBasedVerticalDiffusivities/catke_vertical_diffusivity.jl +++ b/src/TurbulenceClosures/turbulence_closure_implementations/TKEBasedVerticalDiffusivities/catke_vertical_diffusivity.jl @@ -177,8 +177,7 @@ end @inline viscosity_location(::FlavorOfCATKE) = (c, c, f) @inline diffusivity_location(::FlavorOfCATKE) = (c, c, f) -function compute_diffusivities!(diffusivities, closure::FlavorOfCATKE, model; - parameters = :xyz, active_cells_map = nothing) +function compute_diffusivities!(diffusivities, closure::FlavorOfCATKE, model; parameters = :xyz) arch = model.architecture grid = model.grid @@ -194,7 +193,7 @@ function compute_diffusivities!(diffusivities, closure::FlavorOfCATKE, model; # Compute e at the current time: # * update tendency Gⁿ using current and previous velocity field # * use tridiagonal solve to take an implicit step - time_step_catke_equation!(model; parameters, active_cells_map) + time_step_catke_equation!(model) end # Update "previous velocities" @@ -209,8 +208,7 @@ function compute_diffusivities!(diffusivities, closure::FlavorOfCATKE, model; launch!(arch, grid, parameters, compute_CATKE_diffusivities!, - diffusivities, grid, closure, velocities, tracers, buoyancy; - active_cells_map) + diffusivities, grid, closure, velocities, tracers, buoyancy) return nothing end diff --git a/src/TurbulenceClosures/turbulence_closure_implementations/TKEBasedVerticalDiffusivities/time_step_catke_equation.jl b/src/TurbulenceClosures/turbulence_closure_implementations/TKEBasedVerticalDiffusivities/time_step_catke_equation.jl index 8206f4b690..9cf74fcc5b 100644 --- a/src/TurbulenceClosures/turbulence_closure_implementations/TKEBasedVerticalDiffusivities/time_step_catke_equation.jl +++ b/src/TurbulenceClosures/turbulence_closure_implementations/TKEBasedVerticalDiffusivities/time_step_catke_equation.jl @@ -9,7 +9,7 @@ using CUDA get_time_step(closure::CATKEVerticalDiffusivity) = closure.tke_time_step -function time_step_catke_equation!(model; parameters, active_cells_map) +function time_step_catke_equation!(model) # TODO: properly handle closure tuples if model.closure isa Tuple @@ -54,12 +54,12 @@ function time_step_catke_equation!(model; parameters, active_cells_map) # Compute the linear implicit component of the RHS (diffusivities, L) # and step forward - launch!(arch, grid, parameters, + launch!(arch, grid, :xyz, substep_turbulent_kinetic_energy!, κe, Le, grid, closure, model.velocities, previous_velocities, # try this soon: model.velocities, model.velocities, model.tracers, model.buoyancy, diffusivity_fields, - Δτ, χ, Gⁿe, G⁻e; active_cells_map) + Δτ, χ, Gⁿe, G⁻e) # Good idea? # previous_time = model.clock.time - Δt diff --git a/src/TurbulenceClosures/turbulence_closure_implementations/TKEBasedVerticalDiffusivities/tke_dissipation_vertical_diffusivity.jl b/src/TurbulenceClosures/turbulence_closure_implementations/TKEBasedVerticalDiffusivities/tke_dissipation_vertical_diffusivity.jl index 6fd0b00034..d94035e507 100644 --- a/src/TurbulenceClosures/turbulence_closure_implementations/TKEBasedVerticalDiffusivities/tke_dissipation_vertical_diffusivity.jl +++ b/src/TurbulenceClosures/turbulence_closure_implementations/TKEBasedVerticalDiffusivities/tke_dissipation_vertical_diffusivity.jl @@ -191,7 +191,7 @@ end @inline viscosity_location(::FlavorOfTD) = (c, c, f) @inline diffusivity_location(::FlavorOfTD) = (c, c, f) -function compute_diffusivities!(diffusivities, closure::FlavorOfTD, model; parameters = :xyz, active_cells_map = nothing) +function compute_diffusivities!(diffusivities, closure::FlavorOfTD, model; parameters = :xyz) arch = model.architecture grid = model.grid @@ -216,8 +216,7 @@ function compute_diffusivities!(diffusivities, closure::FlavorOfTD, model; param launch!(arch, grid, parameters, compute_TKEDissipation_diffusivities!, - diffusivities, grid, closure, velocities, tracers, buoyancy; - active_cells_map) + diffusivities, grid, closure, velocities, tracers, buoyancy) return nothing end diff --git a/src/TurbulenceClosures/turbulence_closure_implementations/anisotropic_minimum_dissipation.jl b/src/TurbulenceClosures/turbulence_closure_implementations/anisotropic_minimum_dissipation.jl index eeba883a79..390c96555b 100644 --- a/src/TurbulenceClosures/turbulence_closure_implementations/anisotropic_minimum_dissipation.jl +++ b/src/TurbulenceClosures/turbulence_closure_implementations/anisotropic_minimum_dissipation.jl @@ -188,7 +188,7 @@ end @inbounds κₑ[i, j, k] = max(zero(FT), κˢᵍˢ) end -function compute_diffusivities!(diffusivity_fields, closure::AnisotropicMinimumDissipation, model; parameters=:xyz, active_cells_map=nothing) +function compute_diffusivities!(diffusivity_fields, closure::AnisotropicMinimumDissipation, model; parameters = :xyz) grid = model.grid arch = model.architecture velocities = model.velocities @@ -201,7 +201,7 @@ function compute_diffusivities!(diffusivity_fields, closure::AnisotropicMinimumD for (tracer_index, κₑ) in enumerate(diffusivity_fields.κₑ) @inbounds tracer = tracers[tracer_index] launch!(arch, grid, parameters, _compute_AMD_diffusivity!, - κₑ, grid, closure, tracer, Val(tracer_index), velocities; active_cells_map) + κₑ, grid, closure, tracer, Val(tracer_index), velocities) end return nothing diff --git a/src/TurbulenceClosures/turbulence_closure_implementations/convective_adjustment_vertical_diffusivity.jl b/src/TurbulenceClosures/turbulence_closure_implementations/convective_adjustment_vertical_diffusivity.jl index 9c7dd578cb..cfdd407523 100644 --- a/src/TurbulenceClosures/turbulence_closure_implementations/convective_adjustment_vertical_diffusivity.jl +++ b/src/TurbulenceClosures/turbulence_closure_implementations/convective_adjustment_vertical_diffusivity.jl @@ -88,7 +88,7 @@ DiffusivityFields(grid, tracer_names, bcs, closure::FlavorOfCAVD) = (; κᶜ = Z @inline viscosity(::FlavorOfCAVD, diffusivities) = diffusivities.κᵘ @inline diffusivity(::FlavorOfCAVD, diffusivities, id) = diffusivities.κᶜ -function compute_diffusivities!(diffusivities, closure::FlavorOfCAVD, model; parameters=:xyz, active_cells_map=nothing) +function compute_diffusivities!(diffusivities, closure::FlavorOfCAVD, model; parameters = :xyz) arch = model.architecture grid = model.grid @@ -98,7 +98,7 @@ function compute_diffusivities!(diffusivities, closure::FlavorOfCAVD, model; par launch!(arch, grid, parameters, ## If we can figure out how to only precompute the "stability" of a cell: # compute_stability!, diffusivities, grid, closure, tracers, buoyancy, - compute_convective_adjustment_diffusivities!, diffusivities, grid, closure, tracers, buoyancy, active_cells_map) + compute_convective_adjustment_diffusivities!, diffusivities, grid, closure, tracers, buoyancy) return nothing end diff --git a/src/TurbulenceClosures/turbulence_closure_implementations/isopycnal_skew_symmetric_diffusivity.jl b/src/TurbulenceClosures/turbulence_closure_implementations/isopycnal_skew_symmetric_diffusivity.jl index 9da2927e53..803771ec6f 100644 --- a/src/TurbulenceClosures/turbulence_closure_implementations/isopycnal_skew_symmetric_diffusivity.jl +++ b/src/TurbulenceClosures/turbulence_closure_implementations/isopycnal_skew_symmetric_diffusivity.jl @@ -109,7 +109,7 @@ function DiffusivityFields(grid, tracer_names, bcs, ::FlavorOfISSD{TD, A}) where return diffusivities end -function compute_diffusivities!(diffusivities, closure::FlavorOfISSD, model; parameters = :xyz, active_cells_map = nothing) +function compute_diffusivities!(diffusivities, closure::FlavorOfISSD, model; parameters = :xyz) arch = model.architecture grid = model.grid @@ -117,7 +117,7 @@ function compute_diffusivities!(diffusivities, closure::FlavorOfISSD, model; par buoyancy = model.buoyancy launch!(arch, grid, parameters, - compute_tapered_R₃₃!, diffusivities.ϵ_R₃₃, grid, closure, tracers, buoyancy; active_cells_map) + compute_tapered_R₃₃!, diffusivities.ϵ_R₃₃, grid, closure, tracers, buoyancy) compute_eddy_velocities!(diffusivities, closure, model; parameters) diff --git a/src/TurbulenceClosures/turbulence_closure_implementations/leith_enstrophy_diffusivity.jl b/src/TurbulenceClosures/turbulence_closure_implementations/leith_enstrophy_diffusivity.jl index 7b87ffc1da..f640990ca6 100644 --- a/src/TurbulenceClosures/turbulence_closure_implementations/leith_enstrophy_diffusivity.jl +++ b/src/TurbulenceClosures/turbulence_closure_implementations/leith_enstrophy_diffusivity.jl @@ -91,7 +91,7 @@ end @inbounds νₑ[i, j, k] = prefactor * dynamic_ν end -function compute_diffusivities!(diffusivity_fields, closure::TwoDimensionalLeith, model; parameters=:xyz, active_cells_map=nothing) +function compute_diffusivities!(diffusivity_fields, closure::TwoDimensionalLeith, model; parameters = :xyz) arch = model.architecture grid = model.grid velocities = model.velocities @@ -99,7 +99,7 @@ function compute_diffusivities!(diffusivity_fields, closure::TwoDimensionalLeith buoyancy = model.buoyancy launch!(arch, grid, parameters, _compute_leith_viscosity!, - diffusivity_fields.νₑ, grid, closure, buoyancy, velocities, tracers; active_cells_map) + diffusivity_fields.νₑ, grid, closure, buoyancy, velocities, tracers) return nothing end diff --git a/src/TurbulenceClosures/turbulence_closure_implementations/ri_based_vertical_diffusivity.jl b/src/TurbulenceClosures/turbulence_closure_implementations/ri_based_vertical_diffusivity.jl index cbef53feb3..2d4b7bb2eb 100644 --- a/src/TurbulenceClosures/turbulence_closure_implementations/ri_based_vertical_diffusivity.jl +++ b/src/TurbulenceClosures/turbulence_closure_implementations/ri_based_vertical_diffusivity.jl @@ -190,7 +190,7 @@ function DiffusivityFields(grid, tracer_names, bcs, closure::FlavorOfRBVD) return (; κc, κu, Ri) end -function compute_diffusivities!(diffusivities, closure::FlavorOfRBVD, model; parameters = :xyz, active_cells_map = nothing) +function compute_diffusivities!(diffusivities, closure::FlavorOfRBVD, model; parameters = :xyz) arch = model.architecture grid = model.grid clock = model.clock @@ -208,8 +208,7 @@ function compute_diffusivities!(diffusivities, closure::FlavorOfRBVD, model; par tracers, buoyancy, top_tracer_bcs, - clock; - active_cells_map) + clock) # Use `only_local_halos` to ensure that no communication occurs during # this call to fill_halo_regions! @@ -224,8 +223,7 @@ function compute_diffusivities!(diffusivities, closure::FlavorOfRBVD, model; par tracers, buoyancy, top_tracer_bcs, - clock; - active_cells_map) + clock) return nothing end diff --git a/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl b/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl index 56f866c319..003fabbeea 100644 --- a/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl +++ b/src/TurbulenceClosures/turbulence_closure_implementations/scalar_biharmonic_diffusivity.jl @@ -101,7 +101,7 @@ end @inline viscosity(closure::ScalarBiharmonicDiffusivity, K) = closure.ν @inline diffusivity(closure::ScalarBiharmonicDiffusivity, K, ::Val{id}) where id = closure.κ[id] -compute_diffusivities!(diffusivities, closure::ScalarBiharmonicDiffusivity, args...; kwargs...) = nothing +compute_diffusivities!(diffusivities, closure::ScalarBiharmonicDiffusivity, args...) = nothing function Base.summary(closure::ScalarBiharmonicDiffusivity) F = summary(formulation(closure)) diff --git a/src/TurbulenceClosures/turbulence_closure_implementations/scalar_diffusivity.jl b/src/TurbulenceClosures/turbulence_closure_implementations/scalar_diffusivity.jl index 6573fe08c1..a4f85814b8 100644 --- a/src/TurbulenceClosures/turbulence_closure_implementations/scalar_diffusivity.jl +++ b/src/TurbulenceClosures/turbulence_closure_implementations/scalar_diffusivity.jl @@ -192,7 +192,7 @@ end @inline viscosity(closure::ScalarDiffusivity, K) = closure.ν @inline diffusivity(closure::ScalarDiffusivity, K, ::Val{id}) where id = closure.κ[id] -compute_diffusivities!(diffusivities, ::ScalarDiffusivity, args...; kwargs...) = nothing +compute_diffusivities!(diffusivities, ::ScalarDiffusivity, args...) = nothing # Note: we could compute ν and κ (if they are Field): # function compute_diffusivities!(diffusivities, closure::ScalarDiffusivity, args...) From e0b2b199117eef1256f4221a779424d9f503c3a7 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Wed, 11 Dec 2024 11:13:25 +0100 Subject: [PATCH 37/60] some housekeeping --- .../distributed_immersed_boundaries.jl | 23 +++++++++++-------- ...ompute_hydrostatic_free_surface_buffers.jl | 11 +++++---- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/DistributedComputations/distributed_immersed_boundaries.jl b/src/DistributedComputations/distributed_immersed_boundaries.jl index 01ffb3d67b..dc86b8812c 100644 --- a/src/DistributedComputations/distributed_immersed_boundaries.jl +++ b/src/DistributedComputations/distributed_immersed_boundaries.jl @@ -121,23 +121,26 @@ function map_interior_active_cells(ibg::ImmersedBoundaryGrid{<:Any, <:Any, <:Any Nx, Ny, Nz = size(ibg) Hx, Hy, _ = halo_size(ibg) - x_boundary = (Hx, Ny, Nz) - y_boundary = (Nx, Hy, Nz) - - left_offsets = (0, 0, 0) - right_x_offsets = (Nx-Hx, 0, 0) - right_y_offsets = (0, Ny-Hy, 0) + west_boundary = (1:Hx, 1:Ny, 1:Nz) + east_boundary = (Nx-Hx+1:Nx, 1:Ny, 1:Nz) + south_boundary = (1:Nx, 1:Hy, 1:Nz) + north_boundary = (1:Nx, Ny-Hy+1:Ny, 1:Nz) include_west = !isa(ibg, XFlatGrid) && (Rx != 1) && !(Tx == RightConnected) include_east = !isa(ibg, XFlatGrid) && (Rx != 1) && !(Tx == LeftConnected) include_south = !isa(ibg, YFlatGrid) && (Ry != 1) && !(Ty == RightConnected) include_north = !isa(ibg, YFlatGrid) && (Ry != 1) && !(Ty == LeftConnected) - west_halo_dependent_cells = include_west ? interior_active_indices(ibg; parameters = KernelParameters(x_boundary, left_offsets)) : nothing - east_halo_dependent_cells = include_east ? interior_active_indices(ibg; parameters = KernelParameters(x_boundary, right_x_offsets)) : nothing - south_halo_dependent_cells = include_south ? interior_active_indices(ibg; parameters = KernelParameters(y_boundary, left_offsets)) : nothing - north_halo_dependent_cells = include_north ? interior_active_indices(ibg; parameters = KernelParameters(y_boundary, right_y_offsets)) : nothing + west_halo_dependent_cells = interior_active_indices(ibg; parameters = KernelParameters(west_boundary)) + east_halo_dependent_cells = interior_active_indices(ibg; parameters = KernelParameters(east_boundary)) + south_halo_dependent_cells = interior_active_indices(ibg; parameters = KernelParameters(south_boundary)) + north_halo_dependent_cells = interior_active_indices(ibg; parameters = KernelParameters(north_boundary)) + west_halo_dependent_cells = ifelse(include_west, west_halo_dependent_cells, nothing) + east_halo_dependent_cells = ifelse(include_east, east_halo_dependent_cells, nothing) + south_halo_dependent_cells = ifelse(include_south, south_halo_dependent_cells, nothing) + north_halo_dependent_cells = ifelse(include_north, north_halo_dependent_cells, nothing) + nx = Rx == 1 ? Nx : (Tx == RightConnected || Tx == LeftConnected ? Nx - Hx : Nx - 2Hx) ny = Ry == 1 ? Ny : (Ty == RightConnected || Ty == LeftConnected ? Ny - Hy : Ny - 2Hy) diff --git a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_buffers.jl b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_buffers.jl index 7dc110d662..0db6045cbc 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_buffers.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_buffers.jl @@ -35,14 +35,17 @@ end function compute_buffer_tendency_contributions!(grid::DistributedActiveCellsIBG, arch, model) maps = grid.interior_active_cells - for (name, map) in zip(keys(maps), maps) + for name in (:west_dependent_halo_cells, + :east_dependent_halo_cells, + :south_dependent_halo_cells, + :north_dependent_halo_cells) + + map = @inbounds maps[name] # If there exists a buffer map, then we compute the buffer contributions. If not, the # buffer contributions have already been calculated. We exclude the interior because it has # already been calculated - compute_buffer = (name != :interior) && !isnothing(map) - - if compute_buffer + if !isnothing(map) active_cells_map = retrieve_interior_active_cells_map(grid, Val(name)) compute_hydrostatic_free_surface_tendency_contributions!(model, :xyz; active_cells_map) end From c9b19c373840653d6b64cd756e09c36bcb171d56 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Wed, 11 Dec 2024 13:01:36 +0100 Subject: [PATCH 38/60] good active cells map test --- .../distributed_immersed_boundaries.jl | 8 +- test/runtests.jl | 1 + test/test_active_cells_map.jl | 88 ++++++++++++------- 3 files changed, 63 insertions(+), 34 deletions(-) diff --git a/src/DistributedComputations/distributed_immersed_boundaries.jl b/src/DistributedComputations/distributed_immersed_boundaries.jl index dc86b8812c..2138803379 100644 --- a/src/DistributedComputations/distributed_immersed_boundaries.jl +++ b/src/DistributedComputations/distributed_immersed_boundaries.jl @@ -131,10 +131,10 @@ function map_interior_active_cells(ibg::ImmersedBoundaryGrid{<:Any, <:Any, <:Any include_south = !isa(ibg, YFlatGrid) && (Ry != 1) && !(Ty == RightConnected) include_north = !isa(ibg, YFlatGrid) && (Ry != 1) && !(Ty == LeftConnected) - west_halo_dependent_cells = interior_active_indices(ibg; parameters = KernelParameters(west_boundary)) - east_halo_dependent_cells = interior_active_indices(ibg; parameters = KernelParameters(east_boundary)) - south_halo_dependent_cells = interior_active_indices(ibg; parameters = KernelParameters(south_boundary)) - north_halo_dependent_cells = interior_active_indices(ibg; parameters = KernelParameters(north_boundary)) + west_halo_dependent_cells = interior_active_indices(ibg; parameters = KernelParameters(west_boundary...)) + east_halo_dependent_cells = interior_active_indices(ibg; parameters = KernelParameters(east_boundary...)) + south_halo_dependent_cells = interior_active_indices(ibg; parameters = KernelParameters(south_boundary...)) + north_halo_dependent_cells = interior_active_indices(ibg; parameters = KernelParameters(north_boundary...)) west_halo_dependent_cells = ifelse(include_west, west_halo_dependent_cells, nothing) east_halo_dependent_cells = ifelse(include_east, east_halo_dependent_cells, nothing) diff --git a/test/runtests.jl b/test/runtests.jl index a47f0e3d3d..1ad3a5caab 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -120,6 +120,7 @@ CUDA.allowscalar() do @testset "Model and time stepping tests (part 1)" begin include("test_nonhydrostatic_models.jl") include("test_time_stepping.jl") + include("test_active_cells_map.jl") end end diff --git a/test/test_active_cells_map.jl b/test/test_active_cells_map.jl index da9fccdfd6..2084755093 100644 --- a/test/test_active_cells_map.jl +++ b/test/test_active_cells_map.jl @@ -1,6 +1,9 @@ include("dependencies_for_runtests.jl") using Oceananigans.Operators: hack_cosd +using Oceananigans.ImmersedBoundaries: retrieve_surface_active_cells_map, + retrieve_interior_active_cells_map, + immersed_cell function Δ_min(grid) Δx_min = minimum_xspacing(grid, Center(), Center(), Center()) @@ -12,7 +15,7 @@ end function solid_body_rotation_test(grid) - free_surface = SplitExplicitFreeSurface(grid; substeps = 5, gravitational_acceleration = 1) + free_surface = SplitExplicitFreeSurface(grid; substeps = 10, gravitational_acceleration = 1) coriolis = HydrostaticSphericalCoriolis(rotation_rate = 1) model = HydrostaticFreeSurfaceModel(; grid, @@ -46,12 +49,13 @@ function solid_body_rotation_test(grid) return merge(model.velocities, model.tracers, (; η = model.free_surface.η)) end -Nx = 32 -Ny = 32 +Nx = 16 +Ny = 16 +Nz = 10 -for arch in archs - @testset "Active cells map solid body rotation" begin - underlying_grid = LatitudeLongitudeGrid(arch, size = (Nx, Ny, 10), +@testset "Active cells map" begin + for arch in archs + underlying_grid = LatitudeLongitudeGrid(arch, size = (Nx, Ny, Nz), halo = (4, 4, 4), latitude = (-80, 80), longitude = (-160, 160), @@ -68,28 +72,52 @@ for arch in archs immersed_grid = ImmersedBoundaryGrid(underlying_grid, GridFittedBottom(bottom_height)) immersed_active_grid = ImmersedBoundaryGrid(underlying_grid, GridFittedBottom(bottom_height); active_cells_map = true) - ua, va, wa, ca, ηa = solid_body_rotation_test(immersed_active_grid) - u, v, w, c, η = solid_body_rotation_test(immersed_grid) - - ua = interior(on_architecture(CPU(), ua)) - va = interior(on_architecture(CPU(), va)) - wa = interior(on_architecture(CPU(), wa)) - ca = interior(on_architecture(CPU(), ca)) - ηa = interior(on_architecture(CPU(), ηa)) - - u = interior(on_architecture(CPU(), u)) - v = interior(on_architecture(CPU(), v)) - w = interior(on_architecture(CPU(), w)) - c = interior(on_architecture(CPU(), c)) - η = interior(on_architecture(CPU(), η)) - - atol = eps(eltype(immersed_grid)) - rtol = sqrt(eps(eltype(immersed_grid))) - - @test all(isapprox(u, ua; atol, rtol)) - @test all(isapprox(v, va; atol, rtol)) - @test all(isapprox(w, wa; atol, rtol)) - @test all(isapprox(c, ca; atol, rtol)) - @test all(isapprox(η, ηa; atol, rtol)) + @testset "Active cells map construction" begin + surface_active_cells_map = retrieve_surface_active_cells_map(immersed_active_grid) + interior_active_cells_map = retrieve_interior_active_cells_map(immersed_active_grid, Val(:interior)) + + surface_active_cells_map = on_architecture(CPU(), surface_active_cells_map) + interior_active_cells_map = on_architecture(CPU(), interior_active_cells_map) + grid = on_architecture(CPU(), immersed_grid) + + for i in 1:Nx, j in 1:Ny, k in 1:Nz + immersed = immersed_cell(i, j, k, grid) + active = (i, j, k) ∈ interior_active_cells_map + @test immersed ⊻ active + end + + for i in 1:Nx, j in 1:Ny + immersed = all(immersed_cell(i, j, k, grid) for k in 1:Nz) + active = (i, j) ∈ surface_active_cells_map + @test immersed ⊻ active + end + end + + @testset "Active cells map solid body rotation" begin + + ua, va, wa, ca, ηa = solid_body_rotation_test(immersed_active_grid) + u, v, w, c, η = solid_body_rotation_test(immersed_grid) + + ua = interior(on_architecture(CPU(), ua)) + va = interior(on_architecture(CPU(), va)) + wa = interior(on_architecture(CPU(), wa)) + ca = interior(on_architecture(CPU(), ca)) + ηa = interior(on_architecture(CPU(), ηa)) + + u = interior(on_architecture(CPU(), u)) + v = interior(on_architecture(CPU(), v)) + w = interior(on_architecture(CPU(), w)) + c = interior(on_architecture(CPU(), c)) + η = interior(on_architecture(CPU(), η)) + + atol = eps(eltype(immersed_grid)) + rtol = sqrt(eps(eltype(immersed_grid))) + + @test all(isapprox(u, ua; atol, rtol)) + @test all(isapprox(v, va; atol, rtol)) + @test all(isapprox(w, wa; atol, rtol)) + @test all(isapprox(c, ca; atol, rtol)) + @test all(isapprox(η, ηa; atol, rtol)) + end end -end +end \ No newline at end of file From ae0366d35527766beab17ebdbdeb835e8f39b01e Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Wed, 11 Dec 2024 13:08:04 +0100 Subject: [PATCH 39/60] fixed index launching --- src/Utils/kernel_launching.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Utils/kernel_launching.jl b/src/Utils/kernel_launching.jl index 8fc927efee..b9d1cce458 100644 --- a/src/Utils/kernel_launching.jl +++ b/src/Utils/kernel_launching.jl @@ -506,14 +506,14 @@ const MappedCompilerMetadata = CompilerMetadata{<:StaticSize, <:Any, <:Any, <:An return nI end -# To check whether the index is valid in the index map, we need to -# check whether the linear index is smaller than the size of the index map +# # To check whether the index is valid in the index map, we need to +# # check whether the linear index is smaller than the size of the index map @inline function __validindex(ctx::MappedCompilerMetadata, idx::CartesianIndex) # Turns this into a noop for code where we can turn of checkbounds of if __dynamic_checkbounds(ctx) index = @inbounds linear_index(__iterspace(ctx), __groupindex(ctx), idx) return index ≤ linear_ndrange(ctx) else - return false + return true end end \ No newline at end of file From b73ecbc0d90bc40d96491e757e3fd4c563850c65 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Wed, 11 Dec 2024 13:09:44 +0100 Subject: [PATCH 40/60] just test relevant tests --- .buildkite/distributed/pipeline.yml | 180 ++-- .buildkite/pipeline.yml | 1250 +++++++++++++-------------- test/runtests.jl | 6 +- 3 files changed, 718 insertions(+), 718 deletions(-) diff --git a/.buildkite/distributed/pipeline.yml b/.buildkite/distributed/pipeline.yml index 9f7869de63..7df94d1fd0 100644 --- a/.buildkite/distributed/pipeline.yml +++ b/.buildkite/distributed/pipeline.yml @@ -27,69 +27,69 @@ steps: - wait - - label: "🐉 cpu distributed unit tests" - key: "distributed_cpu" - env: - TEST_GROUP: "distributed" - MPI_TEST: "true" - commands: - - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - slurm_mem: 8G - slurm_ntasks: 4 - retry: - automatic: - - exit_status: 1 - limit: 1 + # - label: "🐉 cpu distributed unit tests" + # key: "distributed_cpu" + # env: + # TEST_GROUP: "distributed" + # MPI_TEST: "true" + # commands: + # - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + # agents: + # slurm_mem: 8G + # slurm_ntasks: 4 + # retry: + # automatic: + # - exit_status: 1 + # limit: 1 - - label: "🐲 gpu distributed unit tests" - key: "distributed_gpu" - env: - TEST_GROUP: "distributed" - GPU_TEST: "true" - MPI_TEST: "true" - commands: - - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - slurm_mem: 8G - slurm_ntasks: 4 - slurm_gpus_per_task: 1 - retry: - automatic: - - exit_status: 1 - limit: 1 + # - label: "🐲 gpu distributed unit tests" + # key: "distributed_gpu" + # env: + # TEST_GROUP: "distributed" + # GPU_TEST: "true" + # MPI_TEST: "true" + # commands: + # - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + # agents: + # slurm_mem: 8G + # slurm_ntasks: 4 + # slurm_gpus_per_task: 1 + # retry: + # automatic: + # - exit_status: 1 + # limit: 1 - - label: "🦾 cpu distributed solvers tests" - key: "distributed_solvers_cpu" - env: - TEST_GROUP: "distributed_solvers" - MPI_TEST: "true" - commands: - - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - slurm_mem: 50G - slurm_ntasks: 4 - retry: - automatic: - - exit_status: 1 - limit: 1 + # - label: "🦾 cpu distributed solvers tests" + # key: "distributed_solvers_cpu" + # env: + # TEST_GROUP: "distributed_solvers" + # MPI_TEST: "true" + # commands: + # - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + # agents: + # slurm_mem: 50G + # slurm_ntasks: 4 + # retry: + # automatic: + # - exit_status: 1 + # limit: 1 - - label: "🛸 gpu distributed solvers tests" - key: "distributed_solvers_gpu" - env: - TEST_GROUP: "distributed_solvers" - GPU_TEST: "true" - MPI_TEST: "true" - commands: - - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - slurm_mem: 50G - slurm_ntasks: 4 - slurm_gpus_per_task: 1 - retry: - automatic: - - exit_status: 1 - limit: 1 + # - label: "🛸 gpu distributed solvers tests" + # key: "distributed_solvers_gpu" + # env: + # TEST_GROUP: "distributed_solvers" + # GPU_TEST: "true" + # MPI_TEST: "true" + # commands: + # - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + # agents: + # slurm_mem: 50G + # slurm_ntasks: 4 + # slurm_gpus_per_task: 1 + # retry: + # automatic: + # - exit_status: 1 + # limit: 1 - label: "🤺 cpu distributed hydrostatic model tests" key: "distributed_hydrostatic_model_cpu" @@ -123,37 +123,37 @@ steps: - exit_status: 1 limit: 1 - - label: "🦍 cpu distributed nonhydrostatic regression" - key: "distributed_nonhydrostatic_regression_cpu" - env: - TEST_GROUP: "distributed_nonhydrostatic_regression" - MPI_TEST: "true" - commands: - - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - slurm_mem: 50G - slurm_ntasks: 4 - retry: - automatic: - - exit_status: 1 - limit: 1 + # - label: "🦍 cpu distributed nonhydrostatic regression" + # key: "distributed_nonhydrostatic_regression_cpu" + # env: + # TEST_GROUP: "distributed_nonhydrostatic_regression" + # MPI_TEST: "true" + # commands: + # - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + # agents: + # slurm_mem: 50G + # slurm_ntasks: 4 + # retry: + # automatic: + # - exit_status: 1 + # limit: 1 - - label: "🕺 gpu distributed nonhydrostatic regression" - key: "distributed_nonhydrostatic_regression_gpu" - env: - TEST_GROUP: "distributed_nonhydrostatic_regression" - GPU_TEST: "true" - MPI_TEST: "true" - commands: - - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - slurm_mem: 50G - slurm_ntasks: 4 - slurm_gpus_per_task: 1 - retry: - automatic: - - exit_status: 1 - limit: 1 + # - label: "🕺 gpu distributed nonhydrostatic regression" + # key: "distributed_nonhydrostatic_regression_gpu" + # env: + # TEST_GROUP: "distributed_nonhydrostatic_regression" + # GPU_TEST: "true" + # MPI_TEST: "true" + # commands: + # - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + # agents: + # slurm_mem: 50G + # slurm_ntasks: 4 + # slurm_gpus_per_task: 1 + # retry: + # automatic: + # - exit_status: 1 + # limit: 1 - wait diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index d8dc9987da..e1910b4fd8 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -51,164 +51,164 @@ steps: ##### Unit tests ##### - - label: "🐿️ gpu unit tests" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "unit" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "🐇 cpu unit tests" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "unit" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" - -##### -##### Solver tests -##### - - - label: "🦅 gpu poisson solver tests 1" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "poisson_solvers_1" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "🕊️ cpu poisson solver tests 1" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "poisson_solvers_1" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" - - - label: "🦖 gpu poisson solver tests 2" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "poisson_solvers_2" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "🦕 cpu poisson solver tests 2" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "poisson_solvers_2" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" - - - label: "🌷 gpu matrix poisson solver tests" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "matrix_poisson_solvers" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "🌹 cpu matrix poisson solver tests" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "matrix_poisson_solvers" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" - - - label: "🦤 gpu general solver tests" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "general_solvers" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "🦃 cpu general solver tests" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "general_solvers" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" +# - label: "🐿️ gpu unit tests" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "unit" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "🐇 cpu unit tests" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "unit" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" + +# ##### +# ##### Solver tests +# ##### + +# - label: "🦅 gpu poisson solver tests 1" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "poisson_solvers_1" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "🕊️ cpu poisson solver tests 1" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "poisson_solvers_1" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" + +# - label: "🦖 gpu poisson solver tests 2" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "poisson_solvers_2" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "🦕 cpu poisson solver tests 2" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "poisson_solvers_2" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" + +# - label: "🌷 gpu matrix poisson solver tests" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "matrix_poisson_solvers" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "🌹 cpu matrix poisson solver tests" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "matrix_poisson_solvers" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" + +# - label: "🦤 gpu general solver tests" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "general_solvers" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "🦃 cpu general solver tests" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "general_solvers" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" ##### ##### NonhydrostaticModel and time stepping (part 1) @@ -249,473 +249,473 @@ steps: ##### NonhydrostaticModel and time stepping (part 2) ##### - - label: "🦈 gpu time stepping tests 2" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "time_stepping_2" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "🐬 cpu time stepping tests 2" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "time_stepping_2" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" - -##### -##### NonhydrostaticModel and time stepping (part 3) -##### - - - label: "🦟 gpu time stepping tests 3" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "time_stepping_3" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "🦗 cpu time stepping tests 3" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "time_stepping_3" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" - -##### -##### Turbulence Closures -##### - - - label: "🎣 gpu turbulence closures" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "turbulence_closures" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "🎏 cpu turbulence closures" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "turbulence_closures" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" - -##### -##### HydrostaticFreeSurfaceModel -##### - - - label: "🐙 gpu hydrostatic free surface model tests" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "hydrostatic_free_surface" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "🦑 cpu hydrostatic free surface model tests" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "hydrostatic_free_surface" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" - -##### -##### ShallowWaterModel -##### - - - label: "🦢 gpu shallow water model tests" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "shallow_water" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "🦆 cpu shallow water model tests" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "shallow_water" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" - -##### -##### Simulation -##### - - - label: "🐳 gpu simulation tests" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "simulation" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "🐋 cpu simulation tests" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "simulation" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" - -##### -##### Lagrangian particles tracking -##### - - - label: "🍂 gpu lagrangian particles tests" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "lagrangian" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "🍃 cpu lagrangian particles tests" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "lagrangian" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" - -##### -##### AbstractOperations -##### - - - label: "👻 gpu abstract operations tests" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "abstract_operations" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "🤖 cpu abstract operations tests" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "abstract_operations" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" - -##### -##### Multi-Region -##### - - - label: "🧅 gpu multi region tests" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "multi_region" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "🧄 cpu multi region tests" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "multi_region" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" - -##### -##### Regression -##### - - - label: "🐫 gpu nonhydrostatic regression tests" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "nonhydrostatic_regression" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "🐪 cpu nonhydrostatic regression tests" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "nonhydrostatic_regression" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" - - - label: "🙈 gpu hydrostatic regression tests" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "hydrostatic_regression" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "🙉 cpu hydrostatic regression tests" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "hydrostatic_regression" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" - -##### -##### Scripts -##### - - - label: "🦧 gpu scripts" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "scripts" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "🦍 cpu scripts" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "scripts" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" - -##### -##### Enzyme extension tests -##### - - - label: "👺 gpu Enzyme extension tests" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "enzyme" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "👹 cpu Enzyme extension tests" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "enzyme" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" - -##### -##### Documentation -##### - - - label: "🦉 documentation" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - CUDA_VISIBLE_DEVICES: "0" - JULIA_DEBUG: "Documenter" - TMPDIR: "$TARTARUS_HOME/tmp" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia --color=yes --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'" - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia --color=yes --project=docs/ docs/make.jl" - agents: - queue: Oceananigans - architecture: CPU - depends_on: "init_cpu" - - - wait: ~ - continue_on_failure: true +# - label: "🦈 gpu time stepping tests 2" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "time_stepping_2" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "🐬 cpu time stepping tests 2" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "time_stepping_2" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" + +# ##### +# ##### NonhydrostaticModel and time stepping (part 3) +# ##### + +# - label: "🦟 gpu time stepping tests 3" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "time_stepping_3" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "🦗 cpu time stepping tests 3" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "time_stepping_3" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" + +# ##### +# ##### Turbulence Closures +# ##### + +# - label: "🎣 gpu turbulence closures" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "turbulence_closures" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "🎏 cpu turbulence closures" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "turbulence_closures" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" + +# ##### +# ##### HydrostaticFreeSurfaceModel +# ##### + +# - label: "🐙 gpu hydrostatic free surface model tests" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "hydrostatic_free_surface" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "🦑 cpu hydrostatic free surface model tests" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "hydrostatic_free_surface" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" + +# ##### +# ##### ShallowWaterModel +# ##### + +# - label: "🦢 gpu shallow water model tests" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "shallow_water" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "🦆 cpu shallow water model tests" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "shallow_water" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" + +# ##### +# ##### Simulation +# ##### + +# - label: "🐳 gpu simulation tests" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "simulation" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "🐋 cpu simulation tests" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "simulation" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" + +# ##### +# ##### Lagrangian particles tracking +# ##### + +# - label: "🍂 gpu lagrangian particles tests" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "lagrangian" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "🍃 cpu lagrangian particles tests" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "lagrangian" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" + +# ##### +# ##### AbstractOperations +# ##### + +# - label: "👻 gpu abstract operations tests" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "abstract_operations" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "🤖 cpu abstract operations tests" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "abstract_operations" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" + +# ##### +# ##### Multi-Region +# ##### + +# - label: "🧅 gpu multi region tests" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "multi_region" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "🧄 cpu multi region tests" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "multi_region" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" + +# ##### +# ##### Regression +# ##### + +# - label: "🐫 gpu nonhydrostatic regression tests" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "nonhydrostatic_regression" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "🐪 cpu nonhydrostatic regression tests" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "nonhydrostatic_regression" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" + +# - label: "🙈 gpu hydrostatic regression tests" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "hydrostatic_regression" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "🙉 cpu hydrostatic regression tests" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "hydrostatic_regression" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" + +# ##### +# ##### Scripts +# ##### + +# - label: "🦧 gpu scripts" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "scripts" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "🦍 cpu scripts" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "scripts" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" + +# ##### +# ##### Enzyme extension tests +# ##### + +# - label: "👺 gpu Enzyme extension tests" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "enzyme" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "👹 cpu Enzyme extension tests" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "enzyme" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" + +# ##### +# ##### Documentation +# ##### + +# - label: "🦉 documentation" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# CUDA_VISIBLE_DEVICES: "0" +# JULIA_DEBUG: "Documenter" +# TMPDIR: "$TARTARUS_HOME/tmp" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia --color=yes --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'" +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia --color=yes --project=docs/ docs/make.jl" +# agents: +# queue: Oceananigans +# architecture: CPU +# depends_on: "init_cpu" + +# - wait: ~ +# continue_on_failure: true ##### ##### Clean up diff --git a/test/runtests.jl b/test/runtests.jl index 1ad3a5caab..2b740cee58 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -118,8 +118,8 @@ CUDA.allowscalar() do # Models if group == :time_stepping_1 || group == :all @testset "Model and time stepping tests (part 1)" begin - include("test_nonhydrostatic_models.jl") - include("test_time_stepping.jl") + # include("test_nonhydrostatic_models.jl") + # include("test_time_stepping.jl") include("test_active_cells_map.jl") end end @@ -194,7 +194,7 @@ CUDA.allowscalar() do # In case CUDA is not found, we reset CUDA and restart the julia session reset_cuda_if_necessary() archs = test_architectures() - include("test_hydrostatic_regression.jl") + # include("test_hydrostatic_regression.jl") include("test_distributed_hydrostatic_model.jl") end From d6853451832d1d8c35faadf1ae092a9afbbb78a7 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Wed, 11 Dec 2024 13:34:31 +0100 Subject: [PATCH 41/60] change comment --- .../compute_hydrostatic_free_surface_buffers.jl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_buffers.jl b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_buffers.jl index 0db6045cbc..6c1e39ad60 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_buffers.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_buffers.jl @@ -42,9 +42,8 @@ function compute_buffer_tendency_contributions!(grid::DistributedActiveCellsIBG, map = @inbounds maps[name] - # If there exists a buffer map, then we compute the buffer contributions. If not, the - # buffer contributions have already been calculated. We exclude the interior because it has - # already been calculated + # If the map == nothing, we don't need to compute the buffer because + # the buffer is not adjacent to a processor boundary if !isnothing(map) active_cells_map = retrieve_interior_active_cells_map(grid, Val(name)) compute_hydrostatic_free_surface_tendency_contributions!(model, :xyz; active_cells_map) From 00eac7915b5df7876520be5b9c6ab86586b5cdb5 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Wed, 11 Dec 2024 13:39:16 +0100 Subject: [PATCH 42/60] better --- kernel_maps.jl | 0 .../compute_hydrostatic_free_surface_buffers.jl | 7 ++----- 2 files changed, 2 insertions(+), 5 deletions(-) delete mode 100644 kernel_maps.jl diff --git a/kernel_maps.jl b/kernel_maps.jl deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_buffers.jl b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_buffers.jl index 6c1e39ad60..83c8a4af0e 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_buffers.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_buffers.jl @@ -40,14 +40,11 @@ function compute_buffer_tendency_contributions!(grid::DistributedActiveCellsIBG, :south_dependent_halo_cells, :north_dependent_halo_cells) - map = @inbounds maps[name] + active_cells_map = @inbounds maps[name] # If the map == nothing, we don't need to compute the buffer because # the buffer is not adjacent to a processor boundary - if !isnothing(map) - active_cells_map = retrieve_interior_active_cells_map(grid, Val(name)) - compute_hydrostatic_free_surface_tendency_contributions!(model, :xyz; active_cells_map) - end + !isnothing(map) && compute_hydrostatic_free_surface_tendency_contributions!(model, :xyz; active_cells_map) end return nothing From 1ebb694cfedba6e9660cc4cfe67d2631ed8432c1 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Wed, 11 Dec 2024 13:56:16 +0100 Subject: [PATCH 43/60] it works. Back to the complete test suite. --- .buildkite/distributed/pipeline.yml | 180 +-- .buildkite/pipeline.yml | 1250 ++++++++--------- .../immersed_grid_metrics.jl | 3 +- test.jl | 18 - test/runtests.jl | 6 +- test/test_active_cells_map.jl | 47 +- test/test_distributed_hydrostatic_model.jl | 51 +- test/utils_for_runtests.jl | 49 +- 8 files changed, 773 insertions(+), 831 deletions(-) delete mode 100644 test.jl diff --git a/.buildkite/distributed/pipeline.yml b/.buildkite/distributed/pipeline.yml index 7df94d1fd0..9f7869de63 100644 --- a/.buildkite/distributed/pipeline.yml +++ b/.buildkite/distributed/pipeline.yml @@ -27,69 +27,69 @@ steps: - wait - # - label: "🐉 cpu distributed unit tests" - # key: "distributed_cpu" - # env: - # TEST_GROUP: "distributed" - # MPI_TEST: "true" - # commands: - # - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - # agents: - # slurm_mem: 8G - # slurm_ntasks: 4 - # retry: - # automatic: - # - exit_status: 1 - # limit: 1 + - label: "🐉 cpu distributed unit tests" + key: "distributed_cpu" + env: + TEST_GROUP: "distributed" + MPI_TEST: "true" + commands: + - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + slurm_mem: 8G + slurm_ntasks: 4 + retry: + automatic: + - exit_status: 1 + limit: 1 - # - label: "🐲 gpu distributed unit tests" - # key: "distributed_gpu" - # env: - # TEST_GROUP: "distributed" - # GPU_TEST: "true" - # MPI_TEST: "true" - # commands: - # - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - # agents: - # slurm_mem: 8G - # slurm_ntasks: 4 - # slurm_gpus_per_task: 1 - # retry: - # automatic: - # - exit_status: 1 - # limit: 1 + - label: "🐲 gpu distributed unit tests" + key: "distributed_gpu" + env: + TEST_GROUP: "distributed" + GPU_TEST: "true" + MPI_TEST: "true" + commands: + - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + slurm_mem: 8G + slurm_ntasks: 4 + slurm_gpus_per_task: 1 + retry: + automatic: + - exit_status: 1 + limit: 1 - # - label: "🦾 cpu distributed solvers tests" - # key: "distributed_solvers_cpu" - # env: - # TEST_GROUP: "distributed_solvers" - # MPI_TEST: "true" - # commands: - # - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - # agents: - # slurm_mem: 50G - # slurm_ntasks: 4 - # retry: - # automatic: - # - exit_status: 1 - # limit: 1 + - label: "🦾 cpu distributed solvers tests" + key: "distributed_solvers_cpu" + env: + TEST_GROUP: "distributed_solvers" + MPI_TEST: "true" + commands: + - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + slurm_mem: 50G + slurm_ntasks: 4 + retry: + automatic: + - exit_status: 1 + limit: 1 - # - label: "🛸 gpu distributed solvers tests" - # key: "distributed_solvers_gpu" - # env: - # TEST_GROUP: "distributed_solvers" - # GPU_TEST: "true" - # MPI_TEST: "true" - # commands: - # - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - # agents: - # slurm_mem: 50G - # slurm_ntasks: 4 - # slurm_gpus_per_task: 1 - # retry: - # automatic: - # - exit_status: 1 - # limit: 1 + - label: "🛸 gpu distributed solvers tests" + key: "distributed_solvers_gpu" + env: + TEST_GROUP: "distributed_solvers" + GPU_TEST: "true" + MPI_TEST: "true" + commands: + - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + slurm_mem: 50G + slurm_ntasks: 4 + slurm_gpus_per_task: 1 + retry: + automatic: + - exit_status: 1 + limit: 1 - label: "🤺 cpu distributed hydrostatic model tests" key: "distributed_hydrostatic_model_cpu" @@ -123,37 +123,37 @@ steps: - exit_status: 1 limit: 1 - # - label: "🦍 cpu distributed nonhydrostatic regression" - # key: "distributed_nonhydrostatic_regression_cpu" - # env: - # TEST_GROUP: "distributed_nonhydrostatic_regression" - # MPI_TEST: "true" - # commands: - # - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - # agents: - # slurm_mem: 50G - # slurm_ntasks: 4 - # retry: - # automatic: - # - exit_status: 1 - # limit: 1 + - label: "🦍 cpu distributed nonhydrostatic regression" + key: "distributed_nonhydrostatic_regression_cpu" + env: + TEST_GROUP: "distributed_nonhydrostatic_regression" + MPI_TEST: "true" + commands: + - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + slurm_mem: 50G + slurm_ntasks: 4 + retry: + automatic: + - exit_status: 1 + limit: 1 - # - label: "🕺 gpu distributed nonhydrostatic regression" - # key: "distributed_nonhydrostatic_regression_gpu" - # env: - # TEST_GROUP: "distributed_nonhydrostatic_regression" - # GPU_TEST: "true" - # MPI_TEST: "true" - # commands: - # - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - # agents: - # slurm_mem: 50G - # slurm_ntasks: 4 - # slurm_gpus_per_task: 1 - # retry: - # automatic: - # - exit_status: 1 - # limit: 1 + - label: "🕺 gpu distributed nonhydrostatic regression" + key: "distributed_nonhydrostatic_regression_gpu" + env: + TEST_GROUP: "distributed_nonhydrostatic_regression" + GPU_TEST: "true" + MPI_TEST: "true" + commands: + - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + slurm_mem: 50G + slurm_ntasks: 4 + slurm_gpus_per_task: 1 + retry: + automatic: + - exit_status: 1 + limit: 1 - wait diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index e1910b4fd8..d8dc9987da 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -51,164 +51,164 @@ steps: ##### Unit tests ##### -# - label: "🐿️ gpu unit tests" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "unit" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "🐇 cpu unit tests" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "unit" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" - -# ##### -# ##### Solver tests -# ##### - -# - label: "🦅 gpu poisson solver tests 1" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "poisson_solvers_1" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "🕊️ cpu poisson solver tests 1" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "poisson_solvers_1" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" - -# - label: "🦖 gpu poisson solver tests 2" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "poisson_solvers_2" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "🦕 cpu poisson solver tests 2" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "poisson_solvers_2" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" - -# - label: "🌷 gpu matrix poisson solver tests" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "matrix_poisson_solvers" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "🌹 cpu matrix poisson solver tests" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "matrix_poisson_solvers" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" - -# - label: "🦤 gpu general solver tests" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "general_solvers" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "🦃 cpu general solver tests" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "general_solvers" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" + - label: "🐿️ gpu unit tests" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "unit" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "🐇 cpu unit tests" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "unit" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" + +##### +##### Solver tests +##### + + - label: "🦅 gpu poisson solver tests 1" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "poisson_solvers_1" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "🕊️ cpu poisson solver tests 1" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "poisson_solvers_1" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" + + - label: "🦖 gpu poisson solver tests 2" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "poisson_solvers_2" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "🦕 cpu poisson solver tests 2" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "poisson_solvers_2" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" + + - label: "🌷 gpu matrix poisson solver tests" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "matrix_poisson_solvers" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "🌹 cpu matrix poisson solver tests" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "matrix_poisson_solvers" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" + + - label: "🦤 gpu general solver tests" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "general_solvers" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "🦃 cpu general solver tests" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "general_solvers" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" ##### ##### NonhydrostaticModel and time stepping (part 1) @@ -249,473 +249,473 @@ steps: ##### NonhydrostaticModel and time stepping (part 2) ##### -# - label: "🦈 gpu time stepping tests 2" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "time_stepping_2" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "🐬 cpu time stepping tests 2" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "time_stepping_2" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" - -# ##### -# ##### NonhydrostaticModel and time stepping (part 3) -# ##### - -# - label: "🦟 gpu time stepping tests 3" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "time_stepping_3" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "🦗 cpu time stepping tests 3" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "time_stepping_3" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" - -# ##### -# ##### Turbulence Closures -# ##### - -# - label: "🎣 gpu turbulence closures" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "turbulence_closures" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "🎏 cpu turbulence closures" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "turbulence_closures" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" - -# ##### -# ##### HydrostaticFreeSurfaceModel -# ##### - -# - label: "🐙 gpu hydrostatic free surface model tests" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "hydrostatic_free_surface" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "🦑 cpu hydrostatic free surface model tests" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "hydrostatic_free_surface" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" - -# ##### -# ##### ShallowWaterModel -# ##### - -# - label: "🦢 gpu shallow water model tests" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "shallow_water" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "🦆 cpu shallow water model tests" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "shallow_water" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" - -# ##### -# ##### Simulation -# ##### - -# - label: "🐳 gpu simulation tests" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "simulation" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "🐋 cpu simulation tests" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "simulation" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" - -# ##### -# ##### Lagrangian particles tracking -# ##### - -# - label: "🍂 gpu lagrangian particles tests" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "lagrangian" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "🍃 cpu lagrangian particles tests" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "lagrangian" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" - -# ##### -# ##### AbstractOperations -# ##### - -# - label: "👻 gpu abstract operations tests" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "abstract_operations" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "🤖 cpu abstract operations tests" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "abstract_operations" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" - -# ##### -# ##### Multi-Region -# ##### - -# - label: "🧅 gpu multi region tests" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "multi_region" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "🧄 cpu multi region tests" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "multi_region" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" - -# ##### -# ##### Regression -# ##### - -# - label: "🐫 gpu nonhydrostatic regression tests" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "nonhydrostatic_regression" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "🐪 cpu nonhydrostatic regression tests" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "nonhydrostatic_regression" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" - -# - label: "🙈 gpu hydrostatic regression tests" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "hydrostatic_regression" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "🙉 cpu hydrostatic regression tests" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "hydrostatic_regression" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" - -# ##### -# ##### Scripts -# ##### - -# - label: "🦧 gpu scripts" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "scripts" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "🦍 cpu scripts" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "scripts" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" - -# ##### -# ##### Enzyme extension tests -# ##### - -# - label: "👺 gpu Enzyme extension tests" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "enzyme" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "👹 cpu Enzyme extension tests" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "enzyme" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" - -# ##### -# ##### Documentation -# ##### - -# - label: "🦉 documentation" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# CUDA_VISIBLE_DEVICES: "0" -# JULIA_DEBUG: "Documenter" -# TMPDIR: "$TARTARUS_HOME/tmp" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia --color=yes --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'" -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia --color=yes --project=docs/ docs/make.jl" -# agents: -# queue: Oceananigans -# architecture: CPU -# depends_on: "init_cpu" - -# - wait: ~ -# continue_on_failure: true + - label: "🦈 gpu time stepping tests 2" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "time_stepping_2" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "🐬 cpu time stepping tests 2" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "time_stepping_2" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" + +##### +##### NonhydrostaticModel and time stepping (part 3) +##### + + - label: "🦟 gpu time stepping tests 3" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "time_stepping_3" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "🦗 cpu time stepping tests 3" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "time_stepping_3" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" + +##### +##### Turbulence Closures +##### + + - label: "🎣 gpu turbulence closures" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "turbulence_closures" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "🎏 cpu turbulence closures" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "turbulence_closures" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" + +##### +##### HydrostaticFreeSurfaceModel +##### + + - label: "🐙 gpu hydrostatic free surface model tests" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "hydrostatic_free_surface" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "🦑 cpu hydrostatic free surface model tests" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "hydrostatic_free_surface" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" + +##### +##### ShallowWaterModel +##### + + - label: "🦢 gpu shallow water model tests" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "shallow_water" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "🦆 cpu shallow water model tests" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "shallow_water" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" + +##### +##### Simulation +##### + + - label: "🐳 gpu simulation tests" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "simulation" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "🐋 cpu simulation tests" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "simulation" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" + +##### +##### Lagrangian particles tracking +##### + + - label: "🍂 gpu lagrangian particles tests" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "lagrangian" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "🍃 cpu lagrangian particles tests" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "lagrangian" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" + +##### +##### AbstractOperations +##### + + - label: "👻 gpu abstract operations tests" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "abstract_operations" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "🤖 cpu abstract operations tests" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "abstract_operations" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" + +##### +##### Multi-Region +##### + + - label: "🧅 gpu multi region tests" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "multi_region" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "🧄 cpu multi region tests" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "multi_region" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" + +##### +##### Regression +##### + + - label: "🐫 gpu nonhydrostatic regression tests" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "nonhydrostatic_regression" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "🐪 cpu nonhydrostatic regression tests" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "nonhydrostatic_regression" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" + + - label: "🙈 gpu hydrostatic regression tests" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "hydrostatic_regression" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "🙉 cpu hydrostatic regression tests" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "hydrostatic_regression" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" + +##### +##### Scripts +##### + + - label: "🦧 gpu scripts" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "scripts" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "🦍 cpu scripts" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "scripts" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" + +##### +##### Enzyme extension tests +##### + + - label: "👺 gpu Enzyme extension tests" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "enzyme" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "👹 cpu Enzyme extension tests" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "enzyme" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" + +##### +##### Documentation +##### + + - label: "🦉 documentation" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + CUDA_VISIBLE_DEVICES: "0" + JULIA_DEBUG: "Documenter" + TMPDIR: "$TARTARUS_HOME/tmp" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia --color=yes --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'" + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia --color=yes --project=docs/ docs/make.jl" + agents: + queue: Oceananigans + architecture: CPU + depends_on: "init_cpu" + + - wait: ~ + continue_on_failure: true ##### ##### Clean up diff --git a/src/ImmersedBoundaries/immersed_grid_metrics.jl b/src/ImmersedBoundaries/immersed_grid_metrics.jl index 240a3668cc..b18fc7609a 100644 --- a/src/ImmersedBoundaries/immersed_grid_metrics.jl +++ b/src/ImmersedBoundaries/immersed_grid_metrics.jl @@ -1,7 +1,6 @@ using Oceananigans.AbstractOperations: GridMetricOperation -import Oceananigans.Grids: coordinates -import Oceananigans.Operators: Δrᵃᵃᶠ, Δrᵃᵃᶜ +import Oceananigans.Operators: Δrᵃᵃᶠ, Δrᵃᵃᶜ, Δzᵃᵃᶠ, Δzᵃᵃᶜ import Oceananigans.Operators: Δxᶠᵃᵃ, Δxᶜᵃᵃ, Δxᶠᶜᵃ, Δxᶜᶠᵃ, Δxᶠᶠᵃ, Δxᶜᶜᵃ import Oceananigans.Operators: Δyᵃᶠᵃ, Δyᵃᶜᵃ, Δyᶠᶜᵃ, Δyᶜᶠᵃ, Δyᶠᶠᵃ, Δyᶜᶜᵃ import Oceananigans.Operators: Azᶠᶜᵃ, Azᶜᶠᵃ, Azᶠᶠᵃ, Azᶜᶜᵃ diff --git a/test.jl b/test.jl deleted file mode 100644 index 70239fa292..0000000000 --- a/test.jl +++ /dev/null @@ -1,18 +0,0 @@ -using Revise -using Oceananigans -using Oceananigans.Utils - -using KernelAbstractions: @index, @kernel - -arch = CPU() - -@kernel function _test_indices(a) - i, j, k = @index(Global, NTuple) - a[i, j, k] = i + j + k -end - -grid = RectilinearGrid(arch, size = (3, 3, 3), extent = (1, 1, 1)) -array = zeros(arch, 3, 3, 3) -imap = on_architecture(arch, [(i, j, k) for i in 1:3, j in 1:3, k in 1:2]) - -launch!(arch, grid_cpu, :xyz, _test_indices, array; active_cells_map = imap) \ No newline at end of file diff --git a/test/runtests.jl b/test/runtests.jl index 2b740cee58..1ad3a5caab 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -118,8 +118,8 @@ CUDA.allowscalar() do # Models if group == :time_stepping_1 || group == :all @testset "Model and time stepping tests (part 1)" begin - # include("test_nonhydrostatic_models.jl") - # include("test_time_stepping.jl") + include("test_nonhydrostatic_models.jl") + include("test_time_stepping.jl") include("test_active_cells_map.jl") end end @@ -194,7 +194,7 @@ CUDA.allowscalar() do # In case CUDA is not found, we reset CUDA and restart the julia session reset_cuda_if_necessary() archs = test_architectures() - # include("test_hydrostatic_regression.jl") + include("test_hydrostatic_regression.jl") include("test_distributed_hydrostatic_model.jl") end diff --git a/test/test_active_cells_map.jl b/test/test_active_cells_map.jl index 2084755093..272f96fbe3 100644 --- a/test/test_active_cells_map.jl +++ b/test/test_active_cells_map.jl @@ -5,50 +5,6 @@ using Oceananigans.ImmersedBoundaries: retrieve_surface_active_cells_map, retrieve_interior_active_cells_map, immersed_cell -function Δ_min(grid) - Δx_min = minimum_xspacing(grid, Center(), Center(), Center()) - Δy_min = minimum_yspacing(grid, Center(), Center(), Center()) - return min(Δx_min, Δy_min) -end - -@inline Gaussian(x, y, L) = exp(-(x^2 + y^2) / L^2) - -function solid_body_rotation_test(grid) - - free_surface = SplitExplicitFreeSurface(grid; substeps = 10, gravitational_acceleration = 1) - coriolis = HydrostaticSphericalCoriolis(rotation_rate = 1) - - model = HydrostaticFreeSurfaceModel(; grid, - momentum_advection = VectorInvariant(), - free_surface = free_surface, - coriolis = coriolis, - tracers = :c, - tracer_advection = WENO(), - buoyancy = nothing, - closure = nothing) - - g = model.free_surface.gravitational_acceleration - R = grid.radius - Ω = model.coriolis.rotation_rate - - uᵢ(λ, φ, z) = 0.1 * cosd(φ) * sind(λ) - ηᵢ(λ, φ, z) = (R * Ω * 0.1 + 0.1^2 / 2) * sind(φ)^2 / g * sind(λ) - - # Gaussian leads to values with O(1e-60), - # too small for repetible testing. We cap it at 0.1 - cᵢ(λ, φ, z) = max(Gaussian(λ, φ - 5, 10), 0.1) - vᵢ(λ, φ, z) = 0.1 - - set!(model, u=uᵢ, η=ηᵢ, c=cᵢ) - - Δt = 0.1 * Δ_min(grid) / sqrt(g * grid.Lz) - - simulation = Simulation(model; Δt, stop_iteration = 10) - run!(simulation) - - return merge(model.velocities, model.tracers, (; η = model.free_surface.η)) -end - Nx = 16 Ny = 16 Nz = 10 @@ -66,9 +22,10 @@ Nz = 10 # Make sure the bottom is the same bottom_height = zeros(Nx, Ny) for i in 1:Nx, j in 1:Ny - bottom_height[i, j] = - rand() * 5 - 5 + bottom_height[i, j] = - rand() * 10 end + bottom_height = on_architecture(arch, bottom_height) immersed_grid = ImmersedBoundaryGrid(underlying_grid, GridFittedBottom(bottom_height)) immersed_active_grid = ImmersedBoundaryGrid(underlying_grid, GridFittedBottom(bottom_height); active_cells_map = true) diff --git a/test/test_distributed_hydrostatic_model.jl b/test/test_distributed_hydrostatic_model.jl index 7c2689ab99..c46f6f148d 100644 --- a/test/test_distributed_hydrostatic_model.jl +++ b/test/test_distributed_hydrostatic_model.jl @@ -26,52 +26,7 @@ MPI.Initialized() || MPI.Init() # to initialize MPI. using Oceananigans.Operators: hack_cosd -using Oceananigans.DistributedComputations: partition, all_reduce, cpu_architecture, reconstruct_global_grid - -function Δ_min(grid) - Δx_min = minimum_xspacing(grid, Center(), Center(), Center()) - Δy_min = minimum_yspacing(grid, Center(), Center(), Center()) - return min(Δx_min, Δy_min) -end - -@inline Gaussian(x, y, L) = exp(-(x^2 + y^2) / L^2) - -function solid_body_rotation_test(grid) - - free_surface = SplitExplicitFreeSurface(grid; substeps = 5, gravitational_acceleration = 1) - coriolis = HydrostaticSphericalCoriolis(rotation_rate = 1) - - model = HydrostaticFreeSurfaceModel(; grid, - momentum_advection = VectorInvariant(), - free_surface = free_surface, - coriolis = coriolis, - tracers = :c, - tracer_advection = WENO(), - buoyancy = nothing, - closure = nothing) - - g = model.free_surface.gravitational_acceleration - R = grid.radius - Ω = model.coriolis.rotation_rate - - uᵢ(λ, φ, z) = 0.1 * cosd(φ) * sind(λ) - ηᵢ(λ, φ, z) = (R * Ω * 0.1 + 0.1^2 / 2) * sind(φ)^2 / g * sind(λ) - - # Gaussian leads to values with O(1e-60), - # too small for repetible testing. We cap it at 0.1 - cᵢ(λ, φ, z) = max(Gaussian(λ, φ - 5, 10), 0.1) - vᵢ(λ, φ, z) = 0.1 - - set!(model, u=uᵢ, η=ηᵢ, c=cᵢ) - - @show Δt_local = 0.1 * Δ_min(grid) / sqrt(g * grid.Lz) - @show Δt = all_reduce(min, Δt_local, architecture(grid)) - - simulation = Simulation(model; Δt, stop_iteration = 10) - run!(simulation) - - return merge(model.velocities, model.tracers, (; η = model.free_surface.η)) -end +using Oceananigans.DistributedComputations: partition, cpu_architecture, reconstruct_global_grid Nx = 32 Ny = 32 @@ -94,7 +49,9 @@ for arch in archs global_underlying_grid = reconstruct_global_grid(underlying_grid) global_immersed_grid = ImmersedBoundaryGrid(global_underlying_grid, GridFittedBottom(bottom)) - for (grid, global_grid) in zip((immersed_active_grid, immersed_grid), (global_immersed_grid, global_immersed_grid)) + for (grid, global_grid) in zip((underlying_grid, immersed_grid, immersed_active_grid), + (global_underlying_grid, global_immersed_grid, global_immersed_grid)) + @info " Testing distributed solid body rotation with architecture $arch on $(typeof(grid).name.wrapper)" u, v, w, c, η = solid_body_rotation_test(grid) diff --git a/test/utils_for_runtests.jl b/test/utils_for_runtests.jl index 11dc6ecd5e..15d661ff60 100644 --- a/test/utils_for_runtests.jl +++ b/test/utils_for_runtests.jl @@ -1,5 +1,6 @@ using Oceananigans.TimeSteppers: QuasiAdamsBashforth2TimeStepper, RungeKutta3TimeStepper, update_state! -using Oceananigans.DistributedComputations: Distributed, Partition, child_architecture, Fractional, Equal +using Oceananigans.DistributedComputations: Distributed, Partition, child_architecture, Fractional, Equal, all_reduce +using Oceananigans.TurbulenceClosures: VerticallyImplicitTimeDiscretization import Oceananigans.Fields: interior @@ -201,6 +202,52 @@ function run_script(replace_strings, script_name, script_filepath, module_suffix return true end +function Δ_min(grid) + Δx_min = minimum_xspacing(grid, Center(), Center(), Center()) + Δy_min = minimum_yspacing(grid, Center(), Center(), Center()) + return min(Δx_min, Δy_min) +end + +@inline Gaussian(x, y, L) = exp(-(x^2 + y^2) / L^2) + +function solid_body_rotation_test(grid) + + free_surface = SplitExplicitFreeSurface(grid; substeps = 10, gravitational_acceleration = 1) + coriolis = HydrostaticSphericalCoriolis(rotation_rate = 1) + closure = VerticalScalarDiffusivity(VerticallyImplicitTimeDiscretization(), ν = 0.01, κ = 0.01) + + model = HydrostaticFreeSurfaceModel(; grid, + momentum_advection = VectorInvariant(), + free_surface = free_surface, + coriolis = coriolis, + tracers = :c, + tracer_advection = WENO(), + buoyancy = nothing, + closure) + + g = model.free_surface.gravitational_acceleration + R = grid.radius + Ω = model.coriolis.rotation_rate + + uᵢ(λ, φ, z) = 0.1 * cosd(φ) * sind(λ) + ηᵢ(λ, φ, z) = (R * Ω * 0.1 + 0.1^2 / 2) * sind(φ)^2 / g * sind(λ) + + # Gaussian leads to values with O(1e-60), + # too small for repetible testing. We cap it at 0.1 + cᵢ(λ, φ, z) = max(Gaussian(λ, φ - 5, 10), 0.1) + vᵢ(λ, φ, z) = 0.1 + + set!(model, u=uᵢ, η=ηᵢ, c=cᵢ) + + @show Δt_local = 0.1 * Δ_min(grid) / sqrt(g * grid.Lz) + @show Δt = all_reduce(min, Δt_local, architecture(grid)) + + simulation = Simulation(model; Δt, stop_iteration = 10) + run!(simulation) + + return merge(model.velocities, model.tracers, (; η = model.free_surface.η)) +end + ##### ##### Boundary condition utils ##### From bda1ad505d1342f60fbb77369d4b54dbeaf84c0c Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Wed, 11 Dec 2024 18:10:24 +0100 Subject: [PATCH 44/60] try again --- .buildkite/distributed/pipeline.yml | 180 ++-- .buildkite/pipeline.yml | 1208 +++++++++++++-------------- src/Utils/kernel_launching.jl | 11 +- test/runtests.jl | 6 +- 4 files changed, 701 insertions(+), 704 deletions(-) diff --git a/.buildkite/distributed/pipeline.yml b/.buildkite/distributed/pipeline.yml index 9f7869de63..7df94d1fd0 100644 --- a/.buildkite/distributed/pipeline.yml +++ b/.buildkite/distributed/pipeline.yml @@ -27,69 +27,69 @@ steps: - wait - - label: "🐉 cpu distributed unit tests" - key: "distributed_cpu" - env: - TEST_GROUP: "distributed" - MPI_TEST: "true" - commands: - - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - slurm_mem: 8G - slurm_ntasks: 4 - retry: - automatic: - - exit_status: 1 - limit: 1 + # - label: "🐉 cpu distributed unit tests" + # key: "distributed_cpu" + # env: + # TEST_GROUP: "distributed" + # MPI_TEST: "true" + # commands: + # - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + # agents: + # slurm_mem: 8G + # slurm_ntasks: 4 + # retry: + # automatic: + # - exit_status: 1 + # limit: 1 - - label: "🐲 gpu distributed unit tests" - key: "distributed_gpu" - env: - TEST_GROUP: "distributed" - GPU_TEST: "true" - MPI_TEST: "true" - commands: - - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - slurm_mem: 8G - slurm_ntasks: 4 - slurm_gpus_per_task: 1 - retry: - automatic: - - exit_status: 1 - limit: 1 + # - label: "🐲 gpu distributed unit tests" + # key: "distributed_gpu" + # env: + # TEST_GROUP: "distributed" + # GPU_TEST: "true" + # MPI_TEST: "true" + # commands: + # - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + # agents: + # slurm_mem: 8G + # slurm_ntasks: 4 + # slurm_gpus_per_task: 1 + # retry: + # automatic: + # - exit_status: 1 + # limit: 1 - - label: "🦾 cpu distributed solvers tests" - key: "distributed_solvers_cpu" - env: - TEST_GROUP: "distributed_solvers" - MPI_TEST: "true" - commands: - - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - slurm_mem: 50G - slurm_ntasks: 4 - retry: - automatic: - - exit_status: 1 - limit: 1 + # - label: "🦾 cpu distributed solvers tests" + # key: "distributed_solvers_cpu" + # env: + # TEST_GROUP: "distributed_solvers" + # MPI_TEST: "true" + # commands: + # - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + # agents: + # slurm_mem: 50G + # slurm_ntasks: 4 + # retry: + # automatic: + # - exit_status: 1 + # limit: 1 - - label: "🛸 gpu distributed solvers tests" - key: "distributed_solvers_gpu" - env: - TEST_GROUP: "distributed_solvers" - GPU_TEST: "true" - MPI_TEST: "true" - commands: - - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - slurm_mem: 50G - slurm_ntasks: 4 - slurm_gpus_per_task: 1 - retry: - automatic: - - exit_status: 1 - limit: 1 + # - label: "🛸 gpu distributed solvers tests" + # key: "distributed_solvers_gpu" + # env: + # TEST_GROUP: "distributed_solvers" + # GPU_TEST: "true" + # MPI_TEST: "true" + # commands: + # - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + # agents: + # slurm_mem: 50G + # slurm_ntasks: 4 + # slurm_gpus_per_task: 1 + # retry: + # automatic: + # - exit_status: 1 + # limit: 1 - label: "🤺 cpu distributed hydrostatic model tests" key: "distributed_hydrostatic_model_cpu" @@ -123,37 +123,37 @@ steps: - exit_status: 1 limit: 1 - - label: "🦍 cpu distributed nonhydrostatic regression" - key: "distributed_nonhydrostatic_regression_cpu" - env: - TEST_GROUP: "distributed_nonhydrostatic_regression" - MPI_TEST: "true" - commands: - - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - slurm_mem: 50G - slurm_ntasks: 4 - retry: - automatic: - - exit_status: 1 - limit: 1 + # - label: "🦍 cpu distributed nonhydrostatic regression" + # key: "distributed_nonhydrostatic_regression_cpu" + # env: + # TEST_GROUP: "distributed_nonhydrostatic_regression" + # MPI_TEST: "true" + # commands: + # - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + # agents: + # slurm_mem: 50G + # slurm_ntasks: 4 + # retry: + # automatic: + # - exit_status: 1 + # limit: 1 - - label: "🕺 gpu distributed nonhydrostatic regression" - key: "distributed_nonhydrostatic_regression_gpu" - env: - TEST_GROUP: "distributed_nonhydrostatic_regression" - GPU_TEST: "true" - MPI_TEST: "true" - commands: - - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - slurm_mem: 50G - slurm_ntasks: 4 - slurm_gpus_per_task: 1 - retry: - automatic: - - exit_status: 1 - limit: 1 + # - label: "🕺 gpu distributed nonhydrostatic regression" + # key: "distributed_nonhydrostatic_regression_gpu" + # env: + # TEST_GROUP: "distributed_nonhydrostatic_regression" + # GPU_TEST: "true" + # MPI_TEST: "true" + # commands: + # - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + # agents: + # slurm_mem: 50G + # slurm_ntasks: 4 + # slurm_gpus_per_task: 1 + # retry: + # automatic: + # - exit_status: 1 + # limit: 1 - wait diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index d8dc9987da..93f422b7bf 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -51,164 +51,164 @@ steps: ##### Unit tests ##### - - label: "🐿️ gpu unit tests" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "unit" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "🐇 cpu unit tests" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "unit" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" - -##### -##### Solver tests -##### - - - label: "🦅 gpu poisson solver tests 1" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "poisson_solvers_1" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "🕊️ cpu poisson solver tests 1" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "poisson_solvers_1" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" - - - label: "🦖 gpu poisson solver tests 2" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "poisson_solvers_2" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "🦕 cpu poisson solver tests 2" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "poisson_solvers_2" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" - - - label: "🌷 gpu matrix poisson solver tests" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "matrix_poisson_solvers" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "🌹 cpu matrix poisson solver tests" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "matrix_poisson_solvers" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" - - - label: "🦤 gpu general solver tests" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "general_solvers" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "🦃 cpu general solver tests" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "general_solvers" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" +# - label: "🐿️ gpu unit tests" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "unit" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "🐇 cpu unit tests" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "unit" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" + +# ##### +# ##### Solver tests +# ##### + +# - label: "🦅 gpu poisson solver tests 1" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "poisson_solvers_1" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "🕊️ cpu poisson solver tests 1" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "poisson_solvers_1" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" + +# - label: "🦖 gpu poisson solver tests 2" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "poisson_solvers_2" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "🦕 cpu poisson solver tests 2" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "poisson_solvers_2" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" + +# - label: "🌷 gpu matrix poisson solver tests" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "matrix_poisson_solvers" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "🌹 cpu matrix poisson solver tests" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "matrix_poisson_solvers" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" + +# - label: "🦤 gpu general solver tests" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "general_solvers" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "🦃 cpu general solver tests" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "general_solvers" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" ##### ##### NonhydrostaticModel and time stepping (part 1) @@ -249,452 +249,452 @@ steps: ##### NonhydrostaticModel and time stepping (part 2) ##### - - label: "🦈 gpu time stepping tests 2" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "time_stepping_2" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "🐬 cpu time stepping tests 2" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "time_stepping_2" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" - -##### -##### NonhydrostaticModel and time stepping (part 3) -##### - - - label: "🦟 gpu time stepping tests 3" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "time_stepping_3" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "🦗 cpu time stepping tests 3" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "time_stepping_3" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" - -##### -##### Turbulence Closures -##### - - - label: "🎣 gpu turbulence closures" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "turbulence_closures" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "🎏 cpu turbulence closures" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "turbulence_closures" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" - -##### -##### HydrostaticFreeSurfaceModel -##### - - - label: "🐙 gpu hydrostatic free surface model tests" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "hydrostatic_free_surface" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "🦑 cpu hydrostatic free surface model tests" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "hydrostatic_free_surface" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" - -##### -##### ShallowWaterModel -##### - - - label: "🦢 gpu shallow water model tests" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "shallow_water" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "🦆 cpu shallow water model tests" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "shallow_water" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" - -##### -##### Simulation -##### - - - label: "🐳 gpu simulation tests" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "simulation" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "🐋 cpu simulation tests" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "simulation" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" - -##### -##### Lagrangian particles tracking -##### - - - label: "🍂 gpu lagrangian particles tests" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "lagrangian" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "🍃 cpu lagrangian particles tests" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "lagrangian" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" - -##### -##### AbstractOperations -##### - - - label: "👻 gpu abstract operations tests" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "abstract_operations" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "🤖 cpu abstract operations tests" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "abstract_operations" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" - -##### -##### Multi-Region -##### - - - label: "🧅 gpu multi region tests" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "multi_region" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "🧄 cpu multi region tests" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "multi_region" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" - -##### -##### Regression -##### - - - label: "🐫 gpu nonhydrostatic regression tests" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "nonhydrostatic_regression" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "🐪 cpu nonhydrostatic regression tests" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "nonhydrostatic_regression" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" - - - label: "🙈 gpu hydrostatic regression tests" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "hydrostatic_regression" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "🙉 cpu hydrostatic regression tests" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "hydrostatic_regression" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" - -##### -##### Scripts -##### - - - label: "🦧 gpu scripts" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "scripts" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "🦍 cpu scripts" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "scripts" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" - -##### -##### Enzyme extension tests -##### - - - label: "👺 gpu Enzyme extension tests" - env: - JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "enzyme" - GPU_TEST: "true" - commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: GPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_gpu" - - - label: "👹 cpu Enzyme extension tests" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "enzyme" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" +# - label: "🦈 gpu time stepping tests 2" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "time_stepping_2" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "🐬 cpu time stepping tests 2" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "time_stepping_2" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" + +# ##### +# ##### NonhydrostaticModel and time stepping (part 3) +# ##### + +# - label: "🦟 gpu time stepping tests 3" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "time_stepping_3" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "🦗 cpu time stepping tests 3" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "time_stepping_3" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" + +# ##### +# ##### Turbulence Closures +# ##### + +# - label: "🎣 gpu turbulence closures" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "turbulence_closures" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "🎏 cpu turbulence closures" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "turbulence_closures" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" + +# ##### +# ##### HydrostaticFreeSurfaceModel +# ##### + +# - label: "🐙 gpu hydrostatic free surface model tests" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "hydrostatic_free_surface" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "🦑 cpu hydrostatic free surface model tests" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "hydrostatic_free_surface" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" + +# ##### +# ##### ShallowWaterModel +# ##### + +# - label: "🦢 gpu shallow water model tests" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "shallow_water" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "🦆 cpu shallow water model tests" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "shallow_water" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" + +# ##### +# ##### Simulation +# ##### + +# - label: "🐳 gpu simulation tests" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "simulation" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "🐋 cpu simulation tests" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "simulation" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" + +# ##### +# ##### Lagrangian particles tracking +# ##### + +# - label: "🍂 gpu lagrangian particles tests" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "lagrangian" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "🍃 cpu lagrangian particles tests" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "lagrangian" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" + +# ##### +# ##### AbstractOperations +# ##### + +# - label: "👻 gpu abstract operations tests" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "abstract_operations" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "🤖 cpu abstract operations tests" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "abstract_operations" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" + +# ##### +# ##### Multi-Region +# ##### + +# - label: "🧅 gpu multi region tests" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "multi_region" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "🧄 cpu multi region tests" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "multi_region" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" + +# ##### +# ##### Regression +# ##### + +# - label: "🐫 gpu nonhydrostatic regression tests" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "nonhydrostatic_regression" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "🐪 cpu nonhydrostatic regression tests" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "nonhydrostatic_regression" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" + +# - label: "🙈 gpu hydrostatic regression tests" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "hydrostatic_regression" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "🙉 cpu hydrostatic regression tests" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "hydrostatic_regression" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" + +# ##### +# ##### Scripts +# ##### + +# - label: "🦧 gpu scripts" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "scripts" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "🦍 cpu scripts" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "scripts" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" + +# ##### +# ##### Enzyme extension tests +# ##### + +# - label: "👺 gpu Enzyme extension tests" +# env: +# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "enzyme" +# GPU_TEST: "true" +# commands: +# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: GPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_gpu" + +# - label: "👹 cpu Enzyme extension tests" +# env: +# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" +# TEST_GROUP: "enzyme" +# commands: +# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" +# agents: +# queue: Oceananigans +# architecture: CPU +# retry: +# automatic: +# - exit_status: 1 +# limit: 1 +# depends_on: "init_cpu" ##### ##### Documentation diff --git a/src/Utils/kernel_launching.jl b/src/Utils/kernel_launching.jl index b9d1cce458..bee0a8972c 100644 --- a/src/Utils/kernel_launching.jl +++ b/src/Utils/kernel_launching.jl @@ -497,13 +497,10 @@ const MappedCompilerMetadata = CompilerMetadata{<:StaticSize, <:Any, <:Any, <:An # Mapped kernels are always 1D @inline function linear_index(ndrange::MappedNDRange, groupidx::CartesianIndex{N}, idx::CartesianIndex{N}) where N - nI = Base.@_inline_meta begin - offsets = workitems(ndrange) - stride = size(offsets, 1) - gidx = groupidx.I[1] - (gidx - 1) * stride + idx.I[1] - end - return nI + offsets = workitems(ndrange) + stride = size(offsets, 1) + gidx = groupidx.I[1] + return (gidx - 1) * stride + idx.I[1] end # # To check whether the index is valid in the index map, we need to diff --git a/test/runtests.jl b/test/runtests.jl index 1ad3a5caab..2b740cee58 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -118,8 +118,8 @@ CUDA.allowscalar() do # Models if group == :time_stepping_1 || group == :all @testset "Model and time stepping tests (part 1)" begin - include("test_nonhydrostatic_models.jl") - include("test_time_stepping.jl") + # include("test_nonhydrostatic_models.jl") + # include("test_time_stepping.jl") include("test_active_cells_map.jl") end end @@ -194,7 +194,7 @@ CUDA.allowscalar() do # In case CUDA is not found, we reset CUDA and restart the julia session reset_cuda_if_necessary() archs = test_architectures() - include("test_hydrostatic_regression.jl") + # include("test_hydrostatic_regression.jl") include("test_distributed_hydrostatic_model.jl") end From 0fca27c6c6311d5d9d18cc430d87fb748873dc91 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Wed, 11 Dec 2024 18:12:43 +0100 Subject: [PATCH 45/60] fix distributed --- .../compute_hydrostatic_free_surface_buffers.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_buffers.jl b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_buffers.jl index 83c8a4af0e..c8f7dab72b 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_buffers.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/compute_hydrostatic_free_surface_buffers.jl @@ -35,10 +35,10 @@ end function compute_buffer_tendency_contributions!(grid::DistributedActiveCellsIBG, arch, model) maps = grid.interior_active_cells - for name in (:west_dependent_halo_cells, - :east_dependent_halo_cells, - :south_dependent_halo_cells, - :north_dependent_halo_cells) + for name in (:west_halo_dependent_cells, + :east_halo_dependent_cells, + :south_halo_dependent_cells, + :north_halo_dependent_cells) active_cells_map = @inbounds maps[name] From 3256f2d09fc84c328bfd311aa935d05d8be367d4 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Mon, 16 Dec 2024 10:27:56 +0100 Subject: [PATCH 46/60] override for GPUs --- src/Utils/kernel_launching.jl | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/Utils/kernel_launching.jl b/src/Utils/kernel_launching.jl index bee0a8972c..efb4e34519 100644 --- a/src/Utils/kernel_launching.jl +++ b/src/Utils/kernel_launching.jl @@ -330,15 +330,19 @@ end ##### # TODO: when offsets are implemented in KA so that we can call `kernel(dev, group, size, offsets)`, remove all of this +using CUDA: @device_override using KernelAbstractions.NDIteration: _Size, StaticSize using KernelAbstractions.NDIteration: NDRange using KernelAbstractions.NDIteration using KernelAbstractions: ndrange, workgroupsize -import KernelAbstractions: partition +using KernelAbstractions: __iterspace, __groupindex, __dynamic_checkbounds using KernelAbstractions: CompilerMetadata + +import KernelAbstractions: partition import KernelAbstractions: __ndrange, __groupsize +import KernelAbstractions: __validindex struct OffsetStaticSize{S} <: _Size function OffsetStaticSize{S}() where S @@ -487,10 +491,6 @@ function partition(kernel::MappedKernel, inrange, ingroupsize) end # Extend the valid index function to check whether the index is valid in the index map - -using KernelAbstractions: __iterspace, __groupindex, __dynamic_checkbounds -import KernelAbstractions: __validindex - const MappedCompilerMetadata = CompilerMetadata{<:StaticSize, <:Any, <:Any, <:Any, <:MappedNDRange} @inline linear_ndrange(ctx::MappedCompilerMetadata) = length(__iterspace(ctx).workitems) @@ -513,4 +513,14 @@ end else return true end -end \ No newline at end of file +end + +# Override for GPU computations +@device_override @inline function __validindex(ctx::MappedCompilerMetadata) + if KA.__dynamic_checkbounds(ctx) + index = @inbounds linear_index(KA.__iterspace(ctx), blockIdx().x, threadIdx().x) + return index ≤ linear_ndrange(ctx) + else + return true + end +end From 3656122f3018494efe3c4bd5ee63cd68f14b8450 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Mon, 16 Dec 2024 10:31:52 +0100 Subject: [PATCH 47/60] bugfix --- src/Utils/kernel_launching.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Utils/kernel_launching.jl b/src/Utils/kernel_launching.jl index efb4e34519..f62783936d 100644 --- a/src/Utils/kernel_launching.jl +++ b/src/Utils/kernel_launching.jl @@ -330,7 +330,7 @@ end ##### # TODO: when offsets are implemented in KA so that we can call `kernel(dev, group, size, offsets)`, remove all of this -using CUDA: @device_override +using CUDA: @device_override, blockIdx, threadIdx using KernelAbstractions.NDIteration: _Size, StaticSize using KernelAbstractions.NDIteration: NDRange @@ -518,7 +518,7 @@ end # Override for GPU computations @device_override @inline function __validindex(ctx::MappedCompilerMetadata) if KA.__dynamic_checkbounds(ctx) - index = @inbounds linear_index(KA.__iterspace(ctx), blockIdx().x, threadIdx().x) + index = @inbounds linear_index(__iterspace(ctx), blockIdx().x, threadIdx().x) return index ≤ linear_ndrange(ctx) else return true From 54fd31e08c8373a14192c440d265d203dc6a49d1 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Mon, 16 Dec 2024 10:34:02 +0100 Subject: [PATCH 48/60] another bugfix --- src/Utils/kernel_launching.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Utils/kernel_launching.jl b/src/Utils/kernel_launching.jl index f62783936d..8b144b4c53 100644 --- a/src/Utils/kernel_launching.jl +++ b/src/Utils/kernel_launching.jl @@ -517,7 +517,7 @@ end # Override for GPU computations @device_override @inline function __validindex(ctx::MappedCompilerMetadata) - if KA.__dynamic_checkbounds(ctx) + if __dynamic_checkbounds(ctx) index = @inbounds linear_index(__iterspace(ctx), blockIdx().x, threadIdx().x) return index ≤ linear_ndrange(ctx) else From 6f407f7a1c39975ce63e7834c5a441b7e911b064 Mon Sep 17 00:00:00 2001 From: simone-silvestri Date: Mon, 16 Dec 2024 05:03:51 -0500 Subject: [PATCH 49/60] maybe now it works? --- src/Utils/kernel_launching.jl | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/Utils/kernel_launching.jl b/src/Utils/kernel_launching.jl index 8b144b4c53..4763676187 100644 --- a/src/Utils/kernel_launching.jl +++ b/src/Utils/kernel_launching.jl @@ -493,23 +493,35 @@ end # Extend the valid index function to check whether the index is valid in the index map const MappedCompilerMetadata = CompilerMetadata{<:StaticSize, <:Any, <:Any, <:Any, <:MappedNDRange} -@inline linear_ndrange(ctx::MappedCompilerMetadata) = length(__iterspace(ctx).workitems) +@inline __linear_ndrange(ctx::MappedCompilerMetadata) = length(__iterspace(ctx).workitems) # Mapped kernels are always 1D -@inline function linear_index(ndrange::MappedNDRange, groupidx::CartesianIndex{N}, idx::CartesianIndex{N}) where N +@inline function linear_expand(ndrange::MappedNDRange, groupidx::CartesianIndex{N}, idx::CartesianIndex{N}) where N offsets = workitems(ndrange) stride = size(offsets, 1) gidx = groupidx.I[1] return (gidx - 1) * stride + idx.I[1] end +Base.@propagate_inbounds function linear_expand(ndrange::NDRange, groupidx::Integer, idx::Integer) + linear_expand(ndrange, blocks(ndrange)[groupidx], workitems(ndrange)[idx]) +end + +Base.@propagate_inbounds function linear_expand(ndrange::NDRange{N}, groupidx::CartesianIndex{N}, idx::Integer) where {N} + linear_expand(ndrange, groupidx, workitems(ndrange)[idx]) +end + +Base.@propagate_inbounds function linear_expand(ndrange::NDRange{N}, groupidx::Integer, idx::CartesianIndex{N}) where {N} + linear_expand(ndrange, blocks(ndrange)[groupidx], idx) +end + # # To check whether the index is valid in the index map, we need to # # check whether the linear index is smaller than the size of the index map @inline function __validindex(ctx::MappedCompilerMetadata, idx::CartesianIndex) # Turns this into a noop for code where we can turn of checkbounds of if __dynamic_checkbounds(ctx) - index = @inbounds linear_index(__iterspace(ctx), __groupindex(ctx), idx) - return index ≤ linear_ndrange(ctx) + index = @inbounds linear_expand(__iterspace(ctx), __groupindex(ctx), idx) + return index ≤ __linear_ndrange(ctx) else return true end @@ -518,8 +530,12 @@ end # Override for GPU computations @device_override @inline function __validindex(ctx::MappedCompilerMetadata) if __dynamic_checkbounds(ctx) - index = @inbounds linear_index(__iterspace(ctx), blockIdx().x, threadIdx().x) - return index ≤ linear_ndrange(ctx) + try + index = @inbounds linear_expand(__iterspace(ctx), blockIdx().x, threadIdx().x) + return index ≤ __linear_ndrange(ctx) + catch err + code_typed(err; interactive = true) + end else return true end From d159f9a7c463e1d07d2fc4d927e240fc1643dd00 Mon Sep 17 00:00:00 2001 From: simone-silvestri Date: Mon, 16 Dec 2024 05:04:47 -0500 Subject: [PATCH 50/60] comment --- src/Utils/kernel_launching.jl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Utils/kernel_launching.jl b/src/Utils/kernel_launching.jl index 4763676187..ad78ce1cf1 100644 --- a/src/Utils/kernel_launching.jl +++ b/src/Utils/kernel_launching.jl @@ -490,7 +490,10 @@ function partition(kernel::MappedKernel, inrange, ingroupsize) return iterspace, dynamic end -# Extend the valid index function to check whether the index is valid in the index map +##### +##### Extend the valid index function to check whether the index is valid in the index map +##### + const MappedCompilerMetadata = CompilerMetadata{<:StaticSize, <:Any, <:Any, <:Any, <:MappedNDRange} @inline __linear_ndrange(ctx::MappedCompilerMetadata) = length(__iterspace(ctx).workitems) From 110bbfddd8ba2d22dad40191d10286e717a362d6 Mon Sep 17 00:00:00 2001 From: simone-silvestri Date: Mon, 16 Dec 2024 05:11:33 -0500 Subject: [PATCH 51/60] this should work finally --- src/Utils/kernel_launching.jl | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/src/Utils/kernel_launching.jl b/src/Utils/kernel_launching.jl index ad78ce1cf1..965cf31618 100644 --- a/src/Utils/kernel_launching.jl +++ b/src/Utils/kernel_launching.jl @@ -499,27 +499,16 @@ const MappedCompilerMetadata = CompilerMetadata{<:StaticSize, <:Any, <:Any, <:An @inline __linear_ndrange(ctx::MappedCompilerMetadata) = length(__iterspace(ctx).workitems) # Mapped kernels are always 1D -@inline function linear_expand(ndrange::MappedNDRange, groupidx::CartesianIndex{N}, idx::CartesianIndex{N}) where N +Base.@propagate_inbounds function linear_expand(ndrange::MappedNDRange, gidx::Integer, idx::Integer) offsets = workitems(ndrange) stride = size(offsets, 1) - gidx = groupidx.I[1] - return (gidx - 1) * stride + idx.I[1] + return (gidx - 1) * stride + idx end -Base.@propagate_inbounds function linear_expand(ndrange::NDRange, groupidx::Integer, idx::Integer) - linear_expand(ndrange, blocks(ndrange)[groupidx], workitems(ndrange)[idx]) -end - -Base.@propagate_inbounds function linear_expand(ndrange::NDRange{N}, groupidx::CartesianIndex{N}, idx::Integer) where {N} - linear_expand(ndrange, groupidx, workitems(ndrange)[idx]) -end +# To check whether the index is valid in the index map, we need to +# check whether the linear index is smaller than the size of the index map -Base.@propagate_inbounds function linear_expand(ndrange::NDRange{N}, groupidx::Integer, idx::CartesianIndex{N}) where {N} - linear_expand(ndrange, blocks(ndrange)[groupidx], idx) -end - -# # To check whether the index is valid in the index map, we need to -# # check whether the linear index is smaller than the size of the index map +# CPU version, the index is passed explicitly @inline function __validindex(ctx::MappedCompilerMetadata, idx::CartesianIndex) # Turns this into a noop for code where we can turn of checkbounds of if __dynamic_checkbounds(ctx) @@ -530,15 +519,11 @@ end end end -# Override for GPU computations +# GPU version, the indices are passed implicitly @device_override @inline function __validindex(ctx::MappedCompilerMetadata) if __dynamic_checkbounds(ctx) - try - index = @inbounds linear_expand(__iterspace(ctx), blockIdx().x, threadIdx().x) - return index ≤ __linear_ndrange(ctx) - catch err - code_typed(err; interactive = true) - end + index = @inbounds linear_expand(__iterspace(ctx), blockIdx().x, threadIdx().x) + return index ≤ __linear_ndrange(ctx) else return true end From 6cfa3b4fb23ddd645e96806b5d4017db350b1319 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Mon, 16 Dec 2024 11:54:45 +0100 Subject: [PATCH 52/60] add linear expand for CPU --- src/Utils/kernel_launching.jl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Utils/kernel_launching.jl b/src/Utils/kernel_launching.jl index 965cf31618..7c92b4dd7b 100644 --- a/src/Utils/kernel_launching.jl +++ b/src/Utils/kernel_launching.jl @@ -505,6 +505,14 @@ Base.@propagate_inbounds function linear_expand(ndrange::MappedNDRange, gidx::In return (gidx - 1) * stride + idx end +# Mapped kernels are always 1D +Base.@propagate_inbounds function linear_expand(ndrange::MappedNDRange, gidx::CartesianIndex{1}, idx::CartesianIndex{1}) + offsets = workitems(ndrange) + stride = size(offsets, 1) + gidx = groupidx.I[1] + return (gidx - 1) * stride + idx.I[1] +end + # To check whether the index is valid in the index map, we need to # check whether the linear index is smaller than the size of the index map From e8a87acfb98a0c8ea27ac3a65cc64fe6f246db95 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Mon, 16 Dec 2024 11:54:59 +0100 Subject: [PATCH 53/60] bugfix --- src/Utils/kernel_launching.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Utils/kernel_launching.jl b/src/Utils/kernel_launching.jl index 7c92b4dd7b..7563061de7 100644 --- a/src/Utils/kernel_launching.jl +++ b/src/Utils/kernel_launching.jl @@ -506,7 +506,7 @@ Base.@propagate_inbounds function linear_expand(ndrange::MappedNDRange, gidx::In end # Mapped kernels are always 1D -Base.@propagate_inbounds function linear_expand(ndrange::MappedNDRange, gidx::CartesianIndex{1}, idx::CartesianIndex{1}) +Base.@propagate_inbounds function linear_expand(ndrange::MappedNDRange, groupidx::CartesianIndex{1}, idx::CartesianIndex{1}) offsets = workitems(ndrange) stride = size(offsets, 1) gidx = groupidx.I[1] From 3ddad872f1a5a688bafaa499cf9a6db50229ea76 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Mon, 16 Dec 2024 13:25:40 +0100 Subject: [PATCH 54/60] works, restore all testing --- .buildkite/distributed/pipeline.yml | 180 ++-- .buildkite/pipeline.yml | 1208 +++++++++++++-------------- test/runtests.jl | 6 +- 3 files changed, 697 insertions(+), 697 deletions(-) diff --git a/.buildkite/distributed/pipeline.yml b/.buildkite/distributed/pipeline.yml index 7df94d1fd0..9f7869de63 100644 --- a/.buildkite/distributed/pipeline.yml +++ b/.buildkite/distributed/pipeline.yml @@ -27,69 +27,69 @@ steps: - wait - # - label: "🐉 cpu distributed unit tests" - # key: "distributed_cpu" - # env: - # TEST_GROUP: "distributed" - # MPI_TEST: "true" - # commands: - # - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - # agents: - # slurm_mem: 8G - # slurm_ntasks: 4 - # retry: - # automatic: - # - exit_status: 1 - # limit: 1 + - label: "🐉 cpu distributed unit tests" + key: "distributed_cpu" + env: + TEST_GROUP: "distributed" + MPI_TEST: "true" + commands: + - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + slurm_mem: 8G + slurm_ntasks: 4 + retry: + automatic: + - exit_status: 1 + limit: 1 - # - label: "🐲 gpu distributed unit tests" - # key: "distributed_gpu" - # env: - # TEST_GROUP: "distributed" - # GPU_TEST: "true" - # MPI_TEST: "true" - # commands: - # - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - # agents: - # slurm_mem: 8G - # slurm_ntasks: 4 - # slurm_gpus_per_task: 1 - # retry: - # automatic: - # - exit_status: 1 - # limit: 1 + - label: "🐲 gpu distributed unit tests" + key: "distributed_gpu" + env: + TEST_GROUP: "distributed" + GPU_TEST: "true" + MPI_TEST: "true" + commands: + - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + slurm_mem: 8G + slurm_ntasks: 4 + slurm_gpus_per_task: 1 + retry: + automatic: + - exit_status: 1 + limit: 1 - # - label: "🦾 cpu distributed solvers tests" - # key: "distributed_solvers_cpu" - # env: - # TEST_GROUP: "distributed_solvers" - # MPI_TEST: "true" - # commands: - # - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - # agents: - # slurm_mem: 50G - # slurm_ntasks: 4 - # retry: - # automatic: - # - exit_status: 1 - # limit: 1 + - label: "🦾 cpu distributed solvers tests" + key: "distributed_solvers_cpu" + env: + TEST_GROUP: "distributed_solvers" + MPI_TEST: "true" + commands: + - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + slurm_mem: 50G + slurm_ntasks: 4 + retry: + automatic: + - exit_status: 1 + limit: 1 - # - label: "🛸 gpu distributed solvers tests" - # key: "distributed_solvers_gpu" - # env: - # TEST_GROUP: "distributed_solvers" - # GPU_TEST: "true" - # MPI_TEST: "true" - # commands: - # - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - # agents: - # slurm_mem: 50G - # slurm_ntasks: 4 - # slurm_gpus_per_task: 1 - # retry: - # automatic: - # - exit_status: 1 - # limit: 1 + - label: "🛸 gpu distributed solvers tests" + key: "distributed_solvers_gpu" + env: + TEST_GROUP: "distributed_solvers" + GPU_TEST: "true" + MPI_TEST: "true" + commands: + - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + slurm_mem: 50G + slurm_ntasks: 4 + slurm_gpus_per_task: 1 + retry: + automatic: + - exit_status: 1 + limit: 1 - label: "🤺 cpu distributed hydrostatic model tests" key: "distributed_hydrostatic_model_cpu" @@ -123,37 +123,37 @@ steps: - exit_status: 1 limit: 1 - # - label: "🦍 cpu distributed nonhydrostatic regression" - # key: "distributed_nonhydrostatic_regression_cpu" - # env: - # TEST_GROUP: "distributed_nonhydrostatic_regression" - # MPI_TEST: "true" - # commands: - # - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - # agents: - # slurm_mem: 50G - # slurm_ntasks: 4 - # retry: - # automatic: - # - exit_status: 1 - # limit: 1 + - label: "🦍 cpu distributed nonhydrostatic regression" + key: "distributed_nonhydrostatic_regression_cpu" + env: + TEST_GROUP: "distributed_nonhydrostatic_regression" + MPI_TEST: "true" + commands: + - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + slurm_mem: 50G + slurm_ntasks: 4 + retry: + automatic: + - exit_status: 1 + limit: 1 - # - label: "🕺 gpu distributed nonhydrostatic regression" - # key: "distributed_nonhydrostatic_regression_gpu" - # env: - # TEST_GROUP: "distributed_nonhydrostatic_regression" - # GPU_TEST: "true" - # MPI_TEST: "true" - # commands: - # - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - # agents: - # slurm_mem: 50G - # slurm_ntasks: 4 - # slurm_gpus_per_task: 1 - # retry: - # automatic: - # - exit_status: 1 - # limit: 1 + - label: "🕺 gpu distributed nonhydrostatic regression" + key: "distributed_nonhydrostatic_regression_gpu" + env: + TEST_GROUP: "distributed_nonhydrostatic_regression" + GPU_TEST: "true" + MPI_TEST: "true" + commands: + - "srun julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + slurm_mem: 50G + slurm_ntasks: 4 + slurm_gpus_per_task: 1 + retry: + automatic: + - exit_status: 1 + limit: 1 - wait diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 93f422b7bf..d8dc9987da 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -51,164 +51,164 @@ steps: ##### Unit tests ##### -# - label: "🐿️ gpu unit tests" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "unit" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "🐇 cpu unit tests" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "unit" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" - -# ##### -# ##### Solver tests -# ##### - -# - label: "🦅 gpu poisson solver tests 1" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "poisson_solvers_1" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "🕊️ cpu poisson solver tests 1" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "poisson_solvers_1" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" - -# - label: "🦖 gpu poisson solver tests 2" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "poisson_solvers_2" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "🦕 cpu poisson solver tests 2" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "poisson_solvers_2" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" - -# - label: "🌷 gpu matrix poisson solver tests" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "matrix_poisson_solvers" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "🌹 cpu matrix poisson solver tests" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "matrix_poisson_solvers" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" - -# - label: "🦤 gpu general solver tests" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "general_solvers" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "🦃 cpu general solver tests" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "general_solvers" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" + - label: "🐿️ gpu unit tests" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "unit" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "🐇 cpu unit tests" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "unit" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" + +##### +##### Solver tests +##### + + - label: "🦅 gpu poisson solver tests 1" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "poisson_solvers_1" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "🕊️ cpu poisson solver tests 1" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "poisson_solvers_1" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" + + - label: "🦖 gpu poisson solver tests 2" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "poisson_solvers_2" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "🦕 cpu poisson solver tests 2" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "poisson_solvers_2" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" + + - label: "🌷 gpu matrix poisson solver tests" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "matrix_poisson_solvers" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "🌹 cpu matrix poisson solver tests" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "matrix_poisson_solvers" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" + + - label: "🦤 gpu general solver tests" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "general_solvers" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "🦃 cpu general solver tests" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "general_solvers" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" ##### ##### NonhydrostaticModel and time stepping (part 1) @@ -249,452 +249,452 @@ steps: ##### NonhydrostaticModel and time stepping (part 2) ##### -# - label: "🦈 gpu time stepping tests 2" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "time_stepping_2" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "🐬 cpu time stepping tests 2" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "time_stepping_2" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" - -# ##### -# ##### NonhydrostaticModel and time stepping (part 3) -# ##### - -# - label: "🦟 gpu time stepping tests 3" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "time_stepping_3" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "🦗 cpu time stepping tests 3" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "time_stepping_3" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" - -# ##### -# ##### Turbulence Closures -# ##### - -# - label: "🎣 gpu turbulence closures" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "turbulence_closures" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "🎏 cpu turbulence closures" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "turbulence_closures" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" - -# ##### -# ##### HydrostaticFreeSurfaceModel -# ##### - -# - label: "🐙 gpu hydrostatic free surface model tests" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "hydrostatic_free_surface" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "🦑 cpu hydrostatic free surface model tests" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "hydrostatic_free_surface" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" - -# ##### -# ##### ShallowWaterModel -# ##### - -# - label: "🦢 gpu shallow water model tests" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "shallow_water" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "🦆 cpu shallow water model tests" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "shallow_water" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" - -# ##### -# ##### Simulation -# ##### - -# - label: "🐳 gpu simulation tests" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "simulation" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "🐋 cpu simulation tests" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "simulation" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" - -# ##### -# ##### Lagrangian particles tracking -# ##### - -# - label: "🍂 gpu lagrangian particles tests" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "lagrangian" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "🍃 cpu lagrangian particles tests" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "lagrangian" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" - -# ##### -# ##### AbstractOperations -# ##### - -# - label: "👻 gpu abstract operations tests" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "abstract_operations" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "🤖 cpu abstract operations tests" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "abstract_operations" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" - -# ##### -# ##### Multi-Region -# ##### - -# - label: "🧅 gpu multi region tests" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "multi_region" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "🧄 cpu multi region tests" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "multi_region" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" - -# ##### -# ##### Regression -# ##### - -# - label: "🐫 gpu nonhydrostatic regression tests" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "nonhydrostatic_regression" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "🐪 cpu nonhydrostatic regression tests" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "nonhydrostatic_regression" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" - -# - label: "🙈 gpu hydrostatic regression tests" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "hydrostatic_regression" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "🙉 cpu hydrostatic regression tests" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "hydrostatic_regression" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" - -# ##### -# ##### Scripts -# ##### - -# - label: "🦧 gpu scripts" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "scripts" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "🦍 cpu scripts" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "scripts" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" - -# ##### -# ##### Enzyme extension tests -# ##### - -# - label: "👺 gpu Enzyme extension tests" -# env: -# JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "enzyme" -# GPU_TEST: "true" -# commands: -# - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: GPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_gpu" - -# - label: "👹 cpu Enzyme extension tests" -# env: -# JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" -# TEST_GROUP: "enzyme" -# commands: -# - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" -# agents: -# queue: Oceananigans -# architecture: CPU -# retry: -# automatic: -# - exit_status: 1 -# limit: 1 -# depends_on: "init_cpu" + - label: "🦈 gpu time stepping tests 2" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "time_stepping_2" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "🐬 cpu time stepping tests 2" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "time_stepping_2" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" + +##### +##### NonhydrostaticModel and time stepping (part 3) +##### + + - label: "🦟 gpu time stepping tests 3" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "time_stepping_3" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "🦗 cpu time stepping tests 3" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "time_stepping_3" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" + +##### +##### Turbulence Closures +##### + + - label: "🎣 gpu turbulence closures" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "turbulence_closures" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "🎏 cpu turbulence closures" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "turbulence_closures" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" + +##### +##### HydrostaticFreeSurfaceModel +##### + + - label: "🐙 gpu hydrostatic free surface model tests" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "hydrostatic_free_surface" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "🦑 cpu hydrostatic free surface model tests" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "hydrostatic_free_surface" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" + +##### +##### ShallowWaterModel +##### + + - label: "🦢 gpu shallow water model tests" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "shallow_water" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "🦆 cpu shallow water model tests" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "shallow_water" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" + +##### +##### Simulation +##### + + - label: "🐳 gpu simulation tests" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "simulation" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "🐋 cpu simulation tests" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "simulation" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" + +##### +##### Lagrangian particles tracking +##### + + - label: "🍂 gpu lagrangian particles tests" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "lagrangian" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "🍃 cpu lagrangian particles tests" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "lagrangian" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" + +##### +##### AbstractOperations +##### + + - label: "👻 gpu abstract operations tests" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "abstract_operations" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "🤖 cpu abstract operations tests" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "abstract_operations" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" + +##### +##### Multi-Region +##### + + - label: "🧅 gpu multi region tests" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "multi_region" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "🧄 cpu multi region tests" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "multi_region" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" + +##### +##### Regression +##### + + - label: "🐫 gpu nonhydrostatic regression tests" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "nonhydrostatic_regression" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "🐪 cpu nonhydrostatic regression tests" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "nonhydrostatic_regression" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" + + - label: "🙈 gpu hydrostatic regression tests" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "hydrostatic_regression" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "🙉 cpu hydrostatic regression tests" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "hydrostatic_regression" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" + +##### +##### Scripts +##### + + - label: "🦧 gpu scripts" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "scripts" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "🦍 cpu scripts" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "scripts" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" + +##### +##### Enzyme extension tests +##### + + - label: "👺 gpu Enzyme extension tests" + env: + JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "enzyme" + GPU_TEST: "true" + commands: + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: GPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_gpu" + + - label: "👹 cpu Enzyme extension tests" + env: + JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" + TEST_GROUP: "enzyme" + commands: + - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + agents: + queue: Oceananigans + architecture: CPU + retry: + automatic: + - exit_status: 1 + limit: 1 + depends_on: "init_cpu" ##### ##### Documentation diff --git a/test/runtests.jl b/test/runtests.jl index 2b740cee58..1ad3a5caab 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -118,8 +118,8 @@ CUDA.allowscalar() do # Models if group == :time_stepping_1 || group == :all @testset "Model and time stepping tests (part 1)" begin - # include("test_nonhydrostatic_models.jl") - # include("test_time_stepping.jl") + include("test_nonhydrostatic_models.jl") + include("test_time_stepping.jl") include("test_active_cells_map.jl") end end @@ -194,7 +194,7 @@ CUDA.allowscalar() do # In case CUDA is not found, we reset CUDA and restart the julia session reset_cuda_if_necessary() archs = test_architectures() - # include("test_hydrostatic_regression.jl") + include("test_hydrostatic_regression.jl") include("test_distributed_hydrostatic_model.jl") end From d6f310c08d42688c51307f69ffc5a5c556072983 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Mon, 16 Dec 2024 13:27:05 +0100 Subject: [PATCH 55/60] revert pipeline --- .buildkite/pipeline.yml | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index d8dc9987da..2ac6d44c86 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -319,13 +319,14 @@ steps: ##### Turbulence Closures ##### + - label: "🎣 gpu turbulence closures" env: JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER" TEST_GROUP: "turbulence_closures" GPU_TEST: "true" commands: - - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" + - "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia --color=yes --project -e 'using Pkg; Pkg.test()'" agents: queue: Oceananigans architecture: GPU @@ -335,20 +336,7 @@ steps: limit: 1 depends_on: "init_gpu" - - label: "🎏 cpu turbulence closures" - env: - JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER" - TEST_GROUP: "turbulence_closures" - commands: - - "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'" - agents: - queue: Oceananigans - architecture: CPU - retry: - automatic: - - exit_status: 1 - limit: 1 - depends_on: "init_cpu" +# The CPU turbulence closures test used to be here, but was moved to Github Actions. See https://github.com/CliMA/Oceananigans.jl/pull/3926 ##### ##### HydrostaticFreeSurfaceModel From ed5a47943cfc56a59b2ff0a2658c7382c83409d6 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Mon, 16 Dec 2024 13:28:39 +0100 Subject: [PATCH 56/60] do this optimization in a later PR --- src/Solvers/batched_tridiagonal_solver.jl | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/Solvers/batched_tridiagonal_solver.jl b/src/Solvers/batched_tridiagonal_solver.jl index 4f756ca3ac..2886847938 100644 --- a/src/Solvers/batched_tridiagonal_solver.jl +++ b/src/Solvers/batched_tridiagonal_solver.jl @@ -1,6 +1,5 @@ using Oceananigans.Architectures: on_architecture using Oceananigans.Grids: XDirection, YDirection, ZDirection -using Oceananigans.ImmersedBoundaries: retrieve_surface_active_cells_map import Oceananigans.Architectures: architecture @@ -100,16 +99,13 @@ Press William, H., Teukolsky Saul, A., Vetterling William, T., & Flannery Brian, """ function solve!(ϕ, solver::BatchedTridiagonalSolver, rhs, args...) - if solver.tridiagonal_direction isa XDirection - launch_config = :yz - active_cells_map = nothing - elseif solver.tridiagonal_direction isa YDirection - launch_config = :xz - active_cells_map = nothing - elseif solver.tridiagonal_direction isa ZDirection - launch_config = :xy - active_cells_map = retrieve_surface_active_cells_map(solver.grid) - end + launch_config = if solver.tridiagonal_direction isa XDirection + :yz + elseif solver.tridiagonal_direction isa YDirection + :xz + elseif solver.tridiagonal_direction isa ZDirection + :xy + end launch!(architecture(solver), solver.grid, launch_config, solve_batched_tridiagonal_system_kernel!, ϕ, @@ -121,8 +117,7 @@ function solve!(ϕ, solver::BatchedTridiagonalSolver, rhs, args...) solver.grid, solver.parameters, Tuple(args), - solver.tridiagonal_direction; - active_cells_map) + solver.tridiagonal_direction) return nothing end From 20a3f058ec52591100231e7b2351996dadf7a6d6 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Mon, 16 Dec 2024 13:31:34 +0100 Subject: [PATCH 57/60] better comment --- src/Utils/kernel_launching.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Utils/kernel_launching.jl b/src/Utils/kernel_launching.jl index 7563061de7..6f769631d5 100644 --- a/src/Utils/kernel_launching.jl +++ b/src/Utils/kernel_launching.jl @@ -438,10 +438,10 @@ struct IndexMap end const MappedNDRange{N} = NDRange{N, <:StaticSize, <:StaticSize, <:IndexMap, <:AbstractArray} where N +# TODO: maybe don't do this # NDRange has been modified to include an index_map in place of workitems. -# Remember, dynamic offset kernels are not possible with this extension!! +# Remember, dynamic kernels are not possible in combination with this extension!! # Also, mapped kernels work only with a 1D kernel and a 1D map, it is not possible to launch a ND kernel. -# TODO: maybe don't do this @inline function expand(ndrange::MappedNDRange, groupidx::CartesianIndex{N}, idx::CartesianIndex{N}) where N nI = ntuple(Val(N)) do I Base.@_inline_meta @@ -470,8 +470,8 @@ Adapt.adapt_structure(to, cm::CompilerMetadata{N, C}) where {N, C} = Adapt.adapt_structure(to, ndrange::NDRange{N, B, W}) where {N, B, W} = NDRange{N, B, W}(Adapt.adapt(to, ndrange.blocks), Adapt.adapt(to, ndrange.workitems)) -# Extending the partition function to include offsets in NDRange: note that in this case the -# offsets take the place of the DynamicWorkitems which we assume is not needed in static kernels +# Extending the partition function to include the index_map in NDRange: note that in this case the +# index_map takes the place of the DynamicWorkitems which we assume is not needed in static kernels function partition(kernel::MappedKernel, inrange, ingroupsize) static_workgroupsize = workgroupsize(kernel) From 62757cae7b0c7bdea5abaddea6465f6aac16fdaa Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Sun, 19 Jan 2025 14:34:31 -0500 Subject: [PATCH 58/60] bugfix --- .../barotropic_split_explicit_corrector.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/barotropic_split_explicit_corrector.jl b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/barotropic_split_explicit_corrector.jl index 807b104877..a8425f8a98 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/barotropic_split_explicit_corrector.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/barotropic_split_explicit_corrector.jl @@ -1,5 +1,5 @@ # Kernels to compute the vertical integral of the velocities -@kernel function _barotropic_mode_kernel!(U, V, grid, u, v) +@kernel function _barotropic_mode_kernel!(U, V, grid, u, v, η) i, j = @index(Global, NTuple) k_top = size(grid, 3) + 1 From 52dbf321c3ca18349ae93eaf1d2eac6f341c023b Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Sun, 19 Jan 2025 15:09:37 -0500 Subject: [PATCH 59/60] bugfix --- .../barotropic_split_explicit_corrector.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/barotropic_split_explicit_corrector.jl b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/barotropic_split_explicit_corrector.jl index a8425f8a98..3de75cc256 100644 --- a/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/barotropic_split_explicit_corrector.jl +++ b/src/Models/HydrostaticFreeSurfaceModels/SplitExplicitFreeSurfaces/barotropic_split_explicit_corrector.jl @@ -1,5 +1,5 @@ # Kernels to compute the vertical integral of the velocities -@kernel function _barotropic_mode_kernel!(U, V, grid, u, v, η) +@kernel function _barotropic_mode_kernel!(U̅, V̅, grid, u, v, η) i, j = @index(Global, NTuple) k_top = size(grid, 3) + 1 From 13399aff622043b6e1b170f4263ad239cbc694f0 Mon Sep 17 00:00:00 2001 From: Simone Silvestri Date: Thu, 23 Jan 2025 16:33:35 +0100 Subject: [PATCH 60/60] correction --- ...topologically_conditional_interpolation.jl | 66 ++++++++++++------- 1 file changed, 43 insertions(+), 23 deletions(-) diff --git a/src/Advection/topologically_conditional_interpolation.jl b/src/Advection/topologically_conditional_interpolation.jl index 9c623c6b57..d053afd0a4 100644 --- a/src/Advection/topologically_conditional_interpolation.jl +++ b/src/Advection/topologically_conditional_interpolation.jl @@ -10,18 +10,18 @@ ##### close to the boundary, or a second-order interpolation if i is close to a boundary. ##### -using Oceananigans.Grids: AbstractUnderlyingGrid, Bounded +using Oceananigans.Grids: AbstractUnderlyingGrid, Bounded, RightConnected, LeftConnected, BoundedTopology const AUG = AbstractUnderlyingGrid # Bounded underlying Grids -const AUGX = AUG{<:Any, <:Bounded} -const AUGY = AUG{<:Any, <:Any, <:Bounded} -const AUGZ = AUG{<:Any, <:Any, <:Any, <:Bounded} -const AUGXY = AUG{<:Any, <:Bounded, <:Bounded} -const AUGXZ = AUG{<:Any, <:Bounded, <:Any, <:Bounded} -const AUGYZ = AUG{<:Any, <:Any, <:Bounded, <:Bounded} -const AUGXYZ = AUG{<:Any, <:Bounded, <:Bounded, <:Bounded} +const AUGX = AUG{<:Any, <:BoundedTopology} +const AUGY = AUG{<:Any, <:Any, <:BoundedTopology} +const AUGZ = AUG{<:Any, <:Any, <:Any, <:BoundedTopology} +const AUGXY = AUG{<:Any, <:BoundedTopology, <:BoundedTopology} +const AUGXZ = AUG{<:Any, <:BoundedTopology, <:Any, <:BoundedTopology} +const AUGYZ = AUG{<:Any, <:Any, <:BoundedTopology, <:BoundedTopology} +const AUGXYZ = AUG{<:Any, <:BoundedTopology, <:BoundedTopology, <:BoundedTopology} # Left-biased buffers are smaller by one grid point on the right side; vice versa for right-biased buffers # Center interpolation stencil look at i + 1 (i.e., require one less point on the left) @@ -29,20 +29,40 @@ const AUGXYZ = AUG{<:Any, <:Bounded, <:Bounded, <:Bounded} for dir in (:x, :y, :z) outside_symmetric_haloᶠ = Symbol(:outside_symmetric_halo_, dir, :ᶠ) outside_symmetric_haloᶜ = Symbol(:outside_symmetric_halo_, dir, :ᶜ) - outside_biased_haloᶠ = Symbol(:outside_biased_halo_, dir, :ᶠ) - outside_biased_haloᶜ = Symbol(:outside_biased_halo_, dir, :ᶜ) - required_halo_size = Symbol(:required_halo_size_, dir) + outside_biased_haloᶠ = Symbol(:outside_biased_halo_, dir, :ᶠ) + outside_biased_haloᶜ = Symbol(:outside_biased_halo_, dir, :ᶜ) + required_halo_size = Symbol(:required_halo_size_, dir) @eval begin - @inline $outside_symmetric_haloᶠ(i, N, adv) = (i >= $required_halo_size(adv) + 1) & (i <= N + 1 - $required_halo_size(adv)) - @inline $outside_symmetric_haloᶜ(i, N, adv) = (i >= $required_halo_size(adv)) & (i <= N + 1 - $required_halo_size(adv)) - - @inline $outside_biased_haloᶠ(i, N, adv) = (i >= $required_halo_size(adv) + 1) & (i <= N + 1 - ($required_halo_size(adv) - 1)) & # Left bias - (i >= $required_halo_size(adv)) & (i <= N + 1 - $required_halo_size(adv)) # Right bias - @inline $outside_biased_haloᶜ(i, N, adv) = (i >= $required_halo_size(adv)) & (i <= N + 1 - ($required_halo_size(adv) - 1)) & # Left bias - (i >= $required_halo_size(adv) - 1) & (i <= N + 1 - $required_halo_size(adv)) # Right bias + # Bounded topologies + @inline $outside_symmetric_haloᶠ(i, ::Type{Bounded}, N, adv) = (i >= $required_halo_size(adv) + 1) & (i <= N + 1 - $required_halo_size(adv)) + @inline $outside_symmetric_haloᶜ(i, ::Type{Bounded}, N, adv) = (i >= $required_halo_size(adv)) & (i <= N + 1 - $required_halo_size(adv)) + + @inline $outside_biased_haloᶠ(i, ::Type{Bounded}, N, adv) = (i >= $required_halo_size(adv) + 1) & (i <= N + 1 - ($required_halo_size(adv) - 1)) & # Left bias + (i >= $required_halo_size(adv)) & (i <= N + 1 - $required_halo_size(adv)) # Right bias + @inline $outside_biased_haloᶜ(i, ::Type{Bounded}, N, adv) = (i >= $required_halo_size(adv)) & (i <= N + 1 - ($required_halo_size(adv) - 1)) & # Left bias + (i >= $required_halo_size(adv) - 1) & (i <= N + 1 - $required_halo_size(adv)) # Right bias + + # Right connected topologies (only test the left side, i.e. the bounded side) + @inline $outside_symmetric_haloᶠ(i, ::Type{RightConnected}, N, adv) = i >= $required_halo_size(adv) + 1 + @inline $outside_symmetric_haloᶜ(i, ::Type{RightConnected}, N, adv) = i >= $required_halo_size(adv) + + @inline $outside_biased_haloᶠ(i, ::Type{RightConnected}, N, adv) = (i >= $required_halo_size(adv) + 1) & # Left bias + (i >= $required_halo_size(adv)) # Right bias + @inline $outside_biased_haloᶜ(i, ::Type{RightConnected}, N, adv) = (i >= $required_halo_size(adv)) & # Left bias + (i >= $required_halo_size(adv) - 1) # Right bias + + # Left bounded topologies (only test the right side, i.e. the bounded side) + @inline $outside_symmetric_haloᶠ(i, ::Type{LeftConnected}, N, adv) = (i <= N + 1 - $required_halo_size(adv)) + @inline $outside_symmetric_haloᶜ(i, ::Type{LeftConnected}, N, adv) = (i <= N + 1 - $required_halo_size(adv)) + + @inline $outside_biased_haloᶠ(i, ::Type{LeftConnected}, N, adv) = (i <= N + 1 - ($required_halo_size(adv) - 1)) & # Left bias + (i <= N + 1 - $required_halo_size(adv)) # Right bias + @inline $outside_biased_haloᶜ(i, ::Type{LeftConnected}, N, adv) = (i <= N + 1 - ($required_halo_size(adv) - 1)) & # Left bias + (i <= N + 1 - $required_halo_size(adv)) # Right bias end end + # Separate High order advection from low order advection const HOADV = Union{WENO, Tuple(Centered{N} for N in advection_buffers[2:end])..., @@ -76,21 +96,21 @@ for bias in (:symmetric, :biased) if ξ == :x @eval begin @inline $alt1_interp(i, j, k, grid::AUGX, scheme::HOADV, args...) = - ifelse($outside_buffer(i, grid.Nx, scheme), + ifelse($outside_buffer(i, topology(grid, 1), grid.Nx, scheme), $interp(i, j, k, grid, scheme, args...), $alt2_interp(i, j, k, grid, scheme.buffer_scheme, args...)) end elseif ξ == :y @eval begin @inline $alt1_interp(i, j, k, grid::AUGY, scheme::HOADV, args...) = - ifelse($outside_buffer(j, grid.Ny, scheme), + ifelse($outside_buffer(j, topology(grid, 2), grid.Ny, scheme), $interp(i, j, k, grid, scheme, args...), $alt2_interp(i, j, k, grid, scheme.buffer_scheme, args...)) end elseif ξ == :z @eval begin @inline $alt1_interp(i, j, k, grid::AUGZ, scheme::HOADV, args...) = - ifelse($outside_buffer(k, grid.Nz, scheme), + ifelse($outside_buffer(k, topology(grid, 3), grid.Nz, scheme), $interp(i, j, k, grid, scheme, args...), $alt2_interp(i, j, k, grid, scheme.buffer_scheme, args...)) end @@ -100,11 +120,11 @@ for bias in (:symmetric, :biased) end @inline _multi_dimensional_reconstruction_x(i, j, k, grid::AUGX, scheme, interp, args...) = - ifelse(outside_symmetric_bufferᶜ(i, grid.Nx, scheme), + ifelse(outside_symmetric_bufferᶜ(i, topology(grid, 1), grid.Nx, scheme), multi_dimensional_reconstruction_x(i, j, k, grid::AUGX, scheme, interp, args...), interp(i, j, k, grid, scheme, args...)) @inline _multi_dimensional_reconstruction_y(i, j, k, grid::AUGY, scheme, interp, args...) = - ifelse(outside_symmetric_bufferᶜ(j, grid.Ny, scheme), + ifelse(outside_symmetric_bufferᶜ(j, topology(grid, 2), grid.Ny, scheme), multi_dimensional_reconstruction_y(i, j, k, grid::AUGY, scheme, interp, args...), interp(i, j, k, grid, scheme, args...))