-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
PeriodicCallback
is seemingly not thread-safe in EnsembleProblem
with EnsembleThreads
#99
Comments
Thinking through this a bit more, it does seem like it's more of an issue of not making copies of the callbacks when solving an EnsembleProblem. I've injected a simple |
We should solve this by making the cache in |
See the minimum example below, which loops until resulting in the shown crash.
I did some simple debugging (looking at the thread IDs) and found that
PeriodicCallback
seems to have a race issue with theindex[]
value getting reset (in the initialisation function) by different threads, leading to another thread trying to add a newtstop
value in the wrong place (i.e. wheretdir_tnew < integrator.t
).I can fix this issue by changing
tnew = t0[] + (index[] + 1) * Δt
(inPeriodicCallback
function) totnew = integrator.t + Δt
-- however, I think the issue probably still remains in thecondition
function. So it probably needs a better thought out solution.Could it be simply that
EnsembleProblem
is sharing callbacks between the threads, rather than making copies? I didn't look into this. [UPDATE: I did. See comments below. This particular error only occurs onOrbitalTrajectories v0.1.10
.)The text was updated successfully, but these errors were encountered: