Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

reduction_func and :threads error #31

Closed
ivborissov opened this issue Dec 20, 2018 · 5 comments
Closed

reduction_func and :threads error #31

ivborissov opened this issue Dec 20, 2018 · 5 comments

Comments

@ivborissov
Copy link

Hi,

the issue is also mentioned here, but still present in Julia 0.7:
https://github.com/JuliaDiffEq/DiffEqMonteCarlo.jl/issues/23

It can be illustrated by the following example.

using DiffEqBase, OrdinaryDiffEq, DiffEqMonteCarlo, DiffEqCallbacks, Distributions

function ode_sys(du,u,p,t)
  v1 = p[1]*u[1]*p[2]
  du[1] = -v1/p[2]
  du[2] = v1/p[2]
end

prob = ODEProblem(ode_sys, [10.,0.], (0.,100.),  [1.5,1.0])

function prob_func(prob, i, repeat)
  @. prob.u0 = rand(Normal(prob.u0, 0.3))
  @. prob.p = rand(Normal(prob.p, 0.3))
  prob
end

function reduction(u,data,I)
  # do smth, calculate OnlineStats
  append!(u,data),false
end

monte_prob = MonteCarloProblem(
  prob,
  prob_func=prob_func,
  reduction=reduction
)

sol = solve(
  monte_prob,
  Tsit5(),
  batch_size=1,
  parallel_type=:threads,
  num_monte = 100
)

It works fine with parallel_type=:none but fails with parallel_type=:threads with

UnefRefError: access to undefined reference.
Error thrown in threaded loop on thread 0: BoundsError(a=Array{Any, (1,)}[#<null>], i=(2,))

Is this issue related to my code or general julia multithreading?

@ivborissov
Copy link
Author

I guess it is the same issue
SciML/DifferentialEquations.jl#241

@ChrisRackauckas
Copy link
Member

No, that issue is only with batch sizes > 1. This, I have no idea why this is coming up and will need to dig in.

@ChrisRackauckas
Copy link
Member

Is this required now? I was planning on looking at this library again after PARTR merges JuliaLang/julia#22631 since that'll be a big change to the threading constructs.

@ivborissov
Copy link
Author

Thanks! If it is not 2.0 but some upcoming 1.x merges, it is reasonable to wait. I'm really looking forward to this batching functionality as it will allow me to fully test OnlineStats with Parallel DiffEqMonteCarlo:
https://github.com/JuliaDiffEq/DiffEqMonteCarlo.jl/issues/23

@ChrisRackauckas
Copy link
Member

It was supposed to be 1.1 but it missed that mark. Can't be too far off

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants