Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
charleskawczynski committed Jul 11, 2023
1 parent bd04d8f commit a6599a5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 17 deletions.
4 changes: 3 additions & 1 deletion examples/hybrid/sphere/balanced_flow_rhoe.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Test
import ClimaTimeSteppers as CTS
using ClimaCorePlots, Plots
using ClimaCore.DataLayouts

Expand All @@ -15,7 +16,8 @@ t_end = FT(60 * 60)
dt = FT(5)
dt_save_to_sol = FT(50)
dt_save_to_disk = FT(0) # 0 means don't save to disk
ode_algorithm = OrdinaryDiffEq.SSPRK33
ode_algorithm = CTS.SSP33ShuOsher
jacobian_flags = (; ∂ᶜ𝔼ₜ∂ᶠ𝕄_mode = :exact, ∂ᶠ𝕄ₜ∂ᶜρ_mode = :exact)

additional_cache(ᶜlocal_geometry, ᶠlocal_geometry, dt) = merge(
hyperdiffusion_cache(ᶜlocal_geometry, ᶠlocal_geometry; κ₄ = FT(2e17)),
Expand Down
33 changes: 21 additions & 12 deletions examples/sphere/shallow_water_cuda.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ using ClimaComms
using DocStringExtensions
using LinearAlgebra
using ClimaTimeSteppers, DiffEqBase
import OrdinaryDiffEq as ODE
import ClimaTimeSteppers as CTS
using DiffEqCallbacks
using NVTX

Expand Down Expand Up @@ -448,7 +450,9 @@ function set_initial_condition(
return Y
end

function rhs!(dYdt, y, parameters, t)
function rhs!(_dYdt, _y, parameters, t)
dYdt = _dYdt.c
y = _y.c
NVTX.@range "rhs!" begin
(; f, h_s, ghost_buffer, params) = parameters
(; D₄, g) = params
Expand Down Expand Up @@ -487,7 +491,7 @@ function rhs!(dYdt, y, parameters, t)
NVTX.@range "dss" Spaces.weighted_dss2!(dYdt, ghost_buffer)
end
end
return dYdt
return _dYdt
end

function shallow_water_driver_cuda(ARGS, ::Type{FT}) where {FT}
Expand Down Expand Up @@ -523,12 +527,13 @@ function shallow_water_driver_cuda(ARGS, ::Type{FT}) where {FT}
space = Spaces.SpectralElementSpace2D(grid_topology, quad)
f = set_coriolis_parameter(space, test)
h_s = surface_topography(space, test)
Y = set_initial_condition(space, test)
Y = Fields.FieldVector(; c = set_initial_condition(space, test))
@show eltype(Y)

ghost_buffer = Spaces.create_dss_buffer(Y)
Spaces.weighted_dss_start!(Y, ghost_buffer)
Spaces.weighted_dss_internal!(Y, ghost_buffer)
Spaces.weighted_dss_ghost!(Y, ghost_buffer)
ghost_buffer = Spaces.create_dss_buffer(Y.c)
Spaces.weighted_dss_start!(Y.c, ghost_buffer)
Spaces.weighted_dss_internal!(Y.c, ghost_buffer)
Spaces.weighted_dss_ghost!(Y.c, ghost_buffer)

parameters =
(; f = f, h_s = h_s, ghost_buffer = ghost_buffer, params = test.params)
Expand Down Expand Up @@ -562,12 +567,16 @@ function shallow_water_driver_cuda(ARGS, ::Type{FT}) where {FT}
end
return nothing
end

prob =
ODEProblem(ClimaODEFunction(; T_exp! = rhs!), Y, (0.0, T), parameters)
integrator = DiffEqBase.init(
@show (0.0, T)
prob = ODE.ODEProblem(
CTS.ClimaODEFunction(; T_exp! = rhs!),
Y,
(FT(0), T),
parameters,
)
integrator = ODE.init(
prob,
ExplicitAlgorithm(SSP33ShuOsher()),
CTS.ExplicitAlgorithm(CTS.SSP33ShuOsher()),
dt = dt,
saveat = [],
progress = true,
Expand Down
8 changes: 4 additions & 4 deletions test/Operators/finitedifference/linsolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ face_space = Spaces.FaceExtrudedFiniteDifferenceSpace(center_space)
=#
face_space = Spaces.FaceFiniteDifferenceSpace(center_space)

function _linsolve!(x, A, b, update_matrix = false; kwargs...)
function test_linsolve!(x, A, b, update_matrix = false; kwargs...)

FT = Spaces.undertype(axes(x.c))

Expand Down Expand Up @@ -88,11 +88,11 @@ W = SchurComplementW(Y, use_transform, jacobi_flags)

using JET
using Test
@time _linsolve!(Y, W, b)
@time _linsolve!(Y, W, b)
@time test_linsolve!(Y, W, b)
@time test_linsolve!(Y, W, b)

@testset "JET test for `apply` in linsolve! kernel" begin
@test_opt _linsolve!(Y, W, b)
@test_opt test_linsolve!(Y, W, b)
end

ClimaCore.Operators.allow_mismatched_fd_spaces() = false

0 comments on commit a6599a5

Please sign in to comment.