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 + f3a4a23 commit 4b7ad79
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 27 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
13 changes: 6 additions & 7 deletions src/Operators/stencilcoefs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ struct StencilCoefs{lbw, ubw, C <: NTuple}
coefs::C
end

function StencilCoefs{lbw, ubw}(coefs::NTuple{N, T}) where {lbw, ubw, N, T}
if !(
(lbw isa Integer && ubw isa Integer) ||
(lbw isa PlusHalf && ubw isa PlusHalf)
)
error("Invalid stencil bandwidths $lbw and $ubw (inconsistent types)")
end
function StencilCoefs(
lbw::B,
ubw::B,
coefs::NTuple{N},
) where {N, B <: Union{Integer, PlusHalf}}
T = eltype(coefs)
if N != ubw - lbw + 1
error("Stencil bandwidth ($(ubw - lbw + 1)) and number of stencil \
coefficients ($N) are not equal")
Expand Down
7 changes: 7 additions & 0 deletions src/Spaces/Spaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,11 @@ include("hybrid.jl")
include("triangulation.jl")
include("dss.jl")

# topology =
# space isa ExtrudedFiniteDifferenceSpace ?
# space.horizontal_space.topology : space.topology

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

end # module
50 changes: 40 additions & 10 deletions src/Spaces/dss.jl
Original file line number Diff line number Diff line change
Expand Up @@ -691,14 +691,27 @@ 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::H,
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::H,
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)
topology = hspace.topology
if ghost_buffer isa GhostBuffer
# 1) copy send data to buffer
fill_send_buffer!(topology, data, ghost_buffer)
Expand All @@ -708,7 +721,7 @@ function weighted_dss_start!(
return nothing
end

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

Expand Down Expand Up @@ -747,11 +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::H,
ghost_buffer,
) where {S, T <: DistributedTopology2D, H <: SpectralElementSpace2D{T}}
) where {S, H <: SpectralElementSpace2D{<:DistributedTopology2D}}
_weighted_dss_ghost!(data, space, hspace, hspace, ghost_buffer)
end

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

function _weighted_dss_ghost!(data, space, hspace, ghost_buffer)
hspace =
space isa ExtrudedFiniteDifferenceSpace ? space.horizontal_space : space
topology = hspace.topology
Expand Down Expand Up @@ -793,6 +823,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
3 changes: 2 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,8 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"

[compat]
OrdinaryDiffEq = "5.64.0"
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 4b7ad79

Please sign in to comment.