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

No Cache #1849

Merged
merged 31 commits into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f83af43
Use a horrible extract hack to minimize footprint
chriselrod Jan 27, 2023
009dd63
Fix interpolants
chriselrod Jan 27, 2023
a0245e2
Use correct T2 definition
chriselrod Jan 27, 2023
ab30a34
Format
chriselrod Jan 27, 2023
0f9f5c9
Update src/caches/verner_caches.jl
ChrisRackauckas Jan 28, 2023
9d5b1ce
Update src/caches/verner_caches.jl
ChrisRackauckas Jan 28, 2023
01e3679
Update src/caches/verner_caches.jl
ChrisRackauckas Jan 28, 2023
047c2ca
Update src/caches/verner_caches.jl
ChrisRackauckas Jan 28, 2023
1a624b2
Update src/caches/verner_caches.jl
ChrisRackauckas Jan 28, 2023
83f5681
Update src/caches/verner_caches.jl
ChrisRackauckas Jan 28, 2023
e3d1d01
Update src/caches/verner_caches.jl
ChrisRackauckas Jan 28, 2023
32ebab2
Update src/tableaus/verner_tableaus.jl
ChrisRackauckas Jan 28, 2023
21d2376
Update src/tableaus/verner_tableaus.jl
ChrisRackauckas Jan 28, 2023
57007d4
Update src/tableaus/verner_tableaus.jl
ChrisRackauckas Jan 28, 2023
3b95623
Update src/tableaus/verner_tableaus.jl
ChrisRackauckas Jan 28, 2023
f1c9817
Update src/tableaus/verner_tableaus.jl
ChrisRackauckas Jan 28, 2023
6297a56
Update src/tableaus/verner_tableaus.jl
ChrisRackauckas Jan 28, 2023
f1f6864
Update Project.toml
ChrisRackauckas Jan 28, 2023
06e0a6f
Rename macro to OnDemandTableauExtra
chriselrod Jan 28, 2023
ea9b576
Tsit5Cache on demand
chriselrod Jan 28, 2023
cab9bf3
On demand tableaus for DP5
chriselrod Jan 28, 2023
04b2e59
CompiledFloats and fix name
chriselrod Jan 28, 2023
f732487
Fixes
chriselrod Jan 28, 2023
eb1a24c
Delete a few commented out code blocks
chriselrod Jan 28, 2023
c2ae6cc
Remove commented out fields
chriselrod Jan 28, 2023
8c120b1
No DP5Cache.tab
chriselrod Jan 28, 2023
db4670f
DP5Cache....
chriselrod Jan 28, 2023
7aad76c
add constvalue
ChrisRackauckas Jan 29, 2023
28d9ad3
`@fold` macro to indicate constants should constant fold
chriselrod Jan 29, 2023
433c71c
Fix macro
chriselrod Jan 29, 2023
676c20b
Update static_array_tests.jl
ChrisRackauckas Feb 8, 2023
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
3 changes: 3 additions & 0 deletions src/algorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6667,6 +6667,9 @@ struct CompositeAlgorithm{T, F} <: OrdinaryDiffEqCompositeAlgorithm
algs::T
choice_function::F
end
if isdefined(Base, :Experimental) && isdefined(Base.Experimental, :silence!)
Base.Experimental.silence!(CompositeAlgorithm)
end

################################################################################
"""
Expand Down
3 changes: 3 additions & 0 deletions src/caches/basic_caches.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ mutable struct CompositeCache{T, F} <: OrdinaryDiffEqCache
choice_function::F
current::Int
end
if isdefined(Base, :Experimental) && isdefined(Base.Experimental, :silence!)
Base.Experimental.silence!(CompositeCache)
end

function alg_cache(alg::CompositeAlgorithm, u, rate_prototype, ::Type{uEltypeNoUnits},
::Type{uBottomEltypeNoUnits}, ::Type{tTypeNoUnits}, uprev, uprev2, f, t,
Expand Down
19 changes: 9 additions & 10 deletions src/caches/low_order_rk_caches.jl
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ function alg_cache(alg::BS5, u, rate_prototype, ::Type{uEltypeNoUnits},
BS5ConstantCache(constvalue(uBottomEltypeNoUnits), constvalue(tTypeNoUnits))
end

@cache struct Tsit5Cache{uType, rateType, uNoUnitsType, TabType, StageLimiter, StepLimiter,
@cache struct Tsit5Cache{uType, rateType, uNoUnitsType, StageLimiter, StepLimiter,
Thread} <: OrdinaryDiffEqMutableCache
u::uType
uprev::uType
Expand All @@ -428,11 +428,13 @@ end
utilde::uType
tmp::uType
atmp::uNoUnitsType
tab::TabType
stage_limiter!::StageLimiter
step_limiter!::StepLimiter
thread::Thread
end
if isdefined(Base, :Experimental) && isdefined(Base.Experimental, :silence!)
Base.Experimental.silence!(Tsit5Cache)
end

@cache struct RK46NLCache{uType, rateType, TabType, StageLimiter, StepLimiter, Thread} <:
OrdinaryDiffEqMutableCache
Expand Down Expand Up @@ -509,7 +511,6 @@ function alg_cache(alg::Tsit5, u, rate_prototype, ::Type{uEltypeNoUnits},
::Type{uBottomEltypeNoUnits}, ::Type{tTypeNoUnits}, uprev, uprev2, f, t,
dt, reltol, p, calck,
::Val{true}) where {uEltypeNoUnits, uBottomEltypeNoUnits, tTypeNoUnits}
tab = Tsit5ConstantCache(constvalue(uBottomEltypeNoUnits), constvalue(tTypeNoUnits))
k1 = zero(rate_prototype)
k2 = zero(rate_prototype)
k3 = zero(rate_prototype)
Expand All @@ -521,18 +522,18 @@ function alg_cache(alg::Tsit5, u, rate_prototype, ::Type{uEltypeNoUnits},
atmp = similar(u, uEltypeNoUnits)
recursivefill!(atmp, false)
tmp = zero(u)
Tsit5Cache(u, uprev, k1, k2, k3, k4, k5, k6, k7, utilde, tmp, atmp, tab,
Tsit5Cache(u, uprev, k1, k2, k3, k4, k5, k6, k7, utilde, tmp, atmp,
alg.stage_limiter!, alg.step_limiter!, alg.thread)
end

function alg_cache(alg::Tsit5, u, rate_prototype, ::Type{uEltypeNoUnits},
::Type{uBottomEltypeNoUnits}, ::Type{tTypeNoUnits}, uprev, uprev2, f, t,
dt, reltol, p, calck,
::Val{false}) where {uEltypeNoUnits, uBottomEltypeNoUnits, tTypeNoUnits}
Tsit5ConstantCache(constvalue(uBottomEltypeNoUnits), constvalue(tTypeNoUnits))
Tsit5ConstantCache()
end

@cache struct DP5Cache{uType, rateType, uNoUnitsType, TabType, StageLimiter, StepLimiter,
@cache struct DP5Cache{uType, rateType, uNoUnitsType, StageLimiter, StepLimiter,
Thread} <: OrdinaryDiffEqMutableCache
u::uType
uprev::uType
Expand All @@ -550,7 +551,6 @@ end
utilde::uType
tmp::uType
atmp::uNoUnitsType
tab::TabType
stage_limiter!::StageLimiter
step_limiter!::StepLimiter
thread::Thread
Expand Down Expand Up @@ -583,9 +583,8 @@ function alg_cache(alg::DP5, u, rate_prototype, ::Type{uEltypeNoUnits},
atmp = k3
end

tab = DP5ConstantCache(constvalue(uBottomEltypeNoUnits), constvalue(tTypeNoUnits))
cache = DP5Cache(u, uprev, k1, k2, k3, k4, k5, k6, k7, dense_tmp3, dense_tmp4, update,
bspl, utilde, tmp, atmp, tab, alg.stage_limiter!, alg.step_limiter!,
bspl, utilde, tmp, atmp, alg.stage_limiter!, alg.step_limiter!,
alg.thread)
cache
end
Expand All @@ -594,7 +593,7 @@ function alg_cache(alg::DP5, u, rate_prototype, ::Type{uEltypeNoUnits},
::Type{uBottomEltypeNoUnits}, ::Type{tTypeNoUnits}, uprev, uprev2, f, t,
dt, reltol, p, calck,
::Val{false}) where {uEltypeNoUnits, uBottomEltypeNoUnits, tTypeNoUnits}
DP5ConstantCache(constvalue(uBottomEltypeNoUnits), constvalue(tTypeNoUnits))
DP5ConstantCache()
end

@cache struct Anas5Cache{uType, rateType, uNoUnitsType, TabType} <:
Expand Down
12 changes: 4 additions & 8 deletions src/caches/nordsieck_caches.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ function alg_cache(alg::AN5, u, rate_prototype, ::Type{uEltypeNoUnits},
m = zero(l)
c_LTE = c_conv = zero(tTypeNoUnits)
dts = fill(zero(dt), 6)
tsit5tab = Tsit5ConstantCache(constvalue(uBottomEltypeNoUnits),
constvalue(tTypeNoUnits))
tsit5tab = Tsit5ConstantCache()
AN5ConstantCache(z, l, m, c_LTE, c_conv, dts, Δ, tsit5tab, 1)
end

Expand Down Expand Up @@ -67,7 +66,6 @@ function alg_cache(alg::AN5, u, rate_prototype, ::Type{uEltypeNoUnits},
::Val{true}) where {uEltypeNoUnits, uBottomEltypeNoUnits, tTypeNoUnits}
#################################################
# Tsit5
tab = Tsit5ConstantCache(constvalue(uBottomEltypeNoUnits), constvalue(tTypeNoUnits))
# Cannot alias pointers, since we have to use `k`s to start the Nordsieck vector
k1 = zero(rate_prototype)
k2 = zero(rate_prototype)
Expand All @@ -80,7 +78,7 @@ function alg_cache(alg::AN5, u, rate_prototype, ::Type{uEltypeNoUnits},
atmp = similar(u, uEltypeNoUnits)
recursivefill!(atmp, false)
tmp = zero(u)
tsit5cache = Tsit5Cache(u, uprev, k1, k2, k3, k4, k5, k6, k7, utilde, tmp, atmp, tab,
tsit5cache = Tsit5Cache(u, uprev, k1, k2, k3, k4, k5, k6, k7, utilde, tmp, atmp,
trivial_limiter!, trivial_limiter!, False())
#################################################
N = 5
Expand Down Expand Up @@ -152,8 +150,7 @@ function alg_cache(alg::JVODE, u, rate_prototype, ::Type{uEltypeNoUnits},
m = zero(l)
c_LTE₊₁ = c_LTE = c_LTE₋₁ = c_conv = c_𝒟 = prev_𝒟 = zero(tTypeNoUnits)
dts = fill(zero(dt), N + 1)
tsit5tab = Tsit5ConstantCache(constvalue(uBottomEltypeNoUnits),
constvalue(tTypeNoUnits))
tsit5tab = Tsit5ConstantCache()
η = zero(dt / dt)
JVODEConstantCache(z, l, m,
c_LTE₊₁, c_LTE, c_LTE₋₁, c_conv, c_𝒟, prev_𝒟,
Expand Down Expand Up @@ -213,7 +210,6 @@ function alg_cache(alg::JVODE, u, rate_prototype, ::Type{uEltypeNoUnits},
#################################################
# Tsit5
# Cannot alias pointers, since we have to use `k`s to start the Nordsieck vector
tab = Tsit5ConstantCache(constvalue(uBottomEltypeNoUnits), constvalue(tTypeNoUnits))
k1 = zero(rate_prototype)
k2 = zero(rate_prototype)
k3 = zero(rate_prototype)
Expand All @@ -225,7 +221,7 @@ function alg_cache(alg::JVODE, u, rate_prototype, ::Type{uEltypeNoUnits},
atmp = similar(u, uEltypeNoUnits)
recursivefill!(atmp, false)
tmp = zero(u)
tsit5cache = Tsit5Cache(u, uprev, k1, k2, k3, k4, k5, k6, k7, utilde, tmp, atmp, tab,
tsit5cache = Tsit5Cache(u, uprev, k1, k2, k3, k4, k5, k6, k7, utilde, tmp, atmp,
trivial_limiter!, trivial_limiter!, False())
#################################################
fsalfirst = zero(rate_prototype)
Expand Down
26 changes: 8 additions & 18 deletions src/caches/verner_caches.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function alg_cache(alg::Vern6, u, rate_prototype, ::Type{uEltypeNoUnits},
Vern6ConstantCache(tab)
end

@cache struct Vern7Cache{uType, rateType, uNoUnitsType, TabType, StageLimiter, StepLimiter,
@cache struct Vern7Cache{uType, rateType, uNoUnitsType, StageLimiter, StepLimiter,
Thread} <:
OrdinaryDiffEqMutableCache
u::uType
Expand All @@ -76,7 +76,6 @@ end
tmp::uType
rtmp::rateType
atmp::uNoUnitsType
tab::TabType
stage_limiter!::StageLimiter
step_limiter!::StepLimiter
thread::Thread
Expand All @@ -86,7 +85,6 @@ function alg_cache(alg::Vern7, u, rate_prototype, ::Type{uEltypeNoUnits},
::Type{uBottomEltypeNoUnits}, ::Type{tTypeNoUnits}, uprev, uprev2, f, t,
dt, reltol, p, calck,
::Val{true}) where {uEltypeNoUnits, uBottomEltypeNoUnits, tTypeNoUnits}
tab = Vern7Tableau(constvalue(uBottomEltypeNoUnits), constvalue(tTypeNoUnits))
k1 = zero(rate_prototype)
k2 = zero(rate_prototype)
k3 = k2
Expand All @@ -103,19 +101,16 @@ function alg_cache(alg::Vern7, u, rate_prototype, ::Type{uEltypeNoUnits},
recursivefill!(atmp, false)
rtmp = uEltypeNoUnits === eltype(u) ? utilde : zero(rate_prototype)
Vern7Cache(u, uprev, k1, k2, k3, k4, k5, k6, k7, k8, k9, k10, utilde, tmp, rtmp, atmp,
tab, alg.stage_limiter!, alg.step_limiter!, alg.thread)
alg.stage_limiter!, alg.step_limiter!, alg.thread)
end

struct Vern7ConstantCache{TabType} <: OrdinaryDiffEqConstantCache
tab::TabType
end
struct Vern7ConstantCache <: OrdinaryDiffEqConstantCache end

function alg_cache(alg::Vern7, u, rate_prototype, ::Type{uEltypeNoUnits},
::Type{uBottomEltypeNoUnits}, ::Type{tTypeNoUnits}, uprev, uprev2, f, t,
dt, reltol, p, calck,
::Val{false}) where {uEltypeNoUnits, uBottomEltypeNoUnits, tTypeNoUnits}
tab = Vern7Tableau(constvalue(uBottomEltypeNoUnits), constvalue(tTypeNoUnits))
Vern7ConstantCache(tab)
Vern7ConstantCache()
end

@cache struct Vern8Cache{uType, rateType, uNoUnitsType, TabType, StageLimiter, StepLimiter,
Expand Down Expand Up @@ -185,7 +180,7 @@ function alg_cache(alg::Vern8, u, rate_prototype, ::Type{uEltypeNoUnits},
Vern8ConstantCache(tab)
end

@cache struct Vern9Cache{uType, rateType, uNoUnitsType, TabType, StageLimiter, StepLimiter,
@cache struct Vern9Cache{uType, rateType, uNoUnitsType, StageLimiter, StepLimiter,
Thread} <:
OrdinaryDiffEqMutableCache
u::uType
Expand All @@ -210,7 +205,6 @@ end
tmp::uType
rtmp::rateType
atmp::uNoUnitsType
tab::TabType
stage_limiter!::StageLimiter
step_limiter!::StepLimiter
thread::Thread
Expand All @@ -220,7 +214,6 @@ function alg_cache(alg::Vern9, u, rate_prototype, ::Type{uEltypeNoUnits},
::Type{uBottomEltypeNoUnits}, ::Type{tTypeNoUnits}, uprev, uprev2, f, t,
dt, reltol, p, calck,
::Val{true}) where {uEltypeNoUnits, uBottomEltypeNoUnits, tTypeNoUnits}
tab = Vern9Tableau(constvalue(uBottomEltypeNoUnits), constvalue(tTypeNoUnits))
k1 = zero(rate_prototype)
k2 = zero(rate_prototype)
k3 = k2
Expand All @@ -243,18 +236,15 @@ function alg_cache(alg::Vern9, u, rate_prototype, ::Type{uEltypeNoUnits},
recursivefill!(atmp, false)
rtmp = uEltypeNoUnits === eltype(u) ? utilde : zero(rate_prototype)
Vern9Cache(u, uprev, k1, k2, k3, k4, k5, k6, k7, k8, k9, k10, k11, k12, k13, k14, k15,
k16, utilde, tmp, rtmp, atmp, tab, alg.stage_limiter!, alg.step_limiter!,
k16, utilde, tmp, rtmp, atmp, alg.stage_limiter!, alg.step_limiter!,
alg.thread)
end

struct Vern9ConstantCache{TabType} <: OrdinaryDiffEqConstantCache
tab::TabType
end
struct Vern9ConstantCache <: OrdinaryDiffEqConstantCache end

function alg_cache(alg::Vern9, u, rate_prototype, ::Type{uEltypeNoUnits},
::Type{uBottomEltypeNoUnits}, ::Type{tTypeNoUnits}, uprev, uprev2, f, t,
dt, reltol, p, calck,
::Val{false}) where {uEltypeNoUnits, uBottomEltypeNoUnits, tTypeNoUnits}
tab = Vern9Tableau(constvalue(uBottomEltypeNoUnits), constvalue(tTypeNoUnits))
Vern9ConstantCache(tab)
Vern9ConstantCache()
end
40 changes: 20 additions & 20 deletions src/dense/generic_dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,37 +46,37 @@ end
if length(integrator.cache.caches) == 2
if cache_current == 1
_ode_addsteps!(integrator.k, integrator.tprev, integrator.uprev,
integrator.u,
integrator.dt, f, integrator.p,
cache.caches[1],
always_calc_begin, allow_calc_end, force_calc_end)
integrator.u,
integrator.dt, f, integrator.p,
cache.caches[1],
always_calc_begin, allow_calc_end, force_calc_end)
else
@assert cache_current == 2
_ode_addsteps!(integrator.k, integrator.tprev, integrator.uprev,
integrator.u,
integrator.dt, f, integrator.p,
cache.caches[2],
always_calc_begin, allow_calc_end, force_calc_end)
integrator.u,
integrator.dt, f, integrator.p,
cache.caches[2],
always_calc_begin, allow_calc_end, force_calc_end)
end
else
if cache_current == 1
_ode_addsteps!(integrator.k, integrator.tprev, integrator.uprev,
integrator.u,
integrator.dt, f, integrator.p,
cache.caches[1],
always_calc_begin, allow_calc_end, force_calc_end)
integrator.u,
integrator.dt, f, integrator.p,
cache.caches[1],
always_calc_begin, allow_calc_end, force_calc_end)
elseif cache_current == 2
_ode_addsteps!(integrator.k, integrator.tprev, integrator.uprev,
integrator.u,
integrator.dt, f, integrator.p,
cache.caches[2],
always_calc_begin, allow_calc_end, force_calc_end)
integrator.u,
integrator.dt, f, integrator.p,
cache.caches[2],
always_calc_begin, allow_calc_end, force_calc_end)
else
_ode_addsteps!(integrator.k, integrator.tprev, integrator.uprev,
integrator.u,
integrator.dt, f, integrator.p,
cache.caches[cache_current],
always_calc_begin, allow_calc_end, force_calc_end)
integrator.u,
integrator.dt, f, integrator.p,
cache.caches[cache_current],
always_calc_begin, allow_calc_end, force_calc_end)
end
end
end
Expand Down
15 changes: 8 additions & 7 deletions src/dense/interpolants.jl
Original file line number Diff line number Diff line change
Expand Up @@ -366,11 +366,10 @@ simplifying assumption

Ch. Tsitouras
"""
@def tsit5unpack begin if typeof(cache) <: OrdinaryDiffEqMutableCache
@unpack r11, r12, r13, r14, r22, r23, r24, r32, r33, r34, r42, r43, r44, r52, r53, r54, r62, r63, r64, r72, r73, r74 = cache.tab
else
@unpack r11, r12, r13, r14, r22, r23, r24, r32, r33, r34, r42, r43, r44, r52, r53, r54, r62, r63, r64, r72, r73, r74 = cache
end end
@def tsit5unpack begin
var"#T#" = constvalue(recursive_unitless_bottom_eltype(y₁))
r11, r12, r13, r14, r22, r23, r24, r32, r33, r34, r42, r43, r44, r52, r53, r54, r62, r63, r64, r72, r73, r74 = Tsit5Interp(var"#T#")
end

