diff --git a/lib/OrdinaryDiffEqAdamsBashforthMoulton/src/adams_bashforth_moulton_caches.jl b/lib/OrdinaryDiffEqAdamsBashforthMoulton/src/adams_bashforth_moulton_caches.jl index d417f9cdad..283b4b6b18 100644 --- a/lib/OrdinaryDiffEqAdamsBashforthMoulton/src/adams_bashforth_moulton_caches.jl +++ b/lib/OrdinaryDiffEqAdamsBashforthMoulton/src/adams_bashforth_moulton_caches.jl @@ -4,7 +4,7 @@ get_fsalfirstlast(cache::ABMMutableCache, u) = (cache.fsalfirst, cache.k) function get_fsalfirstlast(cache::ABMVariableCoefficientMutableCache, u) (cache.fsalfirst, cache.k4) end -@cache mutable struct AB3Cache{uType, rateType} <: ABMMutableCache +@cache mutable struct AB3Cache{uType, rateType, Thread} <: ABMMutableCache u::uType uprev::uType fsalfirst::rateType @@ -14,6 +14,7 @@ end k::rateType tmp::uType step::Int + thread::Thread end @cache mutable struct AB3ConstantCache{rateType} <: OrdinaryDiffEqConstantCache @@ -32,7 +33,7 @@ function alg_cache(alg::AB3, u, rate_prototype, ::Type{uEltypeNoUnits}, ralk2 = zero(rate_prototype) k = zero(rate_prototype) tmp = zero(u) - AB3Cache(u, uprev, fsalfirst, k2, k3, ralk2, k, tmp, 1) + AB3Cache(u, uprev, fsalfirst, k2, k3, ralk2, k, tmp, 1, alg.thread) end function alg_cache(alg::AB3, u, rate_prototype, ::Type{uEltypeNoUnits}, @@ -44,7 +45,7 @@ function alg_cache(alg::AB3, u, rate_prototype, ::Type{uEltypeNoUnits}, AB3ConstantCache(k2, k3, 1) end -@cache mutable struct ABM32Cache{uType, rateType} <: ABMMutableCache +@cache mutable struct ABM32Cache{uType, rateType, Thread} <: ABMMutableCache u::uType uprev::uType fsalfirst::rateType @@ -54,6 +55,7 @@ end k::rateType tmp::uType step::Int + thread::Thread end @cache mutable struct ABM32ConstantCache{rateType} <: OrdinaryDiffEqConstantCache @@ -72,7 +74,7 @@ function alg_cache(alg::ABM32, u, rate_prototype, ::Type{uEltypeNoUnits}, ralk2 = zero(rate_prototype) k = zero(rate_prototype) tmp = zero(u) - ABM32Cache(u, uprev, fsalfirst, k2, k3, ralk2, k, tmp, 1) + ABM32Cache(u, uprev, fsalfirst, k2, k3, ralk2, k, tmp, 1, alg.thread) end function alg_cache(alg::ABM32, u, rate_prototype, ::Type{uEltypeNoUnits}, @@ -84,7 +86,7 @@ function alg_cache(alg::ABM32, u, rate_prototype, ::Type{uEltypeNoUnits}, ABM32ConstantCache(k2, k3, 1) end -@cache mutable struct AB4Cache{uType, rateType} <: ABMMutableCache +@cache mutable struct AB4Cache{uType, rateType, Thread} <: ABMMutableCache u::uType uprev::uType fsalfirst::rateType @@ -98,6 +100,7 @@ end t3::rateType t4::rateType step::Int + thread::Thread end @cache mutable struct AB4ConstantCache{rateType} <: OrdinaryDiffEqConstantCache @@ -121,7 +124,7 @@ function alg_cache(alg::AB4, u, rate_prototype, ::Type{uEltypeNoUnits}, t2 = zero(rate_prototype) t3 = zero(rate_prototype) t4 = zero(rate_prototype) - AB4Cache(u, uprev, fsalfirst, k2, k3, k4, ralk2, k, tmp, t2, t3, t4, 1) + AB4Cache(u, uprev, fsalfirst, k2, k3, k4, ralk2, k, tmp, t2, t3, t4, 1, alg.thread) end function alg_cache(alg::AB4, u, rate_prototype, ::Type{uEltypeNoUnits}, @@ -134,7 +137,7 @@ function alg_cache(alg::AB4, u, rate_prototype, ::Type{uEltypeNoUnits}, AB4ConstantCache(k2, k3, k4, 1) end -@cache mutable struct ABM43Cache{uType, rateType} <: ABMMutableCache +@cache mutable struct ABM43Cache{uType, rateType, Thread} <: ABMMutableCache u::uType uprev::uType fsalfirst::rateType @@ -151,6 +154,7 @@ end t6::rateType t7::rateType step::Int + thread::Thread end @cache mutable struct ABM43ConstantCache{rateType} <: OrdinaryDiffEqConstantCache @@ -177,7 +181,8 @@ function alg_cache(alg::ABM43, u, rate_prototype, ::Type{uEltypeNoUnits}, t5 = zero(rate_prototype) t6 = zero(rate_prototype) t7 = zero(rate_prototype) - ABM43Cache(u, uprev, fsalfirst, k2, k3, k4, ralk2, k, tmp, t2, t3, t4, t5, t6, t7, 1) + ABM43Cache(u, uprev, fsalfirst, k2, k3, k4, ralk2, k, + tmp, t2, t3, t4, t5, t6, t7, 1, alg.thread) end function alg_cache(alg::ABM43, u, rate_prototype, ::Type{uEltypeNoUnits}, @@ -190,7 +195,7 @@ function alg_cache(alg::ABM43, u, rate_prototype, ::Type{uEltypeNoUnits}, ABM43ConstantCache(k2, k3, k4, 1) end -@cache mutable struct AB5Cache{uType, rateType} <: ABMMutableCache +@cache mutable struct AB5Cache{uType, rateType, Thread} <: ABMMutableCache u::uType uprev::uType fsalfirst::rateType @@ -204,6 +209,7 @@ end t3::rateType t4::rateType step::Int + thread::Thread end @cache mutable struct AB5ConstantCache{rateType} <: OrdinaryDiffEqConstantCache @@ -228,7 +234,7 @@ function alg_cache(alg::AB5, u, rate_prototype, ::Type{uEltypeNoUnits}, t2 = zero(rate_prototype) t3 = zero(rate_prototype) t4 = zero(rate_prototype) - AB5Cache(u, uprev, fsalfirst, k2, k3, k4, k5, k, tmp, t2, t3, t4, 1) + AB5Cache(u, uprev, fsalfirst, k2, k3, k4, k5, k, tmp, t2, t3, t4, 1, alg.thread) end function alg_cache(alg::AB5, u, rate_prototype, ::Type{uEltypeNoUnits}, @@ -242,7 +248,7 @@ function alg_cache(alg::AB5, u, rate_prototype, ::Type{uEltypeNoUnits}, AB5ConstantCache(k2, k3, k4, k5, 1) end -@cache mutable struct ABM54Cache{uType, rateType} <: ABMMutableCache +@cache mutable struct ABM54Cache{uType, rateType, Thread} <: ABMMutableCache u::uType uprev::uType fsalfirst::rateType @@ -260,6 +266,7 @@ end t7::rateType t8::rateType step::Int + thread::Thread end @cache mutable struct ABM54ConstantCache{rateType} <: OrdinaryDiffEqConstantCache @@ -288,7 +295,8 @@ function alg_cache(alg::ABM54, u, rate_prototype, ::Type{uEltypeNoUnits}, t6 = zero(rate_prototype) t7 = zero(rate_prototype) t8 = zero(rate_prototype) - ABM54Cache(u, uprev, fsalfirst, k2, k3, k4, k5, k, tmp, t2, t3, t4, t5, t6, t7, t8, 1) + ABM54Cache(u, uprev, fsalfirst, k2, k3, k4, k5, k, tmp, + t2, t3, t4, t5, t6, t7, t8, 1, alg.thread) end function alg_cache(alg::ABM54, u, rate_prototype, ::Type{uEltypeNoUnits}, @@ -317,7 +325,7 @@ end end @cache mutable struct VCAB3Cache{uType, rateType, TabType, bs3Type, tArrayType, cArrayType, - uNoUnitsType, coefType, dtArrayType} <: + uNoUnitsType, coefType, dtArrayType, Thread} <: ABMVariableCoefficientMutableCache u::uType uprev::uType @@ -337,6 +345,7 @@ end utilde::uType tab::TabType step::Int + thread::Thread end function alg_cache(alg::VCAB3, u, rate_prototype, ::Type{uEltypeNoUnits}, @@ -395,7 +404,7 @@ function alg_cache(alg::VCAB3, u, rate_prototype, ::Type{uEltypeNoUnits}, tmp = zero(u) utilde = zero(u) VCAB3Cache(u, uprev, fsalfirst, bs3cache, k4, ϕstar_nm1, dts, c, g, ϕ_n, ϕstar_n, β, - order, atmp, tmp, utilde, tab, 1) + order, atmp, tmp, utilde, tab, 1, alg.thread) end @cache mutable struct VCAB4ConstantCache{rk4constcache, tArrayType, rArrayType, cArrayType, @@ -413,7 +422,7 @@ end end @cache mutable struct VCAB4Cache{uType, rateType, rk4cacheType, tArrayType, cArrayType, - uNoUnitsType, coefType, dtArrayType} <: + uNoUnitsType, coefType, dtArrayType, Thread} <: ABMVariableCoefficientMutableCache u::uType uprev::uType @@ -432,6 +441,7 @@ end tmp::uType utilde::uType step::Int + thread::Thread end function alg_cache(alg::VCAB4, u, rate_prototype, ::Type{uEltypeNoUnits}, @@ -489,7 +499,7 @@ function alg_cache(alg::VCAB4, u, rate_prototype, ::Type{uEltypeNoUnits}, tmp = zero(u) utilde = zero(u) VCAB4Cache(u, uprev, fsalfirst, rk4cache, k4, ϕstar_nm1, dts, c, g, ϕ_n, ϕstar_n, β, - order, atmp, tmp, utilde, 1) + order, atmp, tmp, utilde, 1, alg.thread) end # VCAB5 @@ -509,7 +519,7 @@ end end @cache mutable struct VCAB5Cache{uType, rateType, rk4cacheType, tArrayType, cArrayType, - uNoUnitsType, coefType, dtArrayType} <: + uNoUnitsType, coefType, dtArrayType, Thread} <: ABMVariableCoefficientMutableCache u::uType uprev::uType @@ -528,6 +538,7 @@ end tmp::uType utilde::uType step::Int + thread::Thread end function alg_cache(alg::VCAB5, u, rate_prototype, ::Type{uEltypeNoUnits}, @@ -585,7 +596,7 @@ function alg_cache(alg::VCAB5, u, rate_prototype, ::Type{uEltypeNoUnits}, tmp = zero(u) utilde = zero(u) VCAB5Cache(u, uprev, fsalfirst, rk4cache, k4, ϕstar_nm1, dts, c, g, ϕ_n, ϕstar_n, β, - order, atmp, tmp, utilde, 1) + order, atmp, tmp, utilde, 1, alg.thread) end # VCABM3 @@ -607,7 +618,7 @@ end @cache mutable struct VCABM3Cache{ uType, rateType, TabType, bs3Type, tArrayType, cArrayType, - uNoUnitsType, coefType, dtArrayType} <: + uNoUnitsType, coefType, dtArrayType, Thread} <: ABMVariableCoefficientMutableCache u::uType uprev::uType @@ -628,6 +639,7 @@ end utilde::uType tab::TabType step::Int + thread::Thread end function alg_cache(alg::VCABM3, u, rate_prototype, ::Type{uEltypeNoUnits}, @@ -691,7 +703,7 @@ function alg_cache(alg::VCABM3, u, rate_prototype, ::Type{uEltypeNoUnits}, tmp = zero(u) utilde = zero(u) VCABM3Cache(u, uprev, fsalfirst, bs3cache, k4, ϕstar_nm1, dts, c, g, ϕ_n, ϕ_np1, - ϕstar_n, β, order, atmp, tmp, utilde, tab, 1) + ϕstar_n, β, order, atmp, tmp, utilde, tab, 1, alg.thread) end # VCABM4 @@ -713,7 +725,7 @@ end end @cache mutable struct VCABM4Cache{uType, rateType, rk4cacheType, tArrayType, cArrayType, - uNoUnitsType, coefType, dtArrayType} <: + uNoUnitsType, coefType, dtArrayType, Thread} <: ABMVariableCoefficientMutableCache u::uType uprev::uType @@ -733,6 +745,7 @@ end tmp::uType utilde::uType step::Int + thread::Thread end function alg_cache(alg::VCABM4, u, rate_prototype, ::Type{uEltypeNoUnits}, @@ -796,7 +809,7 @@ function alg_cache(alg::VCABM4, u, rate_prototype, ::Type{uEltypeNoUnits}, tmp = zero(u) utilde = zero(u) VCABM4Cache(u, uprev, fsalfirst, rk4cache, k4, ϕstar_nm1, dts, c, g, ϕ_n, ϕ_np1, - ϕstar_n, β, order, atmp, tmp, utilde, 1) + ϕstar_n, β, order, atmp, tmp, utilde, 1, alg.thread) end # VCABM5 @@ -818,7 +831,7 @@ end end @cache mutable struct VCABM5Cache{uType, rateType, rk4cacheType, tArrayType, cArrayType, - uNoUnitsType, coefType, dtArrayType} <: + uNoUnitsType, coefType, dtArrayType, Thread} <: ABMVariableCoefficientMutableCache u::uType uprev::uType @@ -838,6 +851,7 @@ end tmp::uType utilde::uType step::Int + thread::Thread end function alg_cache(alg::VCABM5, u, rate_prototype, ::Type{uEltypeNoUnits}, @@ -901,7 +915,7 @@ function alg_cache(alg::VCABM5, u, rate_prototype, ::Type{uEltypeNoUnits}, tmp = zero(u) utilde = zero(u) VCABM5Cache(u, uprev, fsalfirst, rk4cache, k4, ϕstar_nm1, dts, c, g, ϕ_n, ϕ_np1, - ϕstar_n, β, order, atmp, tmp, utilde, 1) + ϕstar_n, β, order, atmp, tmp, utilde, 1, alg.thread) end # VCABM @@ -924,7 +938,7 @@ end end @cache mutable struct VCABMCache{uType, rateType, dtType, tArrayType, cArrayType, - uNoUnitsType, coefType, dtArrayType} <: + uNoUnitsType, coefType, dtArrayType, Thread} <: ABMVariableCoefficientMutableCache u::uType uprev::uType @@ -952,6 +966,7 @@ end atmpm2::uNoUnitsType atmpp1::uNoUnitsType step::Int + thread::Thread end function alg_cache(alg::VCABM, u, rate_prototype, ::Type{uEltypeNoUnits}, @@ -1023,5 +1038,5 @@ function alg_cache(alg::VCABM, u, rate_prototype, ::Type{uEltypeNoUnits}, VCABMCache( u, uprev, fsalfirst, k4, ϕstar_nm1, dts, c, g, ϕ_n, ϕ_np1, ϕstar_n, β, order, max_order, atmp, tmp, ξ, ξ0, utilde, utildem1, utildem2, utildep1, atmpm1, - atmpm2, atmpp1, 1) + atmpm2, atmpp1, 1, alg.thread) end diff --git a/lib/OrdinaryDiffEqAdamsBashforthMoulton/src/adams_bashforth_moulton_perform_step.jl b/lib/OrdinaryDiffEqAdamsBashforthMoulton/src/adams_bashforth_moulton_perform_step.jl index 077fdfb4ec..e22e68c517 100644 --- a/lib/OrdinaryDiffEqAdamsBashforthMoulton/src/adams_bashforth_moulton_perform_step.jl +++ b/lib/OrdinaryDiffEqAdamsBashforthMoulton/src/adams_bashforth_moulton_perform_step.jl @@ -68,7 +68,7 @@ end @muladd function perform_step!(integrator, cache::AB3Cache, repeat_step = false) @unpack t, dt, uprev, u, f, p = integrator - @unpack tmp, fsalfirst, k2, k3, ralk2, k = cache + @unpack tmp, fsalfirst, k2, k3, ralk2, k, thread = cache k1 = integrator.fsalfirst if integrator.u_modified cache.step = 1 @@ -77,17 +77,17 @@ end if cache.step <= 2 cache.step += 1 ttmp = t + (2 / 3) * dt - @.. broadcast=false tmp=uprev + (2 / 3) * dt * k1 + @.. broadcast=false thread=thread tmp=uprev + (2 / 3) * dt * k1 f(ralk2, tmp, p, ttmp) OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) - @.. broadcast=false u=uprev + (dt / 4) * (k1 + 3 * ralk2) #Ralston Method + @.. broadcast=false thread=thread u=uprev + (dt / 4) * (k1 + 3 * ralk2) #Ralston Method if cnt == 1 cache.k3 .= k1 else cache.k2 .= k1 end else - @.. broadcast=false u=uprev + (dt / 12) * (23 * k1 - 16 * k2 + 5 * k3) + @.. broadcast=false thread=thread u=uprev + (dt / 12) * (23 * k1 - 16 * k2 + 5 * k3) cache.k2, cache.k3 = k3, k2 cache.k2 .= k1 end @@ -128,7 +128,7 @@ end @muladd function perform_step!(integrator, cache::ABM32Cache, repeat_step = false) @unpack t, dt, uprev, u, f, p = integrator - @unpack tmp, fsalfirst, k2, k3, ralk2, k = cache + @unpack tmp, fsalfirst, k2, k3, ralk2, k, thread = cache k1 = integrator.fsalfirst if integrator.u_modified cache.step = 1 @@ -137,21 +137,21 @@ end if cache.step == 1 cache.step += 1 ttmp = t + (2 / 3) * dt - @.. broadcast=false tmp=uprev + (2 / 3) * dt * k1 + @.. broadcast=false thread=thread tmp=uprev + (2 / 3) * dt * k1 f(ralk2, tmp, p, ttmp) OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) - @.. broadcast=false u=uprev + (dt / 4) * (k1 + 3 * ralk2) #Ralston Method + @.. broadcast=false thread=thread u=uprev + (dt / 4) * (k1 + 3 * ralk2) #Ralston Method cache.k2 .= k1 else if cnt == 2 perform_step!(integrator, - AB3Cache(u, uprev, fsalfirst, copy(k2), k3, ralk2, k, tmp, cnt)) #Here passing copy of k2, otherwise it will change in AB3() + AB3Cache(u, uprev, fsalfirst, copy(k2), k3, ralk2, k, tmp, cnt, thread)) #Here passing copy of k2, otherwise it will change in AB3() else perform_step!(integrator, - AB3Cache(u, uprev, fsalfirst, k2, k3, ralk2, k, tmp, cnt)) + AB3Cache(u, uprev, fsalfirst, k2, k3, ralk2, k, tmp, cnt, thread)) end k = integrator.fsallast - @.. broadcast=false u=uprev + (dt / 12) * (5 * k + 8 * k1 - k2) + @.. broadcast=false thread=thread u=uprev + (dt / 12) * (5 * k + 8 * k1 - k2) cache.k2, cache.k3 = k3, k2 cache.k2 .= k1 end @@ -198,7 +198,7 @@ end @muladd function perform_step!(integrator, cache::AB4Cache, repeat_step = false) @unpack t, dt, uprev, u, f, p = integrator - @unpack tmp, fsalfirst, k2, k3, k4, ralk2, k, t2, t3, t4 = cache + @unpack tmp, fsalfirst, k2, k3, k4, ralk2, k, t2, t3, t4, thread = cache k1 = integrator.fsalfirst if integrator.u_modified cache.step = 1 @@ -208,14 +208,14 @@ end cache.step += 1 halfdt = dt / 2 ttmp = t + halfdt - @.. broadcast=false tmp=uprev + halfdt * k1 + @.. broadcast=false thread=thread tmp=uprev + halfdt * k1 f(t2, tmp, p, ttmp) - @.. broadcast=false tmp=uprev + halfdt * t2 + @.. broadcast=false thread=thread tmp=uprev + halfdt * t2 f(t3, tmp, p, ttmp) - @.. broadcast=false tmp=uprev + dt * t3 + @.. broadcast=false thread=thread tmp=uprev + dt * t3 f(t4, tmp, p, t + dt) OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) - @.. broadcast=false u=uprev + (dt / 6) * (2 * (t2 + t3) + (k1 + t4)) #RK4 + @.. broadcast=false thread=thread u=uprev + (dt / 6) * (2 * (t2 + t3) + (k1 + t4)) #RK4 if cnt == 1 cache.k4 .= k1 elseif cnt == 2 @@ -224,7 +224,9 @@ end cache.k2 .= k1 end else - @.. broadcast=false u=uprev + (dt / 24) * (55 * k1 - 59 * k2 + 37 * k3 - 9 * k4) + @.. broadcast=false thread=thread u=uprev + + (dt / 24) * + (55 * k1 - 59 * k2 + 37 * k3 - 9 * k4) cache.k4, cache.k3 = k3, k4 cache.k3 .= k2 cache.k2 .= k1 @@ -272,7 +274,7 @@ end @muladd function perform_step!(integrator, cache::ABM43Cache, repeat_step = false) @unpack t, dt, uprev, u, f, p = integrator - @unpack tmp, fsalfirst, k2, k3, k4, ralk2, k, t2, t3, t4, t5, t6, t7 = cache + @unpack tmp, fsalfirst, k2, k3, k4, ralk2, k, t2, t3, t4, t5, t6, t7, thread = cache k1 = integrator.fsalfirst if integrator.u_modified cache.step = 1 @@ -282,14 +284,14 @@ end cache.step += 1 halfdt = dt / 2 ttmp = t + halfdt - @.. broadcast=false tmp=uprev + halfdt * k1 + @.. broadcast=false thread=thread tmp=uprev + halfdt * k1 f(t2, tmp, p, ttmp) - @.. broadcast=false tmp=uprev + halfdt * t2 + @.. broadcast=false thread=thread tmp=uprev + halfdt * t2 f(t3, tmp, p, ttmp) - @.. broadcast=false tmp=uprev + dt * t3 + @.. broadcast=false thread=thread tmp=uprev + dt * t3 f(t4, tmp, p, t + dt) OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) - @.. broadcast=false u=uprev + (dt / 6) * (2 * (t2 + t3) + (k1 + t4)) #RK4 + @.. broadcast=false thread=thread u=uprev + (dt / 6) * (2 * (t2 + t3) + (k1 + t4)) #RK4 if cnt == 1 cache.k3 .= k1 else @@ -301,9 +303,10 @@ end t4 .= k4 perform_step!(integrator, AB4Cache(u, uprev, fsalfirst, t2, t3, t4, ralk2, k, tmp, t5, t6, t7, - cnt)) + cnt, thread)) k = integrator.fsallast - @.. broadcast=false u=uprev + (dt / 24) * (9 * k + 19 * k1 - 5 * k2 + k3) + @.. broadcast=false thread=thread u=uprev + + (dt / 24) * (9 * k + 19 * k1 - 5 * k2 + k3) cache.k4, cache.k3 = k3, k4 cache.k3 .= k2 cache.k2 .= k1 @@ -354,7 +357,7 @@ end @muladd function perform_step!(integrator, cache::AB5Cache, repeat_step = false) @unpack t, dt, uprev, u, f, p = integrator - @unpack tmp, fsalfirst, k2, k3, k4, k5, k, t2, t3, t4 = cache + @unpack tmp, fsalfirst, k2, k3, k4, k5, k, t2, t3, t4, thread = cache k1 = integrator.fsalfirst if integrator.u_modified cache.step = 1 @@ -364,14 +367,14 @@ end cache.step += 1 halfdt = dt / 2 ttmp = t + halfdt - @.. broadcast=false tmp=uprev + halfdt * k1 + @.. broadcast=false thread=thread tmp=uprev + halfdt * k1 f(t2, tmp, p, ttmp) - @.. broadcast=false tmp=uprev + halfdt * t2 + @.. broadcast=false thread=thread tmp=uprev + halfdt * t2 f(t3, tmp, p, ttmp) - @.. broadcast=false tmp=uprev + dt * t3 + @.. broadcast=false thread=thread tmp=uprev + dt * t3 f(t4, tmp, p, t + dt) OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) - @.. broadcast=false u=uprev + (dt / 6) * (2 * (t2 + t3) + (k1 + t4)) #RK4 + @.. broadcast=false thread=thread u=uprev + (dt / 6) * (2 * (t2 + t3) + (k1 + t4)) #RK4 if cnt == 1 cache.k5 .= k1 elseif cnt == 2 @@ -382,9 +385,10 @@ end cache.k2 .= k1 end else - @.. broadcast=false u=uprev + - (dt / 720) * - (1901 * k1 - 2774 * k2 + 2616 * k3 - 1274 * k4 + 251 * k5) + @.. broadcast=false thread=thread u=uprev + + (dt / 720) * + (1901 * k1 - 2774 * k2 + 2616 * k3 - 1274 * k4 + + 251 * k5) cache.k5, cache.k4 = k4, k5 cache.k4 .= k3 cache.k3 .= k2 @@ -436,7 +440,7 @@ end @muladd function perform_step!(integrator, cache::ABM54Cache, repeat_step = false) @unpack t, dt, uprev, u, f, p = integrator - @unpack tmp, fsalfirst, k2, k3, k4, k5, k, t2, t3, t4, t5, t6, t7, t8 = cache + @unpack tmp, fsalfirst, k2, k3, k4, k5, k, t2, t3, t4, t5, t6, t7, t8, thread = cache k1 = integrator.fsalfirst if integrator.u_modified cache.step = 1 @@ -446,13 +450,13 @@ end cache.step += 1 halfdt = dt / 2 ttmp = t + halfdt - @.. broadcast=false tmp=uprev + halfdt * k1 + @.. broadcast=false thread=thread tmp=uprev + halfdt * k1 f(t2, tmp, p, ttmp) - @.. broadcast=false tmp=uprev + halfdt * t2 + @.. broadcast=false thread=thread tmp=uprev + halfdt * t2 f(t3, tmp, p, ttmp) - @.. broadcast=false tmp=uprev + dt * t3 + @.. broadcast=false thread=thread tmp=uprev + dt * t3 f(t4, tmp, p, t + dt) - @.. broadcast=false u=uprev + (dt / 6) * (2 * (t2 + t3) + (k1 + t4)) #RK4 + @.. broadcast=false thread=thread u=uprev + (dt / 6) * (2 * (t2 + t3) + (k1 + t4)) #RK4 OrdinaryDiffEqCore.increment_nf!(integrator.stats, 3) if cnt == 1 cache.k4 .= k1 @@ -468,11 +472,12 @@ end t5 .= k5 perform_step!(integrator, AB5Cache(u, uprev, fsalfirst, t2, t3, t4, t5, k, tmp, t6, t7, t8, - cnt)) + cnt, thread)) k = integrator.fsallast - @.. broadcast=false u=uprev + - (dt / 720) * - (251 * k + 646 * k1 - 264 * k2 + 106 * k3 - 19 * k4) + @.. broadcast=false thread=thread u=uprev + + (dt / 720) * + (251 * k + 646 * k1 - 264 * k2 + 106 * k3 - + 19 * k4) cache.k5, cache.k4 = k4, k5 cache.k4 .= k3 cache.k3 .= k2 @@ -561,7 +566,7 @@ end @muladd function perform_step!(integrator, cache::VCAB3Cache, repeat_step = false) @unpack t, dt, uprev, u, f, p = integrator - @unpack k4, dts, g, ϕstar_n, ϕstar_nm1, order, atmp, utilde, bs3cache = cache + @unpack k4, dts, g, ϕstar_n, ϕstar_nm1, order, atmp, utilde, bs3cache, thread = cache k1 = integrator.fsalfirst if integrator.u_modified cache.step = 1 @@ -587,12 +592,12 @@ end integrator.fsallast .= k4 else g_coefs!(cache, k) - @.. broadcast=false u=uprev + @.. broadcast=false thread=thread u=uprev for i in 1:k - @.. broadcast=false u+=g[i] * ϕstar_n[i] + @.. broadcast=false thread=thread u+=g[i] * ϕstar_n[i] end if integrator.opts.adaptive - @.. broadcast=false utilde=g[k] * ϕstar_n[k] # Using lower order AB from subset of coefficients + @.. broadcast=false thread=thread utilde=g[k] * ϕstar_n[k] # Using lower order AB from subset of coefficients calculate_residuals!(atmp, utilde, uprev, u, integrator.opts.abstol, integrator.opts.reltol, integrator.opts.internalnorm, t) integrator.EEst = integrator.opts.internalnorm(atmp, t) @@ -694,7 +699,7 @@ end @muladd function perform_step!(integrator, cache::VCAB4Cache, repeat_step = false) @unpack t, dt, uprev, u, f, p = integrator - @unpack k4, dts, g, ϕ_n, ϕstar_n, ϕstar_nm1, order, atmp, utilde, rk4cache = cache + @unpack k4, dts, g, ϕ_n, ϕstar_n, ϕstar_nm1, order, atmp, utilde, rk4cache, thread = cache k1 = integrator.fsalfirst if integrator.u_modified cache.step = 1 @@ -726,12 +731,12 @@ end integrator.fsallast .= rk4cache.k else g_coefs!(cache, k) - @.. broadcast=false u=uprev + @.. broadcast=false thread=thread u=uprev for i in 1:k - @.. broadcast=false u+=g[i] * ϕstar_n[i] + @.. broadcast=false thread=thread u+=g[i] * ϕstar_n[i] end if integrator.opts.adaptive - @.. broadcast=false utilde=g[k] * ϕstar_n[k] + @.. broadcast=false thread=thread utilde=g[k] * ϕstar_n[k] calculate_residuals!(atmp, utilde, uprev, u, integrator.opts.abstol, integrator.opts.reltol, integrator.opts.internalnorm, t) integrator.EEst = integrator.opts.internalnorm(atmp, t) @@ -842,7 +847,7 @@ end @muladd function perform_step!(integrator, cache::VCAB5Cache, repeat_step = false) @unpack t, dt, uprev, u, f, p = integrator - @unpack k4, dts, g, ϕ_n, ϕstar_n, ϕstar_nm1, order, atmp, utilde, rk4cache = cache + @unpack k4, dts, g, ϕ_n, ϕstar_n, ϕstar_nm1, order, atmp, utilde, rk4cache, thread = cache k1 = integrator.fsalfirst if integrator.u_modified cache.step = 1 @@ -881,12 +886,12 @@ end integrator.fsallast .= rk4cache.k else g_coefs!(cache, k) - @.. broadcast=false u=uprev + @.. broadcast=false thread=thread u=uprev for i in 1:k - @.. broadcast=false u+=g[i] * ϕstar_n[i] + @.. broadcast=false thread=thread u+=g[i] * ϕstar_n[i] end if integrator.opts.adaptive - @.. broadcast=false utilde=g[k] * ϕstar_n[k] + @.. broadcast=false thread=thread utilde=g[k] * ϕstar_n[k] calculate_residuals!(atmp, utilde, uprev, u, integrator.opts.abstol, integrator.opts.reltol, integrator.opts.internalnorm, t) integrator.EEst = integrator.opts.internalnorm(atmp, t) @@ -988,7 +993,7 @@ end @muladd function perform_step!(integrator, cache::VCABM3Cache, repeat_step = false) @unpack t, dt, uprev, u, f, p = integrator - @unpack k4, dts, g, ϕstar_n, ϕ_np1, ϕstar_nm1, order, atmp, utilde, bs3cache = cache + @unpack k4, dts, g, ϕstar_n, ϕ_np1, ϕstar_nm1, order, atmp, utilde, bs3cache, thread = cache k1 = integrator.fsalfirst if integrator.u_modified cache.step = 1 @@ -1014,16 +1019,16 @@ end integrator.fsallast .= k4 else g_coefs!(cache, k + 1) - @.. broadcast=false u=uprev + @.. broadcast=false thread=thread u=uprev for i in 1:(k - 1) - @.. broadcast=false u+=g[i] * ϕstar_n[i] + @.. broadcast=false thread=thread u+=g[i] * ϕstar_n[i] end f(k4, u, p, t + dt) OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) ϕ_np1!(cache, k4, k + 1) - @.. broadcast=false u+=g[end - 1] * ϕ_np1[end - 1] + @.. broadcast=false thread=thread u+=g[end - 1] * ϕ_np1[end - 1] if integrator.opts.adaptive - @.. broadcast=false utilde=(g[end] - g[end - 1]) * ϕ_np1[end] + @.. broadcast=false thread=thread utilde=(g[end] - g[end - 1]) * ϕ_np1[end] calculate_residuals!(atmp, utilde, uprev, u, integrator.opts.abstol, integrator.opts.reltol, integrator.opts.internalnorm, t) integrator.EEst = integrator.opts.internalnorm(atmp, t) @@ -1131,7 +1136,7 @@ end @muladd function perform_step!(integrator, cache::VCABM4Cache, repeat_step = false) @unpack t, dt, uprev, u, f, p = integrator - @unpack k4, dts, g, ϕstar_n, ϕ_np1, ϕstar_nm1, order, atmp, utilde, rk4cache = cache + @unpack k4, dts, g, ϕstar_n, ϕ_np1, ϕstar_nm1, order, atmp, utilde, rk4cache, thread = cache k1 = integrator.fsalfirst if integrator.u_modified cache.step = 1 @@ -1163,16 +1168,16 @@ end integrator.fsallast .= rk4cache.k else g_coefs!(cache, k + 1) - @.. broadcast=false u=uprev + @.. broadcast=false thread=thread u=uprev for i in 1:(k - 1) - @.. broadcast=false u+=g[i] * ϕstar_n[i] + @.. broadcast=false thread=thread u+=g[i] * ϕstar_n[i] end f(k4, u, p, t + dt) OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) ϕ_np1!(cache, k4, k + 1) - @.. broadcast=false u+=g[end - 1] * ϕ_np1[end - 1] + @.. broadcast=false thread=thread u+=g[end - 1] * ϕ_np1[end - 1] if integrator.opts.adaptive - @.. broadcast=false utilde=(g[end] - g[end - 1]) * ϕ_np1[end] + @.. broadcast=false thread=thread utilde=(g[end] - g[end - 1]) * ϕ_np1[end] calculate_residuals!(atmp, utilde, uprev, u, integrator.opts.abstol, integrator.opts.reltol, integrator.opts.internalnorm, t) integrator.EEst = integrator.opts.internalnorm(atmp, t) @@ -1288,7 +1293,7 @@ end @muladd function perform_step!(integrator, cache::VCABM5Cache, repeat_step = false) @inbounds begin @unpack t, dt, uprev, u, f, p = integrator - @unpack k4, dts, g, ϕ_n, ϕ_np1, ϕstar_n, ϕstar_nm1, order, atmp, utilde, rk4cache = cache + @unpack k4, dts, g, ϕ_n, ϕ_np1, ϕstar_n, ϕstar_nm1, order, atmp, utilde, rk4cache, thread = cache k1 = integrator.fsalfirst if integrator.u_modified cache.step = 1 @@ -1327,16 +1332,16 @@ end integrator.fsallast .= rk4cache.k else g_coefs!(cache, 6) - @.. broadcast=false u=muladd(g[1], ϕstar_n[1], uprev) - @.. broadcast=false u=muladd(g[2], ϕstar_n[2], u) - @.. broadcast=false u=muladd(g[3], ϕstar_n[3], u) - @.. broadcast=false u=muladd(g[4], ϕstar_n[4], u) + @.. broadcast=false thread=thread u=muladd(g[1], ϕstar_n[1], uprev) + @.. broadcast=false thread=thread u=muladd(g[2], ϕstar_n[2], u) + @.. broadcast=false thread=thread u=muladd(g[3], ϕstar_n[3], u) + @.. broadcast=false thread=thread u=muladd(g[4], ϕstar_n[4], u) f(k4, u, p, t + dt) OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) ϕ_np1!(cache, k4, 6) - @.. broadcast=false u=muladd(g[6 - 1], ϕ_np1[6 - 1], u) + @.. broadcast=false thread=thread u=muladd(g[6 - 1], ϕ_np1[6 - 1], u) if integrator.opts.adaptive - @.. broadcast=false utilde=(g[6] - g[6 - 1]) * ϕ_np1[end] + @.. broadcast=false thread=thread utilde=(g[6] - g[6 - 1]) * ϕ_np1[end] calculate_residuals!(atmp, utilde, uprev, u, integrator.opts.abstol, integrator.opts.reltol, integrator.opts.internalnorm, t) @@ -1464,7 +1469,7 @@ end @muladd function perform_step!(integrator, cache::VCABMCache, repeat_step = false) @inbounds begin @unpack t, dt, uprev, u, f, p = integrator - @unpack k4, dts, g, ϕ_n, ϕ_np1, ϕstar_n, ϕstar_nm1, order, max_order, utilde, utildem2, utildem1, utildep1, atmp, atmpm1, atmpm2, atmpp1 = cache + @unpack k4, dts, g, ϕ_n, ϕ_np1, ϕstar_n, ϕstar_nm1, order, max_order, utilde, utildem2, utildem1, utildep1, atmp, atmpm1, atmpm2, atmpp1, thread = cache k1 = integrator.fsalfirst step = integrator.iter k = order @@ -1476,16 +1481,16 @@ end ϕ_and_ϕstar!(cache, k1, k) g_coefs!(cache, k + 1) # unroll the predictor once - @.. broadcast=false u=muladd(g[1], ϕstar_n[1], uprev) + @.. broadcast=false thread=thread u=muladd(g[1], ϕstar_n[1], uprev) for i in 2:(k - 1) - @.. broadcast=false u=muladd(g[i], ϕstar_n[i], u) + @.. broadcast=false thread=thread u=muladd(g[i], ϕstar_n[i], u) end f(k4, u, p, t + dt) OrdinaryDiffEqCore.increment_nf!(integrator.stats, 1) ϕ_np1!(cache, k4, k + 1) - @.. broadcast=false u=muladd(g[k], ϕ_np1[k], u) + @.. broadcast=false thread=thread u=muladd(g[k], ϕ_np1[k], u) if integrator.opts.adaptive - @.. broadcast=false utilde=(g[k + 1] - g[k]) * ϕ_np1[k + 1] + @.. broadcast=false thread=thread utilde=(g[k + 1] - g[k]) * ϕ_np1[k + 1] calculate_residuals!(atmp, utilde, uprev, u, integrator.opts.abstol, integrator.opts.reltol, integrator.opts.internalnorm, t) integrator.EEst = integrator.opts.internalnorm(atmp, t) @@ -1501,13 +1506,15 @@ end if step <= 4 || order < 3 cache.order = min(order + 1, 3) else - # @.. broadcast=false utildem2 = dt * γstar[(k-2)+1] * ϕ_np1[k-1] - @.. broadcast=false utildem2=(g[k - 1] - g[k - 2]) * ϕ_np1[k - 1] - # @.. broadcast=false utildem1 = dt * γstar[(k-1)+1] * ϕ_np1[k] - @.. broadcast=false utildem1=(g[k] - g[k - 1]) * ϕ_np1[k] + # @.. broadcast=false thread=thread utildem2 = dt * γstar[(k-2)+1] * ϕ_np1[k-1] + @.. broadcast=false thread=thread utildem2=(g[k - 1] - g[k - 2]) * + ϕ_np1[k - 1] + # @.. broadcast=false thread=thread utildem1 = dt * γstar[(k-1)+1] * ϕ_np1[k] + @.. broadcast=false thread=thread utildem1=(g[k] - g[k - 1]) * ϕ_np1[k] expand_ϕ_and_ϕstar!(cache, k + 1) ϕ_np1!(cache, k4, k + 2) - @.. broadcast=false utildep1=dt * γstar[(k + 1) + 1] * ϕ_np1[k + 2] + @.. broadcast=false thread=thread utildep1=dt * γstar[(k + 1) + 1] * + ϕ_np1[k + 2] calculate_residuals!(atmpm2, utildem2, uprev, u, integrator.opts.abstol, integrator.opts.reltol, integrator.opts.internalnorm, t) diff --git a/lib/OrdinaryDiffEqAdamsBashforthMoulton/src/algorithms.jl b/lib/OrdinaryDiffEqAdamsBashforthMoulton/src/algorithms.jl index af35c61140..8adf8dbd43 100644 --- a/lib/OrdinaryDiffEqAdamsBashforthMoulton/src/algorithms.jl +++ b/lib/OrdinaryDiffEqAdamsBashforthMoulton/src/algorithms.jl @@ -3,31 +3,46 @@ reference = """E. Hairer, S. P. Norsett, G. Wanner, Solving Ordinary Differentia Problems. Computational Mathematics (2nd revised ed.), Springer (1996) doi: https://doi.org/10.1007/978-3-540-78862-1""" +keyword_default_description = """ +- `thread`: determines whether internal broadcasting on appropriate CPU arrays should be serial (`thread = OrdinaryDiffEq.False()`) or use multiple threads (`thread = OrdinaryDiffEq.True()`) when Julia is started with multiple threads. +""" + +keyword_default = """ +thread = OrdinaryDiffEq.False(), +""" + @doc generic_solver_docstring("The 3-step third order multistep method. Ralston's Second Order Method is used to calculate starting values.", "AB3", "Adams-Bashforth Explicit Method", reference, - "", - "") -struct AB3 <: OrdinaryDiffEqAlgorithm end + keyword_default_description, + keyword_default) +Base.@kwdef struct AB3{Thread} <: OrdinaryDiffEqAlgorithm + thread::Thread = False() +end @doc generic_solver_docstring("The 4-step fourth order multistep method. Runge-Kutta method of order 4 is used to calculate starting values.", "AB4", "Adams-Bashforth Explicit Method", reference, - "", - "") -struct AB4 <: OrdinaryDiffEqAlgorithm end + keyword_default_description, + keyword_default) +Base.@kwdef struct AB4{Thread} <: OrdinaryDiffEqAlgorithm + thread::Thread = False() +end + @doc generic_solver_docstring("The 5-step fifth order multistep method. Ralston's 3rd order Runge-Kutta method is used to calculate starting values.", "AB5", "Adams-Bashforth Explicit Method", reference, - "", - "") -struct AB5 <: OrdinaryDiffEqAlgorithm end + keyword_default_description, + keyword_default) +Base.@kwdef struct AB5{Thread} <: OrdinaryDiffEqAlgorithm + thread::Thread = False() +end @doc generic_solver_docstring("It is third order method. In ABM32, AB3 works as predictor and Adams Moulton 2-steps method works as Corrector. @@ -35,9 +50,11 @@ struct AB5 <: OrdinaryDiffEqAlgorithm end "ABM32", "Adams-Bashforth Explicit Method", reference, - "", - "") -struct ABM32 <: OrdinaryDiffEqAlgorithm end + keyword_default_description, + keyword_default) +Base.@kwdef struct ABM32{Thread} <: OrdinaryDiffEqAlgorithm + thread::Thread = False() +end @doc generic_solver_docstring("It is fourth order method. In ABM43, AB4 works as predictor and Adams Moulton 3-steps method works as Corrector. @@ -45,9 +62,11 @@ struct ABM32 <: OrdinaryDiffEqAlgorithm end "ABM43", "Adams-Bashforth Explicit Method", reference, - "", - "") -struct ABM43 <: OrdinaryDiffEqAlgorithm end + keyword_default_description, + keyword_default) +Base.@kwdef struct ABM43{Thread} <: OrdinaryDiffEqAlgorithm + thread::Thread = False() +end @doc generic_solver_docstring("It is fifth order method. In ABM54, AB5 works as predictor and Adams Moulton 4-steps method works as Corrector. @@ -55,9 +74,11 @@ struct ABM43 <: OrdinaryDiffEqAlgorithm end "ABM54", "Adams-Bashforth Explicit Method", reference, - "", - "") -struct ABM54 <: OrdinaryDiffEqAlgorithm end + keyword_default_description, + keyword_default) +Base.@kwdef struct ABM54{Thread} <: OrdinaryDiffEqAlgorithm + thread::Thread = False() +end # Variable Step Size Adams methods @@ -66,54 +87,66 @@ struct ABM54 <: OrdinaryDiffEqAlgorithm end "VCAB3", "Adams explicit Method", reference, - "", - "") -struct VCAB3 <: OrdinaryDiffEqAdaptiveAlgorithm end + keyword_default_description, + keyword_default) +Base.@kwdef struct VCAB3{Thread} <: OrdinaryDiffEqAdaptiveAlgorithm + thread::Thread = False() +end @doc generic_solver_docstring("The 4th order Adams method. Runge-Kutta 4 is used to calculate starting values.", "VCAB4", "Adams explicit Method", reference, - "", - "") -struct VCAB4 <: OrdinaryDiffEqAdaptiveAlgorithm end + keyword_default_description, + keyword_default) +Base.@kwdef struct VCAB4{Thread} <: OrdinaryDiffEqAdaptiveAlgorithm + thread::Thread = False() +end @doc generic_solver_docstring("The 5th order Adams method. Runge-Kutta 4 is used to calculate starting values.", "VCAB5", "Adams explicit Method", reference, - "", - "") -struct VCAB5 <: OrdinaryDiffEqAdaptiveAlgorithm end + keyword_default_description, + keyword_default) +Base.@kwdef struct VCAB5{Thread} <: OrdinaryDiffEqAdaptiveAlgorithm + thread::Thread = False() +end @doc generic_solver_docstring("The 3rd order Adams-Moulton method. Bogacki-Shampine 3/2 method is used to calculate starting values.", "VCABM3", "Adams explicit Method", reference, - "", - "") -struct VCABM3 <: OrdinaryDiffEqAdaptiveAlgorithm end + keyword_default_description, + keyword_default) +Base.@kwdef struct VCABM3{Thread} <: OrdinaryDiffEqAdaptiveAlgorithm + thread::Thread = False() +end @doc generic_solver_docstring("The 4th order Adams-Moulton method. Runge-Kutta 4 is used to calculate starting values.", "VCABM4", "Adams explicit Method", reference, - "", - "") -struct VCABM4 <: OrdinaryDiffEqAdaptiveAlgorithm end + keyword_default_description, + keyword_default) +Base.@kwdef struct VCABM4{Thread} <: OrdinaryDiffEqAdaptiveAlgorithm + thread::Thread = False() +end @doc generic_solver_docstring("The 5th order Adams-Moulton method. Runge-Kutta 4 is used to calculate starting values.", "VCABM5", "Adams explicit Method", reference, - "", - "") -struct VCABM5 <: OrdinaryDiffEqAdaptiveAlgorithm end + keyword_default_description, + keyword_default) +Base.@kwdef struct VCABM5{Thread} <: OrdinaryDiffEqAdaptiveAlgorithm + thread::Thread = False() +end # Variable Order and Variable Step Size Adams methods @@ -122,6 +155,8 @@ struct VCABM5 <: OrdinaryDiffEqAdaptiveAlgorithm end "VCABM", "adaptive order Adams explicit Method", reference, - "", - "") -struct VCABM <: OrdinaryDiffEqAdamsVarOrderVarStepAlgorithm end + keyword_default_description, + keyword_default) +Base.@kwdef struct VCABM{Thread} <: OrdinaryDiffEqAdamsVarOrderVarStepAlgorithm + thread::Thread = False() +end diff --git a/lib/OrdinaryDiffEqAdamsBashforthMoulton/test/abm_convergence_tests.jl b/lib/OrdinaryDiffEqAdamsBashforthMoulton/test/abm_convergence_tests.jl index ccebddd73e..ffe01a7d71 100644 --- a/lib/OrdinaryDiffEqAdamsBashforthMoulton/test/abm_convergence_tests.jl +++ b/lib/OrdinaryDiffEqAdamsBashforthMoulton/test/abm_convergence_tests.jl @@ -37,3 +37,21 @@ testTol = 0.2 sim106 = test_convergence(dts, prob, VCABM5()) @test sim106.𝒪est[:l2]≈5 atol=testTol end + +@testset "Explicit Solver Convergence Tests ($(["out-of-place", "in-place"][i])) - threaded " for i in 1:2 + prob = (ODEProblemLibrary.prob_ode_linear, + ODEProblemLibrary.prob_ode_2Dlinear)[i] + + sim5 = test_convergence(dts, prob, AB3(true)) + @test sim5.𝒪est[:l2]≈3 atol=testTol + sim7 = test_convergence(dts, prob, AB4(true)) + @test sim7.𝒪est[:l2]≈4 atol=testTol + sim9 = test_convergence(dts, prob, AB5(true)) + @test sim9.𝒪est[:l2]≈5 atol=testTol + sim101 = test_convergence(dts, prob, VCAB3(true)) + @test sim101.𝒪est[:l2]≈3 atol=testTol + sim103 = test_convergence(dts, prob, VCAB5(true)) + @test sim103.𝒪est[:l2]≈5 atol=testTol + sim105 = test_convergence(dts, prob, VCABM4(true)) + @test sim105.𝒪est[:l2]≈4 atol=testTol +end diff --git a/lib/OrdinaryDiffEqAdamsBashforthMoulton/test/regression_test_threading.jl b/lib/OrdinaryDiffEqAdamsBashforthMoulton/test/regression_test_threading.jl new file mode 100644 index 0000000000..b70a6b11cb --- /dev/null +++ b/lib/OrdinaryDiffEqAdamsBashforthMoulton/test/regression_test_threading.jl @@ -0,0 +1,22 @@ +using OrdinaryDiffEqAdamsBashforthMoulton, ODEProblemLibrary +import OrdinaryDiffEqCore: OrdinaryDiffEqAdaptiveAlgorithm +using Test +using Static + +algorithms = [ + AB3, AB4, AB5, ABM32, ABM43, ABM54, VCAB3, VCAB4, VCAB5, VCABM3, VCABM4, VCABM5, VCABM] + +problem = ODEProblemLibrary.prob_ode_linear + +@testset "Regression test for threading versions vs non threading versions" begin + @testset "$ALG" for ALG in algorithms + if ALG isa OrdinaryDiffEqAdaptiveAlgorithm + sol_thread = solve(problem, ALG(Static.True())) + sol_nothread = solve(problem, ALG(Static.False())) + else + sol_thread = solve(problem, ALG(Static.True()), dt = 1 // 2^9) + sol_nothread = solve(problem, ALG(Static.False()), dt = 1 // 2^9) + end + @test all(sol_nothread .== sol_thread) + end +end diff --git a/lib/OrdinaryDiffEqAdamsBashforthMoulton/test/runtests.jl b/lib/OrdinaryDiffEqAdamsBashforthMoulton/test/runtests.jl index a0518e6f70..fd3e5ee9a4 100644 --- a/lib/OrdinaryDiffEqAdamsBashforthMoulton/test/runtests.jl +++ b/lib/OrdinaryDiffEqAdamsBashforthMoulton/test/runtests.jl @@ -2,3 +2,4 @@ using SafeTestsets @time @safetestset "ABM Convergence Tests" include("abm_convergence_tests.jl") @time @safetestset "Adams Variable Coefficients Tests" include("adams_tests.jl") +@time @safetestset "Regression test for threading versions vs non threading versions" include("regression_test_threading.jl")