How can I increase the number of MATLAB workers inside Parallel Computing Toolbox to use all the cores of my machine?

141 visualizaciones (últimos 30 días)
My computer has 32 logical cores but by default Parallel Computing Toolbox will only start a number of workers equal to the number of physical cores I have. How do I enable Parallel Computing Toolbox to use all the logical cores? Is it beneficial?

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 9 de Mayo de 2025
Editada: MathWorks Support Team el 9 de Mayo de 2025
A physical core refers to an individual processing unit within a CPU. In modern CPUs, a physical core consists of an independent execution unit capable of performing calculations and running instructions.
A logical core, also known as a virtual core or thread, is a concept that arises from the use of technologies like Hyper-Threading or simultaneous multithreading (SMT). These technologies allow a single physical core to behave as if it were multiple logical cores. Some resources inside a physical core are duplicated to streamline this.
In some chip architectures your cores may instead be labelled as performance or efficiency cores. For more information on these, refer to the
Compute-bound mathematical operations tend to gain the most benefit from running exclusively on physical cores (or physical "performance" cores where available). However, if your parallel code is not compute bound (for example does significant disk I/O or memory intensive operations) then you may gain some performance benefit from increasing the number of workers above the default value.
 

To alter the maximum number of workers allowed by the 'Processes' or 'local' profile:

Setting the number of parallel workers too high may impact your performance and machine's stability. Always ensure the machine has enough memory to run the number of MATLAB workers and code you wish to execute. We recommend that if you choose to exceed the default number of workers, you increase this setting gradually and measure your application's performance, memory usage and stability.
  • Using the MATLAB GUI: From the Parallel Computing menu > Create and Manager clusters...> inside the 'Cluster Profile Manager' select the 'Processes' or 'local' profile and edit the number of workers (NumWorkers) to start on your local machine.
  • Programmatically: 
c = parcluster('Processes') % or use parcluster('local') pre-R2022b
c.NumWorkers = 10; % choose the new value you want. Using 10 here as an example.
saveProfile(c) % will overwrite the profile with the new NumWorkers value
Note: if you are also altering the NumThreads we recommend that NumWorkers x NumThreads <= Number of Physical Cores on the system.

Más respuestas (0)

Productos


Versión

R2015b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by