Skip to content

Commit 3cce666

Browse files
Merge pull request #465 from SciML/jumpsafety
Fix and test multithreaded jump safety
2 parents dd44877 + 88b40a6 commit 3cce666

File tree

4 files changed

+71
-1
lines changed

4 files changed

+71
-1
lines changed

.buildkite/pipeline.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
steps:
2+
- label: "Multithreaded"
3+
plugins:
4+
- JuliaCI/julia#v1:
5+
version: "1"
6+
- JuliaCI/julia-test#v1:
7+
coverage: false
8+
julia_args: "--threads=auto"
9+
agents:
10+
os: "linux"
11+
queue: "juliaecosystem"
12+
env:
13+
GROUP: 'Multithreaded'
14+
timeout_in_minutes: 240
15+
# Don't run Buildkite if the commit message includes the text [skip tests]
16+
if: build.message !~ /\[skip tests\]/
17+
218
- label: "OOPWeakConvergence"
319
plugins:
420
- JuliaCI/julia#v1:

src/solve.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function DiffEqBase.__init(
7979
end
8080

8181
if typeof(_prob) <: JumpProblem
82-
if alias_jumps
82+
if !alias_jumps
8383
_prob = DiffEqJump.resetted_jump_problem(_prob, _seed)
8484
elseif _seed !== 0
8585
DiffEqJump.reset_jump_problem!(_prob, _seed)

test/multithreaded_jump_test.jl

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using DiffEqJump, StochasticDiffEq, Test
2+
3+
# Requires threads to be effective
4+
# https://github.com/SciML/DifferentialEquations.jl/issues/854
5+
using Base.Threads
6+
@test Threads.nthreads() > 1
7+
8+
9+
function testdrift!(du, u, p, t)
10+
du[1] = u[1]
11+
end
12+
13+
14+
function testdiffusion!(du, u, p, t)
15+
du[1] = u[1]
16+
end
17+
18+
19+
function testrate(u, p, t)
20+
return 0.32
21+
end
22+
23+
24+
function testaffect!(integrator)
25+
integrator.u[1] += integrator.u[1] * randn()
26+
end
27+
28+
29+
testjump = ConstantRateJump(testrate, testaffect!)
30+
31+
test_sdeprob = SDEProblem(testdrift!,
32+
testdiffusion!,
33+
[1.0],
34+
(0.0, 1.0)
35+
)
36+
37+
test_jumpprob = JumpProblem(test_sdeprob,
38+
Direct(),
39+
testjump
40+
)
41+
42+
test_ensemprob = EnsembleProblem(test_jumpprob)
43+
44+
test_ensemsim = solve(test_ensemprob,
45+
EM(),
46+
dt=0.01,
47+
EnsembleThreads();
48+
trajectories=1_000_000,
49+
alias_jump = false,
50+
)

test/runtests.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,5 +125,9 @@ const is_APPVEYOR = Sys.iswindows() && haskey(ENV,"APPVEYOR")
125125
@time @safetestset "GPU Weak adaptive step size scalar noise SDE" begin include("gpu/sde_weak_scalar_adaptive_gpu.jl") end
126126
@time @safetestset "GPU Weak adaptive" begin include("gpu/sde_weak_adaptive_gpu.jl") end
127127
end
128+
129+
if !is_APPVEYOR && GROUP == "Multithreaded"
130+
@time @safetestset "Mulithreaded Jump Thread Safety Tests" begin include("multithreaded_jump_test.jl") end
131+
end
128132

129133
end

0 commit comments

Comments
 (0)