Skip to content

Commit

Permalink
Merge #978
Browse files Browse the repository at this point in the history
978: Extend and fix Ref broadcasting with StencilCoefs r=charleskawczynski a=charleskawczynski

This PR extends and fixes `Ref` broadcasting with StencilCoefs (#963), solution was basically the same as the one applied in #945. Closes #963.

I tried applying only `copyto!`, and only `apply_stencil!`, but that didn't work so I applied to all three methods (which does work).

Co-authored-by: Charles Kawczynski <kawczynski.charles@gmail.com>
  • Loading branch information
bors[bot] and charleskawczynski authored Oct 4, 2022
2 parents 64b5023 + 9779510 commit f2eb09c
Show file tree
Hide file tree
Showing 8 changed files with 556 additions and 497 deletions.
12 changes: 12 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ steps:
- "julia -O0 --color=yes --check-bounds=yes --project=test test/Operators/finitedifference/implicit_stencils.jl --float_type Float32"
agents:
config: cpu
slurm_mem: 10GB
queue: central
slurm_ntasks: 1

Expand All @@ -127,6 +128,7 @@ steps:
- "julia -O0 --color=yes --check-bounds=yes --project=test test/Operators/finitedifference/implicit_stencils.jl --float_type Float64"
agents:
config: cpu
slurm_mem: 10GB
queue: central
slurm_ntasks: 1

Expand Down Expand Up @@ -775,6 +777,7 @@ steps:
- "examples/hybrid/sphere/output/deformation_flow/*"
agents:
config: cpu
slurm_mem: 20GB
queue: central
slurm_ntasks: 1

Expand All @@ -786,6 +789,7 @@ steps:
- "examples/hybrid/sphere/output/hadley_circulation/*"
agents:
config: cpu
slurm_mem: 20GB
queue: central
slurm_ntasks: 1

Expand Down Expand Up @@ -813,6 +817,7 @@ steps:
TEST_NAME: "sphere/baroclinic_wave_rhoe"
agents:
config: cpu
slurm_mem: 10GB
queue: central
slurm_ntasks: 1

Expand All @@ -827,6 +832,7 @@ steps:
CLIMACORE_DISTRIBUTED: "MPI"
agents:
config: cpu
slurm_mem: 20GB
queue: central
slurm_ntasks: 2

Expand All @@ -841,6 +847,7 @@ steps:
TEST_NAME: "sphere/baroclinic_wave_rhotheta"
agents:
config: cpu
slurm_mem: 10GB
queue: central
slurm_ntasks: 1

Expand Down Expand Up @@ -874,6 +881,7 @@ steps:
TEST_NAME: "sphere/balanced_flow_rhoe"
agents:
config: cpu
slurm_mem: 20GB
queue: central
slurm_ntasks: 1

Expand All @@ -900,6 +908,7 @@ steps:
TEST_NAME: "sphere/held_suarez_rhoe"
agents:
config: cpu
slurm_mem: 10GB
queue: central
slurm_ntasks: 1

Expand All @@ -914,6 +923,7 @@ steps:
FLOAT_TYPE: "Float64"
agents:
config: cpu
slurm_mem: 20GB
queue: central
slurm_ntasks: 1

Expand All @@ -940,6 +950,7 @@ steps:
TEST_NAME: "sphere/held_suarez_rhoe_int"
agents:
config: cpu
slurm_mem: 10GB
queue: central
slurm_ntasks: 1

Expand Down Expand Up @@ -967,6 +978,7 @@ steps:
Z_STRETCH: "true"
agents:
config: cpu
slurm_mem: 10GB
queue: central
slurm_ntasks: 1

Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ClimaCore"
uuid = "d414da3d-4745-48bb-8d80-42e94e092884"
authors = ["CliMA Contributors <clima-software@caltech.edu>"]
version = "0.10.15"
version = "0.10.16"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand Down
2 changes: 1 addition & 1 deletion docs/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ version = "0.3.0"
deps = ["Adapt", "BlockArrays", "CUDA", "ClimaComms", "CubedSphere", "DataStructures", "DiffEqBase", "DocStringExtensions", "ForwardDiff", "GaussQuadrature", "GilbertCurves", "HDF5", "InteractiveUtils", "IntervalSets", "LinearAlgebra", "PkgVersion", "RecursiveArrayTools", "RootSolvers", "Rotations", "SparseArrays", "Static", "StaticArrays", "Statistics", "UnPack"]
path = ".."
uuid = "d414da3d-4745-48bb-8d80-42e94e092884"
version = "0.10.15"
version = "0.10.16"

[[deps.ClimaCoreMakie]]
deps = ["ClimaCore", "Makie"]
Expand Down
20 changes: 10 additions & 10 deletions examples/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ version = "0.3.2"
deps = ["Adapt", "BlockArrays", "CUDA", "ClimaComms", "CubedSphere", "DataStructures", "DiffEqBase", "DocStringExtensions", "ForwardDiff", "GaussQuadrature", "GilbertCurves", "HDF5", "InteractiveUtils", "IntervalSets", "LinearAlgebra", "PkgVersion", "RecursiveArrayTools", "RootSolvers", "Rotations", "SparseArrays", "Static", "StaticArrays", "Statistics", "UnPack"]
path = ".."
uuid = "d414da3d-4745-48bb-8d80-42e94e092884"
version = "0.10.15"
version = "0.10.16"

[[deps.ClimaCorePlots]]
deps = ["ClimaCore", "RecipesBase", "StaticArrays", "TriplotBase"]
Expand Down Expand Up @@ -529,10 +529,10 @@ uuid = "61eb1bfa-7361-4325-ad38-22787b887f55"
version = "0.16.4"

[[deps.GR]]
deps = ["Base64", "DelimitedFiles", "GR_jll", "HTTP", "JSON", "Libdl", "LinearAlgebra", "Pkg", "Printf", "Random", "RelocatableFolders", "Serialization", "Sockets", "Test", "UUIDs"]
git-tree-sha1 = "0ac6f27e784059c68b987f42b909ade0bcfabe69"
deps = ["Base64", "DelimitedFiles", "GR_jll", "HTTP", "JSON", "Libdl", "LinearAlgebra", "Pkg", "Preferences", "Printf", "Random", "Serialization", "Sockets", "Test", "UUIDs"]
git-tree-sha1 = "859e9cfa91d21ed87e8ea9f2998c94df1de12045"
uuid = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71"
version = "0.68.0"
version = "0.69.2"

[[deps.GR_jll]]
deps = ["Artifacts", "Bzip2_jll", "Cairo_jll", "FFMPEG_jll", "Fontconfig_jll", "GLFW_jll", "JLLWrappers", "JpegTurbo_jll", "Libdl", "Libtiff_jll", "Pixman_jll", "Pkg", "Qt5Base_jll", "Zlib_jll", "libpng_jll"]
Expand Down Expand Up @@ -671,9 +671,9 @@ version = "1.0.0"

[[deps.JLD2]]
deps = ["FileIO", "MacroTools", "Mmap", "OrderedCollections", "Pkg", "Printf", "Reexport", "TranscodingStreams", "UUIDs"]
git-tree-sha1 = "6c38bbe47948f74d63434abed68bdfc8d2c46b99"
git-tree-sha1 = "0d0ad913e827d13c5e88a73f9333d7e33c424576"
uuid = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
version = "0.4.23"
version = "0.4.24"

[[deps.JLFzf]]
deps = ["Pipe", "REPL", "Random", "fzf_jll"]
Expand Down Expand Up @@ -1146,9 +1146,9 @@ version = "1.3.1"

[[deps.Plots]]
deps = ["Base64", "Contour", "Dates", "Downloads", "FFMPEG", "FixedPointNumbers", "GR", "JLFzf", "JSON", "LaTeXStrings", "Latexify", "LinearAlgebra", "Measures", "NaNMath", "Pkg", "PlotThemes", "PlotUtils", "Printf", "REPL", "Random", "RecipesBase", "RecipesPipeline", "Reexport", "RelocatableFolders", "Requires", "Scratch", "Showoff", "SnoopPrecompile", "SparseArrays", "Statistics", "StatsBase", "UUIDs", "UnicodeFun", "Unzip"]
git-tree-sha1 = "284a353a34a352a95fca1d61ea28a0d48feaf273"
git-tree-sha1 = "f60a3090028cdf16b33a62f97eaedf67a6509824"
uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
version = "1.34.4"
version = "1.35.0"

[[deps.Polyester]]
deps = ["ArrayInterface", "BitTwiddlingConvenienceFunctions", "CPUSummary", "IfElse", "ManualMemory", "PolyesterWeave", "Requires", "Static", "StrideArraysCore", "ThreadingUtilities"]
Expand Down Expand Up @@ -1230,9 +1230,9 @@ version = "1.3.0"

[[deps.RecipesPipeline]]
deps = ["Dates", "NaNMath", "PlotUtils", "RecipesBase"]
git-tree-sha1 = "e7eac76a958f8664f2718508435d058168c7953d"
git-tree-sha1 = "017f217e647cf20b0081b9be938b78c3443356a0"
uuid = "01d81517-befc-4cb6-b9ec-a95719d0359c"
version = "0.6.3"
version = "0.6.6"

[[deps.RecursiveArrayTools]]
deps = ["Adapt", "ArrayInterfaceCore", "ArrayInterfaceStaticArraysCore", "ChainRulesCore", "DocStringExtensions", "FillArrays", "GPUArraysCore", "IteratorInterfaceExtensions", "LinearAlgebra", "RecipesBase", "StaticArraysCore", "Statistics", "Tables", "ZygoteRules"]
Expand Down
20 changes: 10 additions & 10 deletions perf/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ version = "0.3.2"
deps = ["Adapt", "BlockArrays", "CUDA", "ClimaComms", "CubedSphere", "DataStructures", "DiffEqBase", "DocStringExtensions", "ForwardDiff", "GaussQuadrature", "GilbertCurves", "HDF5", "InteractiveUtils", "IntervalSets", "LinearAlgebra", "PkgVersion", "RecursiveArrayTools", "RootSolvers", "Rotations", "SparseArrays", "Static", "StaticArrays", "Statistics", "UnPack"]
path = ".."
uuid = "d414da3d-4745-48bb-8d80-42e94e092884"
version = "0.10.15"
version = "0.10.16"

[[deps.ClimaCorePlots]]
deps = ["ClimaCore", "RecipesBase", "StaticArrays", "TriplotBase"]
Expand Down Expand Up @@ -585,10 +585,10 @@ uuid = "61eb1bfa-7361-4325-ad38-22787b887f55"
version = "0.16.4"

[[deps.GR]]
deps = ["Base64", "DelimitedFiles", "GR_jll", "HTTP", "JSON", "Libdl", "LinearAlgebra", "Pkg", "Printf", "Random", "RelocatableFolders", "Serialization", "Sockets", "Test", "UUIDs"]
git-tree-sha1 = "0ac6f27e784059c68b987f42b909ade0bcfabe69"
deps = ["Base64", "DelimitedFiles", "GR_jll", "HTTP", "JSON", "Libdl", "LinearAlgebra", "Pkg", "Preferences", "Printf", "Random", "Serialization", "Sockets", "Test", "UUIDs"]
git-tree-sha1 = "859e9cfa91d21ed87e8ea9f2998c94df1de12045"
uuid = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71"
version = "0.68.0"
version = "0.69.2"

[[deps.GR_jll]]
deps = ["Artifacts", "Bzip2_jll", "Cairo_jll", "FFMPEG_jll", "Fontconfig_jll", "GLFW_jll", "JLLWrappers", "JpegTurbo_jll", "Libdl", "Libtiff_jll", "Pixman_jll", "Pkg", "Qt5Base_jll", "Zlib_jll", "libpng_jll"]
Expand Down Expand Up @@ -738,9 +738,9 @@ version = "0.6.5"

[[deps.JLD2]]
deps = ["FileIO", "MacroTools", "Mmap", "OrderedCollections", "Pkg", "Printf", "Reexport", "TranscodingStreams", "UUIDs"]
git-tree-sha1 = "6c38bbe47948f74d63434abed68bdfc8d2c46b99"
git-tree-sha1 = "0d0ad913e827d13c5e88a73f9333d7e33c424576"
uuid = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
version = "0.4.23"
version = "0.4.24"

[[deps.JLFzf]]
deps = ["Pipe", "REPL", "Random", "fzf_jll"]
Expand Down Expand Up @@ -1231,9 +1231,9 @@ version = "1.3.1"

[[deps.Plots]]
deps = ["Base64", "Contour", "Dates", "Downloads", "FFMPEG", "FixedPointNumbers", "GR", "JLFzf", "JSON", "LaTeXStrings", "Latexify", "LinearAlgebra", "Measures", "NaNMath", "Pkg", "PlotThemes", "PlotUtils", "Printf", "REPL", "Random", "RecipesBase", "RecipesPipeline", "Reexport", "RelocatableFolders", "Requires", "Scratch", "Showoff", "SnoopPrecompile", "SparseArrays", "Statistics", "StatsBase", "UUIDs", "UnicodeFun", "Unzip"]
git-tree-sha1 = "284a353a34a352a95fca1d61ea28a0d48feaf273"
git-tree-sha1 = "f60a3090028cdf16b33a62f97eaedf67a6509824"
uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
version = "1.34.4"
version = "1.35.0"

[[deps.Polyester]]
deps = ["ArrayInterface", "BitTwiddlingConvenienceFunctions", "CPUSummary", "IfElse", "ManualMemory", "PolyesterWeave", "Requires", "Static", "StrideArraysCore", "ThreadingUtilities"]
Expand Down Expand Up @@ -1343,9 +1343,9 @@ version = "1.3.0"

[[deps.RecipesPipeline]]
deps = ["Dates", "NaNMath", "PlotUtils", "RecipesBase"]
git-tree-sha1 = "e7eac76a958f8664f2718508435d058168c7953d"
git-tree-sha1 = "017f217e647cf20b0081b9be938b78c3443356a0"
uuid = "01d81517-befc-4cb6-b9ec-a95719d0359c"
version = "0.6.3"
version = "0.6.6"

[[deps.RecursiveArrayTools]]
deps = ["Adapt", "ArrayInterfaceCore", "ArrayInterfaceStaticArraysCore", "ChainRulesCore", "DocStringExtensions", "FillArrays", "GPUArraysCore", "IteratorInterfaceExtensions", "LinearAlgebra", "RecipesBase", "StaticArraysCore", "Statistics", "Tables", "ZygoteRules"]
Expand Down
8 changes: 4 additions & 4 deletions src/Operators/finitedifference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3277,7 +3277,7 @@ function Base.similar(
return Field(Eltype, sp)
end

function _serial_copyto!(
@inline function _serial_copyto!(
field_out::Field,
bc::Base.Broadcast.Broadcasted{S},
Ni::Int,
Expand All @@ -3290,7 +3290,7 @@ function _serial_copyto!(
return field_out
end

function _threaded_copyto!(
@inline function _threaded_copyto!(
field_out::Field,
bc::Base.Broadcast.Broadcasted{S},
Ni::Int,
Expand All @@ -3307,7 +3307,7 @@ function _threaded_copyto!(
return field_out
end

function Base.copyto!(
@inline function Base.copyto!(
field_out::Field,
bc::Base.Broadcast.Broadcasted{S},
) where {S <: AbstractStencilStyle}
Expand All @@ -3320,7 +3320,7 @@ function Base.copyto!(
return _serial_copyto!(field_out, bc, Ni, Nj, Nh)
end

function apply_stencil!(field_out, bc, hidx)
Base.@propagate_inbounds function apply_stencil!(field_out, bc, hidx)
space = axes(bc)
if Topologies.isperiodic(Spaces.vertical_topology(space))
@inbounds for idx in
Expand Down
6 changes: 5 additions & 1 deletion test/Fields/field_opt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,11 @@ end

allocs_test_Ref_with_compose!(S, ∂ᶠ𝕄ₜ∂ᶜρ, ∂ᶜρₜ∂ᶠ𝕄)
p = @allocated allocs_test_Ref_with_compose!(S, ∂ᶠ𝕄ₜ∂ᶜρ, ∂ᶜρₜ∂ᶠ𝕄)
@test_broken p == 0
@test p == 0

allocs_test_Ref_with_compose_column!(S, ∂ᶠ𝕄ₜ∂ᶜρ, ∂ᶜρₜ∂ᶠ𝕄)
p = @allocated allocs_test_Ref_with_compose_column!(S, ∂ᶠ𝕄ₜ∂ᶜρ, ∂ᶜρₜ∂ᶠ𝕄)
@test p == 0
end
end
nothing
Loading

0 comments on commit f2eb09c

Please sign in to comment.