Skip to content

Commit

Permalink
Fix potential deadlocks during parallel simplification (#1844)
Browse files Browse the repository at this point in the history
For larger models, I experienced occassional deadlocks during import. Unclear why.
Most such issues seem to be related to forking, so let's do without.
  • Loading branch information
dweindl authored Aug 4, 2022
1 parent 7cf65d1 commit 1f5e5ef
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions python/amici/ode_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,11 @@ def smart_jacobian(eq: sp.MutableDenseMatrix,
)

# parallel
from multiprocessing import Pool
with Pool(n_procs) as p:
from multiprocessing import get_context
# "spawn" should avoid potential deadlocks occurring with fork
# see e.g. https://stackoverflow.com/a/66113051
ctx = get_context('spawn')
with ctx.Pool(n_procs) as p:
mapped = p.starmap(_jacobian_element, elements)
return sp.MutableSparseMatrix(nrow, ncol, dict(mapped))

Expand Down

0 comments on commit 1f5e5ef

Please sign in to comment.