How to use all CPU cores
0 commentaires
Réponse acceptée
0 commentaires
Plus de réponses (2)
0 commentaires
1 commentaire
You accidentally left out the instructions.
By default, MATLAB configures all physical cores in the pool. By default the pool size is the same as the number of cores.
This configuration is the best one when each of the workers is CPU bound and happen to work well in single threaded mode.
If tasks are CPU bound and happen to be mostly operations on larger matrices, especially linear algebra calculations, then there can be benefits to reconfiguring the pool to have fewer members each with multiple physical cores.
If the tasks happen to contain notable waits on outside events, such as reading from disk or waiting for interruption, then sometimes there is benefit to enabling logical cores.
On the other hand, if the tasks do involve notable waiting for disk, then there is the problem that disk controllers are typically limited to transferring a small number of channels simultaneously, and disk drives are almost always limited reading only one file at a time. Even drives that do good optimization of several outstanding read requests are almost always limited to reading one stream of blocks at a time, so when you have more than roughly 3 outstanding read requests at a time, performance begins to suffer. To get around this problem you need to carefully plan the placement of data on separate drives and separate drive controllers to optimize drive performance. The maximum practical performance is typically with four drives distributed across two controllers and two or three outstanding read requests per drive. In short even with good planning, it is tricky to optimize I/O on more than roughly 8 workers. (Not impossible, if you are using server class machines that are well equipped and very carefully implemented.)
All of which is to say that a lot of the time, the default of one worker per physical core works out the best, whereas enabling logical cores tends to slow things down.
Voir également
Catégories
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!