@def tsit5pre0 begin
@tsit5unpack
Expand Down Expand Up @@ -1788,7 +1787,8 @@ end

## Vern7
@def vern7unpack begin
@unpack r011, r012, r013, r014, r015, r016, r017, r042, r043, r044, r045, r046, r047, r052, r053, r054, r055, r056, r057, r062, r063, r064, r065, r066, r067, r072, r073, r074, r075, r076, r077, r082, r083, r084, r085, r086, r087, r092, r093, r094, r095, r096, r097, r112, r113, r114, r115, r116, r117, r122, r123, r124, r125, r126, r127, r132, r133, r134, r135, r136, r137, r142, r143, r144, r145, r146, r147, r152, r153, r154, r155, r156, r157, r162, r163, r164, r165, r166, r167 = cache.tab.interp
var"#T#" = constvalue(recursive_unitless_bottom_eltype(y₁))
@OnDemandTableauExtract Vern7InterpolationCoefficients var"#T#"
end

@def vern7pre0 begin
Expand Down Expand Up @@ -2106,7 +2106,8 @@ end

## Vern9
@def vern9unpack begin
@unpack r011, r012, r013, r014, r015, r016, r017, r018, r019, r082, r083, r084, r085, r086, r087, r088, r089, r092, r093, r094, r095, r096, r097, r098, r099, r102, r103, r104, r105, r106, r107, r108, r109, r112, r113, r114, r115, r116, r117, r118, r119, r122, r123, r124, r125, r126, r127, r128, r129, r132, r133, r134, r135, r136, r137, r138, r139, r142, r143, r144, r145, r146, r147, r148, r149, r152, r153, r154, r155, r156, r157, r158, r159, r172, r173, r174, r175, r176, r177, r178, r179, r182, r183, r184, r185, r186, r187, r188, r189, r192, r193, r194, r195, r196, r197, r198, r199, r202, r203, r204, r205, r206, r207, r208, r209, r212, r213, r214, r215, r216, r217, r218, r219, r222, r223, r224, r225, r226, r227, r228, r229, r232, r233, r234, r235, r236, r237, r238, r239, r242, r243, r244, r245, r246, r247, r248, r249, r252, r253, r254, r255, r256, r257, r258, r259, r262, r263, r264, r265, r266, r267, r268, r269 = cache.tab.interp
var"#T#" = constvalue(recursive_unitless_bottom_eltype(y₁))
@OnDemandTableauExtract Vern9InterpolationCoefficients var"#T#"
end

@def vern9pre0 begin
Expand Down
Loading