Comparison of multi-threading models in Julia >=1.3 and Python 3.x

Ant*_*llo 5 python performance multithreading julia

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) ?

一个比另一个更实用/提供更高级别的功能吗?

一个比另一个更灵活(例如,它可以应用于更广泛的案例集)?

Prz*_*fel 10

Julia 在 Python 中提供了许多级别的功能,这两种语言之间存在一些差异。您具有以下类型的并行性(我在这里讨论的是标准语言功能,而不是通过外部库提供的功能):

  1. CPU 的 SIMD (signle-instruction-multiple-data) 特性

  2. 绿色线程(也称为协程)。(这不是实际的线程 - 但允许在多个任务中使用一个系统线程。这对于并行化 IO 操作(例如网络抓取或进程间通信)特别有用 - 例如,如果一个任务正在等待 IO,另一个任务可以并行执行。)

  3. 多线程:跨多个系统线程在单个进程(和共享内存)中并行运行多个任务:

    • Julia:使用Threads.@threads宏来并行化循环并Threads.@spawn在单独的系统线程上启动任务。使用锁或原子值来控制并行执行。(有关更多详细信息,请参阅https://docs.julialang.org/en/v1/manual/parallel-computing/

    • Python:由于 GIL(全局解释器锁)不支持

  4. 多处理