Right, I am not saying addprocs(Sys.CPU_THREADS)
dosn’t work… I am saying that you are not making use of the newly developed, true threading library. You are not utilizing the hyperthread feature of your CPU. For this you need to have the envionrment variable setup and call using Threads
, and write code that is thread safe (remember, when using threads the memory is shared).
By running addprocs(Sys.CPU_THREADS)
you are simply launching Sys.CPU_THREADS
workers. Each worker is inherently single threaded. There is no memory shared between them, but you are indeed running “true” parallelism. I am also not used to using primitives like @sync
and @async
, but I don’t think these utilize threading either.
So again, point is… you are launching x
amount of independent workers… each worker is separate… this is through Julia’s Distributed
library. it is possible to use threads within each worker by also utilizing Julia’s Threads
library.
To really wrap your head around it, simply do addprocs(4)
on your local machine and play around with functions from both Distributed and Threads.