Expensive GPU kernel
- Dominant language
- Julia
- Stars
- 117
- Forks
- 19
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 41
Description
Here is a MWE for an expensive GPU kernel (creating a thermodynamic state):
```julia
using Revise
import ClimaCore;
using Test
import Thermodynamics
import Thermodynamics as TD
import ClimaCore.Fields as Fields
import ClimaCore.DataLayouts as DataLayouts
using BenchmarkTools;
@isdefined(TU) || include(joinpath(pkgdir(ClimaCore), "test", "TestUtilities", "TestUtilities.jl"));
import .TestUtilities as TU;
FT = Float64;
zelem=25
space = TU.CenterExtrudedFiniteDifferenceSpace(FT;zelem, helem=10);
x = fill((;ᶜts=zero(TD.PhaseEquil{FT}), ᶜK = FT(0), ᶜΦ=FT(0),ρ=FT(0),p=FT(0), e_tot=FT(0), q_tot=FT(0)), space);
# From ClimaAtmos
import CLIMAParameters as CP
aliases = string.(fieldnames(TD.Parameters.ThermodynamicsParameters));
toml_dict = CP.create_toml_dict(FT);
pairs = CP.get_parameter_values!(toml_dict, aliases, "Thermodynamics");
const thermo_params = TD.Parameters.ThermodynamicsParameters{FT}(; pairs...)
function thermo_state(;ρ = nothing, e_int = nothing,q_tot = nothing)
return TD.PhaseEquil_ρeq(
thermo_params,
ρ,
e_int,
q_tot,
3,
eltype(thermo_params)(0.003),
)
end
ts_gs(e_tot, q_tot, K, Φ, ρ) = thermo_state(;ρ, e_int = e_tot - K - Φ, q_tot)
function thermo_kernel!(x)
(; ᶜts, ᶜK, ᶜΦ, ρ, e_tot, q_tot) = x
@. ᶜts = ts_gs(e_tot, q_tot, ᶜK, ᶜΦ, ρ)
return nothing
end;
ρ = FT(1)
ρu = FT[1, 2, 3]
ρe = FT(1100)
e_pot = FT(93)
q_tot₀ = 0.001
e_int₀ = TD.internal_energy(ρ, ρe, ρu, e_pot)
ts₀ = TD.PhaseEquil_ρeq(thermo_params, ρ, e_int₀, q_tot₀)
e_tot₀ = TD.total_energy(thermo_params, ts₀, FT(0), FT(0))
@. x.ρ = 1
@. x.q_tot = q_tot₀
@. x.e_tot = e_int₀
@. x.ᶜts.T = FT(0)
thermo_kernel!(x) # compile first / correctness test
@testset "correctness (span field)" begin
@test !any(x->x≈0, parent(x.ᶜts.T)) # correctness test
end
println("\n******************* thermo_kernel")
trial = BenchmarkTools.@benchmark thermo_kernel!($x);
show(stdout, MIME("text/plain"), trial);
nothing
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by running the provided MWE and its BenchmarkTools trial around thermo_kernel!(x), then inspect the PhaseEquil_ρeq path used by ts_gs. Compare the kernel's cost and correctness output before and after investigation; the issue does not define a target runtime or specific code location, so the desired completion criteria need clarification.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100