Skip to content

Commit 8ac0ac3

Browse files
authored
Merge pull request #967 from CliMA/gb/allocations
Reduce allocations
2 parents aa7a61d + 1822266 commit 8ac0ac3

File tree

27 files changed

+450
-369
lines changed

27 files changed

+450
-369
lines changed

.buildkite/Manifest-v1.11.toml

Lines changed: 83 additions & 84 deletions
Large diffs are not rendered by default.

.buildkite/Manifest.toml

Lines changed: 83 additions & 84 deletions
Large diffs are not rendered by default.

.buildkite/longruns_gpu/pipeline.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
agents:
22
queue: clima
33
slurm_mem: 8G
4-
modules: climacommon/2024_10_09
4+
modules: climacommon/2024_12_16
5+
6+
env:
7+
JULIA_CUDA_MEMORY_POOL: "cuda"
8+
59

610
steps:
711
- label: "init :GPU:"

.buildkite/pipeline.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
agents:
22
queue: new-central
33
slurm_mem: 12G
4-
modules: climacommon/2024_10_09
4+
modules: climacommon/2024_12_16
55

66
env:
77
JULIA_NVTX_CALLBACKS: gc
88
OPENBLAS_NUM_THREADS: 1
99
SLURM_KILL_BAD_EXIT: 1
1010
JULIA_DEPOT_PATH: "${BUILDKITE_BUILD_PATH}/${BUILDKITE_PIPELINE_SLUG}/depot/default"
11+
JULIA_CUDA_MEMORY_POOL: "cuda"
12+
1113

1214
steps:
1315
- label: "init environment :computer:"

.buildkite/target/pipeline.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
agents:
22
queue: clima
3-
modules: climacommon/2024_10_09
3+
modules: climacommon/2024_12_16
44

55
env:
66
JULIA_DEPOT_PATH: "${BUILDKITE_BUILD_PATH}/${BUILDKITE_PIPELINE_SLUG}/depot/default"
77
JULIA_NVTX_CALLBACKS: gc
88
OPENBLAS_NUM_THREADS: 1
99
SLURM_KILL_BAD_EXIT: 1
10+
JULIA_CUDA_MEMORY_POOL: "cuda"
1011

1112
steps:
1213
- label: "init environment :computer:"

docs/src/APIs/shared_utilities.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ ClimaLand.CoupledAtmosphere
7575
ClimaLand.CoupledRadiativeFluxes
7676
ClimaLand.AbstractAtmosphericDrivers
7777
ClimaLand.AbstractRadiativeDrivers
78-
ClimaLand.turbulent_fluxes
78+
ClimaLand.turbulent_fluxes!
7979
ClimaLand.turbulent_fluxes_at_a_point
8080
ClimaLand.set_atmos_ts!
8181
ClimaLand.surface_air_density

docs/tutorials/standalone/Bucket/coupled_bucket.jl

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161

6262
# These are stored in the [BucketModel](https://clima.github.io/ClimaLand.jl/dev/APIs/Bucket/#ClimaLand.Bucket.BucketModel) object,
6363
# along with [BucketParameters](https://clima.github.io/ClimaLand.jl/dev/APIs/Bucket/#ClimaLand.Bucket.BucketParameters).
64-
# In order to compute turbulent surface fluxes, we call [turbulent_fluxes](https://clima.github.io/ClimaLand.jl/dev/APIs/shared_utilities/#ClimaLand.turbulent_fluxes),
64+
# In order to compute turbulent surface fluxes, we call [turbulent_fluxes!](https://clima.github.io/ClimaLand.jl/dev/APIs/shared_utilities/#ClimaLand.turbulent_fluxes!),
6565
# with arguments including `prescribed_atmos`. Since this argument is of the type `PrescribedAtmosphere`, the method of `turbulent_fluxes` which is executed is one which computes the turbulent surface fluxes
6666
# using MOST. We have a similar function for [net_radiation](https://clima.github.io/ClimaLand.jl/dev/APIs/shared_utilities/#ClimaLand.net_radiation) and which computes the net radiation based on the prescribed downwelling radiative fluxes, stored in an argument
6767
# `prescribed_radiation`, which is of type `PrescribedRadiation`.
@@ -74,38 +74,40 @@
7474
# struct CoupledRadiativeFluxes{FT} <: AbstractRadiativeDrivers{FT} end
7575
# ```
7676

