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

Projects
None yet
3 participants
@alubbock
Copy link
Member

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

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.

@jmuhlich
Copy link
Member

left a comment

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

Show resolved Hide resolved pysb/simulator/scipyode.py Outdated
Show resolved Hide resolved pysb/tests/test_simulator_scipy.py

alubbock added some commits Dec 1, 2018

Add ScipyOdeSimulator multiprocessing capability
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 alubbock:parallel_odeint branch from aceec38 to 074086a Apr 10, 2019

@jmuhlich
Copy link
Member

left a comment

Thanks, just a couple of bits left to fix.

Show resolved Hide resolved pysb/simulator/scipyode.py Outdated
Show resolved Hide resolved pysb/simulator/scipyode.py Outdated
@alubbock

This comment has been minimized.

Copy link
Member Author

commented Apr 24, 2019

@jmuhlich Thanks, feedback implemented.

@alubbock alubbock merged commit 2b6e954 into pysb:master Apr 25, 2019

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.03%) to 78.126%
Details

@alubbock alubbock deleted the alubbock:parallel_odeint branch Apr 25, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.