Skip to content

Commit

Permalink
Try #785:
Browse files Browse the repository at this point in the history
  • Loading branch information
bors[bot] authored Jul 1, 2022
2 parents c139012 + 717f452 commit 8a762fd
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 26 deletions.
10 changes: 5 additions & 5 deletions src/DataLayouts/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ end
function Base.similar(
::Union{IF{<:Any, Ni, A}, Broadcast.Broadcasted{IFStyle{Ni, A}}},
::Type{Eltype},
) where {S, Ni, A, Eltype}
) where {Ni, A, Eltype}
Nf = typesize(eltype(A), Eltype)
array = MArray{Tuple{Ni, Nf}, eltype(A), 2, Ni * Nf}(undef)
return IF{Eltype, Ni}(array)
Expand Down Expand Up @@ -432,8 +432,8 @@ end

function Base.copyto!(
dest::IJFH{S, Nij},
bc::Union{IJFH{S, Nij}, Base.Broadcast.Broadcasted{IJFHStyle{Nij, A}}},
) where {S, Nij, A}
bc::Union{IJFH{S, Nij}, Base.Broadcast.Broadcasted{<:IJFHStyle{Nij}}},
) where {S, Nij}
_, _, _, _, Nh = size(bc)
@inbounds for h in 1:Nh
slab_dest = slab(dest, h)
Expand All @@ -445,8 +445,8 @@ end

