Skip to content

Commit

Permalink
Merge pull request #2979 from CliMA/ck/up_deps_patch
Browse files Browse the repository at this point in the history
Use ClimaTimesteppers `benchmark_step`
  • Loading branch information
charleskawczynski authored May 7, 2024
2 parents dc60dde + 4c89e20 commit 987aea9
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 137 deletions.
8 changes: 8 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,14 @@ steps:
agents:
slurm_mem: 24GB

- label: ":computer: Benchmark: perf target (gpu)"
command: >
julia --color=yes --project=perf perf/benchmark.jl
$PERF_CONFIG_PATH/bm_perf_target.yml
agents:
slurm_mem: 24GB
slurm_gpus: 1

- label: ":computer: Benchmark: perf target (Threaded)"
command: >
julia --color=yes --threads 8 --project=perf perf/benchmark.jl
Expand Down
12 changes: 6 additions & 6 deletions docs/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ weakdeps = ["StaticArrays"]

[[deps.AliasTables]]
deps = ["Random"]
git-tree-sha1 = "07591db28451b3e45f4c0088a2d5e986ae5aa92d"
git-tree-sha1 = "82b912bb5215792fd33df26f407d064d3602af98"
uuid = "66dad0bd-aa9a-41b7-9441-69ab47430ed8"
version = "1.1.1"
version = "1.1.2"

[[deps.Animations]]
deps = ["Colors"]
Expand Down Expand Up @@ -345,9 +345,9 @@ version = "0.5.8"

[[deps.ClimaCore]]
deps = ["Adapt", "BandedMatrices", "BlockArrays", "ClimaComms", "CubedSphere", "DataStructures", "DocStringExtensions", "ForwardDiff", "GaussQuadrature", "GilbertCurves", "HDF5", "InteractiveUtils", "IntervalSets", "KrylovKit", "LinearAlgebra", "MultiBroadcastFusion", "PkgVersion", "RecursiveArrayTools", "RootSolvers", "SparseArrays", "Static", "StaticArrays", "Statistics", "Unrolled"]
git-tree-sha1 = "ecac62e5b132806815ea017b7c76072bfd807b6d"
git-tree-sha1 = "eeb99b41998733bf4e907df9699f070ea9cc7695"
uuid = "d414da3d-4745-48bb-8d80-42e94e092884"
version = "0.14.1"
version = "0.14.2"
weakdeps = ["CUDA", "Krylov"]

[deps.ClimaCore.extensions]
Expand All @@ -368,9 +368,9 @@ version = "0.10.5"

[[deps.ClimaTimeSteppers]]
deps = ["ClimaComms", "Colors", "DataStructures", "DiffEqBase", "DiffEqCallbacks", "KernelAbstractions", "Krylov", "LinearAlgebra", "LinearOperators", "NVTX", "SciMLBase", "StaticArrays"]
git-tree-sha1 = "3168583915b1db93298d17853a1d222f0adb37e3"
git-tree-sha1 = "b1bede5bb3c33ff9280c57f602f601579b5acc6b"
uuid = "595c0a79-7f3d-439a-bc5a-b232dc3bde79"
version = "0.7.22"
version = "0.7.24"

[deps.ClimaTimeSteppers.extensions]
ClimaTimeSteppersBenchmarkToolsExt = ["CUDA", "BenchmarkTools", "OrderedCollections", "StatsBase", "PrettyTables"]
Expand Down
12 changes: 6 additions & 6 deletions examples/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ weakdeps = ["StaticArrays"]

[[deps.AliasTables]]
deps = ["Random"]
git-tree-sha1 = "07591db28451b3e45f4c0088a2d5e986ae5aa92d"
git-tree-sha1 = "82b912bb5215792fd33df26f407d064d3602af98"
uuid = "66dad0bd-aa9a-41b7-9441-69ab47430ed8"
version = "1.1.1"
version = "1.1.2"

[[deps.Animations]]
deps = ["Colors"]
Expand Down Expand Up @@ -337,9 +337,9 @@ version = "0.5.8"