77-
# Then, we have defined a new method for `turbulent_fluxes` and `net_radiation` which dispatch for these types,
78-
# and simply return the fluxes that the coupler has updated `p.bucket.turbulent_fluxes` and `p.bucket.R_n` with.
77+
# Then, we have defined a new method for `turbulent_fluxes!` and `net_radiation!` which dispatch for these types,
78+
# and updates dest with the fluxes that the coupler has updated `p.bucket.turbulent_fluxes` and `p.bucket.R_n` with.
7979
# In pseudo code:
8080
#
8181
# ```julia
82-
# function ClimaLand.turbulent_fluxes(
82+
# function ClimaLand.turbulent_fluxes!(
83+
# dest,
8384
# atmos::CoupledAtmosphere,
8485
# model::BucketModel,
8586
# p)
86-
# return (
87+
# dest .= (
8788
# lhf = p.bucket.turbulent_fluxes.lhf,
8889
# shf = p.bucket.turbulent_fluxes.shf,
8990
# vapor_flux = p.bucket.turbulent_fluxes.vapor_flux,
9091
# )
9192
# end
9293
# ```
9394

94-
# similarily:
95+
# similarily:
9596

9697
# ```julia
97-
# function ClimaLand.net_radiation(
98+
# function ClimaLand.net_radiation!(
99+
# dest,
98100
# radiation::CoupledRadiativeFluxes{FT},
99101
# model::BucketModel{FT},
100102
# p)
101-
# return p.bucket.R_n
103+
# dest .= p.bucket.R_n
102104
# end
103105
# ```
104106

105-
# These methods simply returns the values stored in the auxiliary state `p`. Importantly, these functions are
107+
# These methods update the values stored in the auxiliary state `p`. Importantly, these functions are
106108
# called by the bucket model
107109
# each time step **after** the coupler has already computed these values
108-
# (or extracted them from another model) and modifed `p`!
110+
# (or extracted them from another model) and modified `p`!
109111

110112
# # Surface air density
111113
# Within the right hand side/ODE function calls for the bucket model, we need both the

experiments/benchmarks/bucket.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#
1010
# When run with buildkite on clima, this code also compares with the previous best time
1111
# saved at the bottom of this file
12+
delete!(ENV, "JULIA_CUDA_MEMORY_POOL")
1213

1314
import SciMLBase
1415
using Dates
@@ -243,7 +244,7 @@ if ClimaComms.device() isa ClimaComms.CUDADevice
243244
end
244245

245246
if get(ENV, "BUILDKITE_PIPELINE_SLUG", nothing) == "climaland-benchmark"
246-
PREVIOUS_BEST_TIME = 1.1
247+
PREVIOUS_BEST_TIME = 0.477
247248
if average_timing_s > PREVIOUS_BEST_TIME + std_timing_s
248249
@info "Possible performance regression, previous average time was $(PREVIOUS_BEST_TIME)"
249250
elseif average_timing_s < PREVIOUS_BEST_TIME - std_timing_s

experiments/benchmarks/land.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
# Fixed number of iterations: 3
2121
# Jacobian update: Every Newton iteration
2222
# Atmos forcing update: every 3 hours
23+
delete!(ENV, "JULIA_CUDA_MEMORY_POOL")
24+
2325
import SciMLBase
2426
import ClimaComms
2527
ClimaComms.@import_required_backends
@@ -426,7 +428,7 @@ ProfileCanvas.html_file(flame_file, results)
426428
@info "Saved compute flame to $flame_file"
427429

428430
prob, ode_algo, Δt, cb = setup_simulation()
429-
Profile.Allocs.@profile sample_rate = 0.005 SciMLBase.solve(
431+
Profile.Allocs.@profile sample_rate = 0.0025 SciMLBase.solve(
430432
prob,
431433
ode_algo;
432434
dt = Δt,
@@ -463,7 +465,7 @@ if ClimaComms.device() isa ClimaComms.CUDADevice
463465
end
464466

465467
if get(ENV, "BUILDKITE_PIPELINE_SLUG", nothing) == "climaland-benchmark"
466-
PREVIOUS_BEST_TIME = 4.9
468+
PREVIOUS_BEST_TIME = 6.1
467469
if average_timing_s > PREVIOUS_BEST_TIME + std_timing_s
468470
@info "Possible performance regression, previous average time was $(PREVIOUS_BEST_TIME)"
469471
elseif average_timing_s < PREVIOUS_BEST_TIME - std_timing_s

experiments/benchmarks/richards.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
# Fixed number of iterations: 2
2222
# Jacobian update: Every Newton iteration
2323
# Precipitation data update: every timestep
24+
delete!(ENV, "JULIA_CUDA_MEMORY_POOL")
2425

2526
import SciMLBase
2627
using Dates
@@ -294,7 +295,7 @@ if ClimaComms.device() isa ClimaComms.CUDADevice
294295
end
295296

296297
if get(ENV, "BUILDKITE_PIPELINE_SLUG", nothing) == "climaland-benchmark"
297-
PREVIOUS_BEST_TIME = 5.9
298+
PREVIOUS_BEST_TIME = 5.8
298299
if average_timing_s > PREVIOUS_BEST_TIME + std_timing_s
299300
@info "Possible performance regression, previous average time was $(PREVIOUS_BEST_TIME)"
300301
elseif average_timing_s < PREVIOUS_BEST_TIME - std_timing_s

0 commit comments

Comments
 (0)