function Base.copyto!(
dest::IFH{S, Ni},
bc::Union{IFH{S, Ni}, Base.Broadcast.Broadcasted{IFHStyle{Ni, A}}},
) where {S, Ni, A}
bc::Union{IFH{S, Ni}, Base.Broadcast.Broadcasted{<:IFHStyle{Ni}}},
) where {S, Ni}
_, _, _, _, Nh = size(bc)
@inbounds for h in 1:Nh
slab_dest = slab(dest, h)
Expand Down
2 changes: 0 additions & 2 deletions src/Fields/field_iterator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ function isa_12_covariant_field(
f::Type{CF},
) where {
FT,
T,
CF <: Geometry.AxisTensor{
FT,
1,
Expand All @@ -62,7 +61,6 @@ function isa_3_covariant_field(
f::Type{CF},
) where {
FT,
T,
CF <: Geometry.AxisTensor{
FT,
1,
Expand Down
3 changes: 1 addition & 2 deletions src/Geometry/axistensors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,7 @@ end
# LinearAlgebra

check_axes(::A, ::A) where {A} = nothing
check_axes(ax1, ax2) where {A} =
throw(DimensionMismatch("$ax1 and $ax2 do not match"))
check_axes(ax1, ax2) = throw(DimensionMismatch("$ax1 and $ax2 do not match"))

check_dual(ax1, ax2) = _check_dual(ax1, ax2, dual(ax2))
_check_dual(::A, _, ::A) where {A} = nothing
Expand Down
3 changes: 2 additions & 1 deletion src/Operators/stencilcoefs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ struct StencilCoefs{lbw, ubw, C <: NTuple}
coefs::C
end

function StencilCoefs{lbw, ubw}(coefs::NTuple{N, T}) where {lbw, ubw, N, T}
function StencilCoefs{lbw, ubw}(coefs::NTuple{N}) where {lbw, ubw, N}
if !(
(lbw isa Integer && ubw isa Integer) ||
(lbw isa PlusHalf && ubw isa PlusHalf)
Expand All @@ -23,6 +23,7 @@ function StencilCoefs{lbw, ubw}(coefs::NTuple{N, T}) where {lbw, ubw, N, T}
if N == 0 # no reason to support edge case of an empty stencil
error("Stencil cannot be empty")
end
T = eltype(coefs)
if !isconcretetype(T) # must be compatible with DataLayouts
error("Stencil coefficients must all have the same concrete type")
end
Expand Down
3 changes: 3 additions & 0 deletions src/Spaces/Spaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,7 @@ include("hybrid.jl")
include("triangulation.jl")
include("dss.jl")

horizontal_space(space::ExtrudedFiniteDifferenceSpace) = space.horizontal_space
horizontal_space(space::AbstractSpace) = space

end # module
58 changes: 43 additions & 15 deletions src/Spaces/dss.jl
Original file line number Diff line number Diff line change
Expand Up @@ -691,14 +691,31 @@ Create the ghost buffer, if necessary, load the send buffer and start communicat
Part of [`Spaces.weighted_dss!`](@ref).
"""
function weighted_dss_start!(
weighted_dss_start!(data, space, ghost_buffer) =
weighted_dss_start!(data, space, horizontal_space(space), ghost_buffer)

weighted_dss_start!(
data,
space::ExtrudedFiniteDifferenceSpace{S, H},
hspace,
ghost_buffer,
) where {S, H <: SpectralElementSpace2D{<:DistributedTopology2D}} =
_weighted_dss_start!(data, space, hspace, ghost_buffer)

weighted_dss_start!(
data,
space::Union{ExtrudedFiniteDifferenceSpace{S, H}, H},
space::H,
hspace,
ghost_buffer,
) where {S, T <: DistributedTopology2D, H <: SpectralElementSpace2D{T}}
topology =
space isa ExtrudedFiniteDifferenceSpace ?
space.horizontal_space.topology : space.topology
) where {H <: SpectralElementSpace2D{<:DistributedTopology2D}} =
_weighted_dss_start!(data, space, hspace, ghost_buffer)

function weighted_dss_start!(data, space, hspace, ghost_buffer)
return nothing
end

function _weighted_dss_start!(data, space, hspace, ghost_buffer)
topology = hspace.topology
if ghost_buffer isa GhostBuffer
# 1) copy send data to buffer
fill_send_buffer!(topology, data, ghost_buffer)
Expand All @@ -708,10 +725,6 @@ function weighted_dss_start!(
return nothing
end

function weighted_dss_start!(data, space, ghost_buffer)
return nothing
end

"""
weighted_dss_internal!(data, space, ghost_buffer)
Expand Down Expand Up @@ -747,13 +760,28 @@ Complete communication. Perform weighted dss for ghost faces and vertices.
Part of [`Spaces.weighted_dss!`](@ref).
"""
weighted_dss_ghost!(data, space, ghost_buffer) =
weighted_dss_ghost!(data, space, horizontal_space(space), ghost_buffer)

function weighted_dss_ghost!(
data,
space::Union{ExtrudedFiniteDifferenceSpace{S, H}, H},
space::ExtrudedFiniteDifferenceSpace{S, H},
hspace,
ghost_buffer,
) where {S, T <: DistributedTopology2D, H <: SpectralElementSpace2D{T}}
hspace =
space isa ExtrudedFiniteDifferenceSpace ? space.horizontal_space : space
) where {S, H <: SpectralElementSpace2D{<:DistributedTopology2D}}
_weighted_dss_ghost!(data, space, hspace, ghost_buffer)
end

function weighted_dss_ghost!(
data,
space::H,
hspace,
ghost_buffer,
) where {H <: SpectralElementSpace2D{<:DistributedTopology2D}}
_weighted_dss_ghost!(data, space, hspace, ghost_buffer)
end

function _weighted_dss_ghost!(data, space, hspace, ghost_buffer)
topology = hspace.topology
local_geometry = local_geometry_data(space)
local_weights = hspace.local_dss_weights
Expand Down Expand Up @@ -793,6 +821,6 @@ function weighted_dss_ghost!(
return data
end

function weighted_dss_ghost!(data, space, ghost_buffer)
function weighted_dss_ghost!(data, space, hspace, ghost_buffer)
return data
end
4 changes: 3 additions & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[deps]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
AssociatedLegendrePolynomials = "2119f1ac-fb78-50f5-8cc0-dda848ebdb19"
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
Expand Down Expand Up @@ -27,8 +28,9 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"

[compat]
OrdinaryDiffEq = "5.64.0"
Aqua = "0.5"
DiffEqBase = "~6.84.0"
OrdinaryDiffEq = "5.64.0"

[extras]
CPUSummary = "2a0fbf3d-bb9c-48f3-b0a9-814d99fd7ab9"
12 changes: 12 additions & 0 deletions test/aqua.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Test
import ClimaCore
using Aqua

@testset "Aqua tests - unbound args" begin
# This tests that we don't accidentally run into
# https://github.com/JuliaLang/julia/issues/29393
Aqua.test_unbound_args(ClimaCore)

# returns a vector of all unbound args
# ua = Aqua.detect_unbound_args_recursively(ClimaCore)
end
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ using Base: operator_associativity

@time include("Limiters/limiter.jl")
@time include("Limiters/distributed.jl")
@time include("aqua.jl") # Code quality checks

if "CUDA" in ARGS
@time include("gpu/cuda.jl")
Expand Down

0 comments on commit 8a762fd

Please sign in to comment.