Skip to content
Open
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
2 changes: 1 addition & 1 deletion lib/OrdinaryDiffEqCore/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "OrdinaryDiffEqCore"
uuid = "bbf590c4-e513-4bbe-9b18-05decba2e5d8"
authors = ["ParamThakkar123 <paramthakkar864@gmail.com>"]
version = "4.20.1"
version = "4.20.2"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down
4 changes: 4 additions & 0 deletions lib/OrdinaryDiffEqCore/src/misc_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ isthreaded(::BaseThreads) = true
isthreaded(::PolyesterThreads) = true

@inline function _threaded_execute(f, ::Union{BaseThreads, Bool}, range)
if ccall(:jl_in_threaded_region, Cint, ()) != 0
foreach(f, range)
return nothing
end
return Threads.@threads :static for i in range
f(i)
end
Expand Down
14 changes: 14 additions & 0 deletions lib/OrdinaryDiffEqPRK/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,20 @@ end
@test !any(Base.isexported.(Ref(OrdinaryDiffEqPRK), internal))
end

@time @safetestset "Threaded stages inside another threaded loop" begin
using OrdinaryDiffEqPRK, Test
prob_iip = ODEProblem((du, u, p, t) -> (du .= -u), [1.0, 2.0], (0.0, 1.0))
prob_oop = ODEProblem((u, p, t) -> -u, 1.0, (0.0, 1.0))
for prob in (prob_iip, prob_oop)
threaded = solve(prob, KuttaPRK2p5(threading = true); dt = 0.1)
sols = Vector{Any}(undef, 2)
Threads.@threads for i in 1:2
sols[i] = solve(prob, KuttaPRK2p5(threading = true); dt = 0.1)
end
@test all(sol -> sol.u == threaded.u, sols)
end
end

# Run QA tests (AllocCheck, JET, Aqua) - skip on pre-release Julia
# Allocation tests must run before JET because JET's static analysis
# invalidates compiled code and causes spurious runtime allocations.
Expand Down
Loading