Reputation: 6431
I would like to understand, from the user point of view, the differences in multithreading programming models between Julia >= 1.3 and Python 3.
Is there one that is more efficient than the other (in the sense that rising the thread numbers reduces more the computational time) ? In which situations (e.g. one model may have an edge, but only on computational or memory intensive tasks) ?
Is one that is more practical/provide higher level functions than the other ?
Is one that is more flexible than the other (e.g. it can be applied to a wider set of cases) ?
Upvotes: 6
Views: 2368
Reputation: 42194
There are several differences between the languages with Julia providing many levels of functionality on this what you can find in Python. You have the following types of parallelism (I am discussing here the standard language features not functionality available via external libraries):
@simd
with @inbounds
(see https://docs.julialang.org/en/v1/manual/performance-tips/)asyncio
(for more details see https://docs.python.org/3/library/asyncio-task.html)Julia: use Threads.@threads
macro to parallelize loops and Threads.@spawn
to launch tasks on separate system threads. Use locks or atomic values to control the parallel execution. (for more details see https://docs.julialang.org/en/v1/manual/parallel-computing/)
Python: not useful for CPU-dominated tasks due to GIL (global-interpreter-lock) (see the comment by @Jim below)
Julia: use macros from the Distibuted
package to parallelize loops and spawn remote processes (for more details see https://docs.julialang.org/en/v1/manual/parallel-computing/)
Python: use multiprocessing
library - for more details see https://docs.python.org/3.8/library/multiprocessing.html
Upvotes: 11