Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some allocations and gpu moist example #1882

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,6 @@ steps:
- "julia --project -e 'using CUDA; CUDA.versioninfo()'"
- "nsys profile --trace=nvtx,cuda --output=gpu_implicit_barowave_moist/report julia --color=yes --project=examples perf/benchmark_step.jl --job_id gpu_implicit_barowave_moist --z_elem 25 --h_elem 12 --initial_condition MoistBaroclinicWave --t_end 1mins --dt 1secs --dt_save_to_sol Inf --dt_save_to_disk Inf --moist equil --precip 0M --apply_limiter false"
artifact_paths: "gpu_implicit_barowave_moist/*"
soft_fail: true
agents:
slurm_gpus: 1

Expand Down
28 changes: 16 additions & 12 deletions src/cache/diagnostic_edmf_precomputed_quantities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -343,18 +343,20 @@ function set_diagnostic_edmf_precomputed_quantities!(Y, p, t)
scale_factor = FT(1e-6)
@. u³ʲ_halflevel = ifelse(
(
u³ʲ_datau³ʲ_data <
(scale_factor / (∂x³∂ξ³_level * ∂x³∂ξ³_level)) ||
ρaʲu³ʲ_data < (scale_factor / ∂x³∂ξ³_level)
(
u³ʲ_datau³ʲ_data <
(scale_factor / (∂x³∂ξ³_level * ∂x³∂ξ³_level))
) | (ρaʲu³ʲ_data < (scale_factor / ∂x³∂ξ³_level))
),
CT3(FT(0)),
CT3(sqrt(max(FT(0), u³ʲ_datau³ʲ_data))),
)
@. ρaʲ_level = ifelse(
(
u³ʲ_datau³ʲ_data <
(scale_factor / (∂x³∂ξ³_level * ∂x³∂ξ³_level)) ||
ρaʲu³ʲ_data < (scale_factor / ∂x³∂ξ³_level)
(
u³ʲ_datau³ʲ_data <
(scale_factor / (∂x³∂ξ³_level * ∂x³∂ξ³_level))
) | (ρaʲu³ʲ_data < (scale_factor / ∂x³∂ξ³_level))
),
FT(0),
ρaʲu³ʲ_data / sqrt(max(FT(0), u³ʲ_datau³ʲ_data)),
Expand All @@ -378,9 +380,10 @@ function set_diagnostic_edmf_precomputed_quantities!(Y, p, t)
)
@. h_totʲ_level = ifelse(
(
u³ʲ_datau³ʲ_data <
(scale_factor / (∂x³∂ξ³_level * ∂x³∂ξ³_level)) ||
ρaʲu³ʲ_data < (scale_factor / ∂x³∂ξ³_level)
(
u³ʲ_datau³ʲ_data <
(scale_factor / (∂x³∂ξ³_level * ∂x³∂ξ³_level))
) | (ρaʲu³ʲ_data < (scale_factor / ∂x³∂ξ³_level))
),
h_tot_level,
ρaʲu³ʲ_datah_tot / ρaʲu³ʲ_data,
Expand All @@ -404,9 +407,10 @@ function set_diagnostic_edmf_precomputed_quantities!(Y, p, t)
)
@. q_totʲ_level = ifelse(
(
u³ʲ_datau³ʲ_data <
(scale_factor / (∂x³∂ξ³_level * ∂x³∂ξ³_level)) ||
ρaʲu³ʲ_data < (scale_factor / ∂x³∂ξ³_level)
(
u³ʲ_datau³ʲ_data <
(scale_factor / (∂x³∂ξ³_level * ∂x³∂ξ³_level))
) | (ρaʲu³ʲ_data < (scale_factor / ∂x³∂ξ³_level))
),
q_tot_level,
ρaʲu³ʲ_dataq_tot / ρaʲu³ʲ_data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function non_orographic_gravity_wave_cache(

# This latitude depend source follows MiMA specs
source_ampl = @. ifelse(
lat > ϕ0_n || lat < ϕ0_s,
(lat > ϕ0_n) | (lat < ϕ0_s),
Bt_0 +
Bt_n * FT(0.5) * (FT(1) + tanh((lat - ϕ0_n) / dϕ_n)) +
Bt_s * FT(0.5) * (FT(1) + tanh((lat - ϕ0_s) / dϕ_s)),
Expand Down
7 changes: 3 additions & 4 deletions src/parameterized_tendencies/microphysics/precipitation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,9 @@ function precipitation_tendency!(
# update precip in cache for coupler's use
# 3d rain and snow
@. ᶜT[colidx] = TD.air_temperature(thermo_params, ᶜts[colidx])
@. ᶜ3d_rain[colidx] =
ifelse(ᶜT[colidx] >= FT(273.15), ᶜS_ρq_tot[colidx], FT(0))
@. ᶜ3d_snow[colidx] =
ifelse(ᶜT[colidx] < FT(273.15), ᶜS_ρq_tot[colidx], FT(0))
T_fr = TD.Parameters.T_freeze(thermo_params)
@. ᶜ3d_rain[colidx] = ifelse(ᶜT[colidx] >= T_fr, ᶜS_ρq_tot[colidx], 0)
@. ᶜ3d_snow[colidx] = ifelse(ᶜT[colidx] < T_fr, ᶜS_ρq_tot[colidx], 0)
Operators.column_integral_definite!(
col_integrated_rain[colidx],
ᶜ3d_rain[colidx],
Expand Down
2 changes: 1 addition & 1 deletion src/parameterized_tendencies/radiation/radiation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function radiation_model_cache(
),
center_cloud_fraction = RRTMGPI.field2array(
@. ifelse(
ᶜis_bottom_cloud || ᶜis_top_cloud,
ᶜis_bottom_cloud | ᶜis_top_cloud,
FT(1),
FT(0) * ᶜΔz,
)
Expand Down
2 changes: 1 addition & 1 deletion test/non_orographic_gravity_wave/nogw_test_mima.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function non_orographic_gravity_wave_cache(

# source amplitude following MiMA: radical change between subtropics and the tropic
source_ampl = @. ifelse(
lat > ϕ0_n || lat < ϕ0_s,
(lat > ϕ0_n) | (lat < ϕ0_s),
Bt_0 +
Bt_n * FT(0.5) * (FT(1) + tanh((lat - ϕ0_n) / dϕ_n)) +
Bt_s * FT(0.5) * (FT(1) + tanh((lat - ϕ0_s) / dϕ_s)),
Expand Down