Skip to content
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

ScipyOdeSimulator multiprocessing capability #395

Merged
merged 7 commits into from Apr 25, 2019

Conversation

@alubbock
Copy link
Member

@alubbock alubbock commented Dec 1, 2018

This PR uses the multiprocessing module to add parallel simulation
capability to the ScipyOdeSimulator. This only works when using
Cython as a compiler.

Multiprocessing is picky about what can be pickled and sent to
child processes, so the Cython code is sent as text for use with
inline(). Since inline() is called in __init__() with the same code,
it utilises cython's cache, and therefore the ODEs only have to be
compiled once. The code is a little bit duplicative, since we can't
pass instance methods through to multiprocessing's processes,
thefore the rhs() and jac_fn() methods must be redefined in
each process. Requires (and checks for) Python >=3.3.

@coveralls
Copy link

@coveralls coveralls commented Dec 1, 2018

Coverage Status

Coverage decreased (-1.0%) to 78.197% when pulling 1c1466b on alubbock:parallel_odeint into 4c56f33 on pysb:master.

@coveralls
Copy link

@coveralls coveralls commented Dec 1, 2018

Coverage Status

Coverage increased (+0.03%) to 78.126% when pulling ae16cbb on alubbock:parallel_odeint into 9bcb2f4 on pysb:master.

Copy link
Member

@jmuhlich jmuhlich left a comment

Great idea, needs some refactoring to address code duplication though.

pysb/simulator/scipyode.py Outdated Show resolved Hide resolved
pysb/tests/test_simulator_scipy.py Show resolved Hide resolved
alubbock added 5 commits Apr 10, 2019
This PR uses the multiprocessing module to add parallel simulation
capability to the ScipyOdeSimulator. This only works when using
Cython as a compiler.

Multiprocessing is picky about what can be pickled and sent to
child processes, so the Cython code is sent as text for use with
inline(). Since inline() is called in `__init__()` with the same code,
it utilises cython's cache, and therefore the ODEs only have to be
compiled once. The code is a little bit duplicative, since we can't
pass instance methods through to multiprocessing's processes, and
thefore the `rhs()` and `jac_fn()` methods must be redefined in
each process.
@alubbock alubbock force-pushed the parallel_odeint branch from aceec38 to 074086a Apr 10, 2019
Copy link
Member

@jmuhlich jmuhlich left a comment

Thanks, just a couple of bits left to fix.

pysb/simulator/scipyode.py Outdated Show resolved Hide resolved
pysb/simulator/scipyode.py Outdated Show resolved Hide resolved
@alubbock
Copy link
Member Author

@alubbock alubbock commented Apr 24, 2019

@jmuhlich Thanks, feedback implemented.

@alubbock alubbock merged commit 2b6e954 into pysb:master Apr 25, 2019
3 checks passed
@alubbock alubbock deleted the parallel_odeint branch Apr 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants