Will leftover CPU cores (not used by parfor workers) be used for built-in multithreading?
9 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Lorenco Santos Vasconcelos
il 23 Dic 2024
Modificato: Lorenco Santos Vasconcelos
il 23 Dic 2024
I have an 8-core CPU with 16 logical cores (hyper-threading). I’m aware that MATLAB’s built-in functions (e.g., min, max, sum, large matrix operations) can use multiple threads internally.
Right now, I need to run several time-consuming tasks in parallel using parfor with the "threads" profile. Typically, I’d start a pool with 8 workers (one per physical core). However, I’m considering creating a pool with only 6 workers, leaving 2 physical cores “free.” My hope is that these 2 leftover cores would be used by each worker’s built-in multithreading, potentially speeding up those internal functions.
My questions are:
- If I create a 6-worker pool on an 8-core machine, will the built-in threaded functions inside each worker automatically use the remaining 2 cores?
- Does the operating system or MATLAB’s runtime effectively allocate these leftover cores to those functions, or is that not how it works in practice?
The job for each worker does not depend on any other thing.
I’d appreciate any insights or suggestions on finding the right balance between the number of parfor workers and MATLAB’s internal multithreading. Thank you!
0 Commenti
Risposta accettata
Walter Roberson
il 23 Dic 2024
No, left-over cores will not be automatically used. They will be left for the operating system to run (whatever) on.
If you want more than one core for each worker then you need to use the Cluster Profile Manager to specify a higher "Number of computational threads to use on each worker NumThreads".
However, each worker will use the same number of cores, so the best you could do would be to allocate NumWorkers as 4 and NumThreads as 2.
3 Commenti
Walter Roberson
il 23 Dic 2024
Editting the cluster profile does not have any effect on Threads pool.
I am not certain but I think that Threads pool allocates one core per thread. But possibly they do not explicitly allocate cores and simply leave it up to the operating system to schedule them... constrained to one core at a time.
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!