From f11da89812ab83ff5b1d75c827ced50e97167ae7 Mon Sep 17 00:00:00 2001 From: LenkaNovak Date: Thu, 2 May 2024 13:41:50 -0700 Subject: [PATCH] use Base.@precompile --- experiments/AMIP/coupler_driver.jl | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/experiments/AMIP/coupler_driver.jl b/experiments/AMIP/coupler_driver.jl index b9ff99ce54..27458d6a37 100644 --- a/experiments/AMIP/coupler_driver.jl +++ b/experiments/AMIP/coupler_driver.jl @@ -710,8 +710,7 @@ function solve_coupler!(cs) ClimaComms.iamroot(comms_ctx) && @info("Starting coupling loop") ## step in time - ## Use ClimaComms.@elapsed to time the simulation on both CPU and GPU - walltime = ClimaComms.@elapsed comms_ctx.device for t in ((tspan[begin] + Δt_cpl):Δt_cpl:tspan[end]) + for t in (tspan[begin]:Δt_cpl:tspan[end]) cs.dates.date[1] = TimeManager.current_date(cs, t) @@ -798,9 +797,8 @@ function solve_coupler!(cs) TimeManager.trigger_callback!(cs, cs.callbacks.checkpoint) end - ClimaComms.iamroot(comms_ctx) && @show(walltime) - return walltime + return nothing end ## exit if running performance anaysis #hide @@ -808,8 +806,16 @@ if haskey(ENV, "CI_PERF_SKIP_COUPLED_RUN") #hide throw(:exit_profile_init) #hide end #hide -## run the coupled simulation -walltime = solve_coupler!(cs); +## precompile the coupler loop before running, so that our runtime analysis is accurate +Base.precompile(solve_coupler!, (typeof(cs),)) + +## Use ClimaComms.@elapsed to time the simulation on both CPU and GPU +walltime = ClimaComms.@elapsed comms_ctx.device begin + s = CA.@timed_str begin + solve_coupler!(cs) + end +end +ClimaComms.iamroot(comms_ctx) && @show(walltime) ## Use ClimaAtmos calculation to show the simulated years per day of the simulation (SYPD) es = CA.EfficiencyStats(tspan, walltime)