[[deps.ClimaCore]]
deps = ["Adapt", "BandedMatrices", "BlockArrays", "ClimaComms", "CubedSphere", "DataStructures", "DocStringExtensions", "ForwardDiff", "GaussQuadrature", "GilbertCurves", "HDF5", "InteractiveUtils", "IntervalSets", "KrylovKit", "LinearAlgebra", "MultiBroadcastFusion", "PkgVersion", "RecursiveArrayTools", "RootSolvers", "SparseArrays", "Static", "StaticArrays", "Statistics", "Unrolled"]
git-tree-sha1 = "ecac62e5b132806815ea017b7c76072bfd807b6d"
git-tree-sha1 = "eeb99b41998733bf4e907df9699f070ea9cc7695"
uuid = "d414da3d-4745-48bb-8d80-42e94e092884"
version = "0.14.1"
version = "0.14.2"
weakdeps = ["CUDA", "Krylov"]

[deps.ClimaCore.extensions]
Expand Down Expand Up @@ -390,9 +390,9 @@ version = "0.10.5"

[[deps.ClimaTimeSteppers]]
deps = ["ClimaComms", "Colors", "DataStructures", "DiffEqBase", "DiffEqCallbacks", "KernelAbstractions", "Krylov", "LinearAlgebra", "LinearOperators", "NVTX", "SciMLBase", "StaticArrays"]
git-tree-sha1 = "3168583915b1db93298d17853a1d222f0adb37e3"
git-tree-sha1 = "b1bede5bb3c33ff9280c57f602f601579b5acc6b"
uuid = "595c0a79-7f3d-439a-bc5a-b232dc3bde79"
version = "0.7.22"
version = "0.7.24"

[deps.ClimaTimeSteppers.extensions]
ClimaTimeSteppersBenchmarkToolsExt = ["CUDA", "BenchmarkTools", "OrderedCollections", "StatsBase", "PrettyTables"]
Expand Down
12 changes: 6 additions & 6 deletions perf/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ weakdeps = ["StaticArrays"]

[[deps.AliasTables]]
deps = ["Random"]
git-tree-sha1 = "07591db28451b3e45f4c0088a2d5e986ae5aa92d"
git-tree-sha1 = "82b912bb5215792fd33df26f407d064d3602af98"
uuid = "66dad0bd-aa9a-41b7-9441-69ab47430ed8"
version = "1.1.1"
version = "1.1.2"

[[deps.Animations]]
deps = ["Colors"]
Expand Down Expand Up @@ -348,9 +348,9 @@ version = "0.5.8"

[[deps.ClimaCore]]
deps = ["Adapt", "BandedMatrices", "BlockArrays", "ClimaComms", "CubedSphere", "DataStructures", "DocStringExtensions", "ForwardDiff", "GaussQuadrature", "GilbertCurves", "HDF5", "InteractiveUtils", "IntervalSets", "KrylovKit", "LinearAlgebra", "MultiBroadcastFusion", "PkgVersion", "RecursiveArrayTools", "RootSolvers", "SparseArrays", "Static", "StaticArrays", "Statistics", "Unrolled"]
git-tree-sha1 = "ecac62e5b132806815ea017b7c76072bfd807b6d"
git-tree-sha1 = "eeb99b41998733bf4e907df9699f070ea9cc7695"
uuid = "d414da3d-4745-48bb-8d80-42e94e092884"
version = "0.14.1"
version = "0.14.2"
weakdeps = ["CUDA", "Krylov"]

[deps.ClimaCore.extensions]
Expand Down Expand Up @@ -401,9 +401,9 @@ version = "0.10.5"

[[deps.ClimaTimeSteppers]]
deps = ["ClimaComms", "Colors", "DataStructures", "DiffEqBase", "DiffEqCallbacks", "KernelAbstractions", "Krylov", "LinearAlgebra", "LinearOperators", "NVTX", "SciMLBase", "StaticArrays"]
git-tree-sha1 = "3168583915b1db93298d17853a1d222f0adb37e3"
git-tree-sha1 = "b1bede5bb3c33ff9280c57f602f601579b5acc6b"
uuid = "595c0a79-7f3d-439a-bc5a-b232dc3bde79"
version = "0.7.22"
version = "0.7.24"
weakdeps = ["BenchmarkTools", "CUDA", "OrderedCollections", "PrettyTables", "StatsBase"]

[deps.ClimaTimeSteppers.extensions]
Expand Down
66 changes: 19 additions & 47 deletions perf/benchmark.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,65 +5,38 @@ import ClimaAtmos as CA

include("common.jl")

using CUDA, BenchmarkTools, OrderedCollections, StatsBase, PrettyTables # needed for CTS.benchmark_step
using Test
using ClimaComms
import SciMLBase
import ClimaTimeSteppers as CTS

length(ARGS) != 1 && error("Usage: benchmark.jl <config_file>")
config_file = ARGS[1]
config_dict = YAML.load_file(config_file)
config = AtmosCoveragePerfConfig(config_dict)
config = AtmosCoveragePerfConfig(config_dict);

simulation = CA.get_simulation(config)
(; integrator) = simulation
simulation = CA.get_simulation(config);
(; integrator) = simulation;
(; parsed_args) = config;

(; parsed_args) = config
device = ClimaComms.device(config.comms_ctx)
(; table_summary, trials) = CTS.benchmark_step(integrator, device)

import SciMLBase
import ClimaTimeSteppers as CTS
SciMLBase.step!(integrator) # compile first

(; sol, u, p, dt, t) = integrator

W = get_W(integrator)
X = similar(u)

include("benchmark_utils.jl")

import OrderedCollections
import LinearAlgebra as LA
trials = OrderedCollections.OrderedDict()
#! format: off
trials["Wfact"] = get_trial(wfact_fun(integrator), (W, u, p, dt, t), "Wfact");
trials["linsolve"] = get_trial(LA.ldiv!, (X, W, u), "linsolve");
trials["implicit_tendency!"] = get_trial(implicit_fun(integrator), implicit_args(integrator), "implicit_tendency!");
trials["remaining_tendency!"] = get_trial(remaining_fun(integrator), remaining_args(integrator), "remaining_tendency!");
trials["additional_tendency!"] = get_trial(CA.additional_tendency!, (X, u, p, t), "additional_tendency!");
trials["hyperdiffusion_tendency!"] = get_trial(CA.hyperdiffusion_tendency!, remaining_args(integrator), "hyperdiffusion_tendency!");
trials["dss!"] = get_trial(CA.dss!, (u, p, t), "dss!");
trials["set_precomputed_quantities!"] = get_trial(CA.set_precomputed_quantities!, (u, p, t), "set_precomputed_quantities!");
trials["step!"] = get_trial(SciMLBase.step!, (integrator, ), "step!");
#! format: on

using Test
using ClimaComms

table_summary = OrderedCollections.OrderedDict()
for k in keys(trials)
table_summary[k] = get_summary(trials[k])
end
tabulate_summary(table_summary)

are_boundschecks_forced = Base.JLOptions().check_bounds == 1
# Benchmark allocation tests
@testset "Benchmark allocation tests" begin
if ClimaComms.device(config.comms_ctx) isa ClimaComms.CPUSingleThreaded &&
!are_boundschecks_forced
if device isa ClimaComms.CPUSingleThreaded && !are_boundschecks_forced
@test trials["Wfact"].memory == 0
@test trials["linsolve"].memory == 0
@test trials["implicit_tendency!"].memory == 0
@test trials["remaining_tendency!"].memory 2480
@test trials["additional_tendency!"].memory == 0
@test trials["hyperdiffusion_tendency!"].memory 2480
@test trials["ldiv!"].memory == 0
@test trials["T_imp!"].memory == 0
@test trials["T_exp_T_lim!"].memory 9920
@test trials["lim!"].memory == 0
@test trials["dss!"].memory == 0
@test trials["set_precomputed_quantities!"].memory 40
@test_broken trials["set_precomputed_quantities!"].memory < 40
@test trials["post_explicit!"].memory 120
@test trials["post_implicit!"].memory 160

# It's difficult to guarantee zero allocations,
# so let's just leave this as broken for now.
Expand All @@ -81,7 +54,6 @@ if get(ENV, "BUILDKITE", "") == "true"
end
end

import ClimaComms
if config.comms_ctx isa ClimaComms.SingletonCommsContext && !isinteractive()
include(joinpath(pkgdir(CA), "perf", "jet_report_nfailures.jl"))
end
72 changes: 0 additions & 72 deletions perf/benchmark_utils.jl

This file was deleted.

0 comments on commit 987aea9

Please sign in to comment.