Difference between multiprocessors and multithreads

Hi,

I used to use package Distributed to do parallel computation. I may require multiple processors by addprocs() and use pmap to execute a function f on multiple cpus. But I just realize that Julia also provides multithreads as in https://docs.julialang.org/en/v1/manual/multi-threading/ . Due to my very limited knowledge, I am very confused about this. What is the difference between multithreads and the way I used to use? How to decide which one to use?

Thanks

Google “shared memory vs distributed memory parallelism” or “threads vs processes” and similar things and you will find lots of explainers — this is not specific to Julia.

1 Like

Super Short Answer : (wikipedia will give you better info)

MT deal with parallelism inside a processor with multiple threads (light process) concurrently sharing the same memory. These concurrent threads may (or may not) be executed in parallel by the multiple cores of the processor.
PROS : much less latency → you can parallelize task with a relatively small workloads
CONS #1: difficult and dangerous (data races) → you may use parallel patterns such as ThreadsX.jl by @tkf.
CONS #2: You cannot scale to interconnected processors (cluster) as you can with Distributed computing.

Combination of Distributed parallelism and MT inside processors is common.

1 Like