Suppose I'm running an expensive computation in the background with @async. Will this computation be performed on the same thread the Julia runtime is running on (i.e. on the same CPU core)? If yes, will I have to then start Julia like julia --threads 2 and use Base.Threads?
@async spawns a green thread coroutine. They will be all spawned in the same system thread and hence are good for types of parallelism where you are waiting for external resources (IO, remote jobs) it is not good for things such as parallelizing your numerical computations (unless they are done on remote workers).
Basically, in Julia you have the following parallelism types:
@simd - utilize Single instruction, multiple data (SIMD) feature of a CPU@async - coroutines@threads - multithreading, requires seting JULIA_NUM_THREADS environment variable@distributed - multiprocessing on a single or multiple machinesCUDA.jlYou can find several more detailed examples on StackOverflow for each topic above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With