Will leftover CPU cores (not used by parfor workers) be used for built-in multithreading?
46 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Lorenco Santos Vasconcelos
el 23 de Dic. de 2024 a las 19:16
Editada: Lorenco Santos Vasconcelos
el 23 de Dic. de 2024 a las 22:25
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 comentarios
Respuesta aceptada
Walter Roberson
el 23 de Dic. de 2024 a las 20:11
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 comentarios
Walter Roberson
el 23 de Dic. de 2024 a las 20:47
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.
Lorenco Santos Vasconcelos
el 23 de Dic. de 2024 a las 22:25
Editada: Lorenco Santos Vasconcelos
el 23 de Dic. de 2024 a las 22:25
Más respuestas (0)
Ver también
Categorías
Más información sobre Parallel Computing Fundamentals en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!