Number of cores, by default

109 vues (au cours des 30 derniers jours)
David López de la Cruz
David López de la Cruz le 20 Mai 2019
Commenté : Jason Ross le 20 Sep 2021
I am using Parallel Pool for running my program. When I use it, the number of workers is set in 2 workers. However, my computer has 4 cores and in the Porperties of Parallel Computing Toolbox the variable NumWorkers is set to "number of cores, up to 512 (default)". How is it possible that MATLAB can't allow to work with the total number of processors of my computer?
Thanks for all,
David
  2 commentaires
Andrea Picciau
Andrea Picciau le 21 Mai 2019
Modifié(e) : Andrea Picciau le 21 Mai 2019
Hi David,
I've just come across this other thread. Does it apply to your case?
shital shinde
shital shinde le 4 Mar 2020
Hi, I also have the same question for the number of workers and cores of system. anybody know about that.???

Connectez-vous pour commenter.

Réponses (1)

John D'Errico
John D'Errico le 4 Mar 2020
Modifié(e) : John D'Errico le 4 Mar 2020
As Andrea has suggested, read the other thread. This is usually a question of hyper-threading.
Your computer makes it look as if you have 4 cores, when in reality, you have two physical cores. For some problems, this works very nicely, because most things you will do on your computer don't really need to run your CPU flat out at 100%. That is, check your mail, view a web page, etc. Every other time step, one core can solve two simple problems at once. And since you have two physical cores, now it makes you think that you have 4 cores. So hyper-threading works well, because it now looks as if you have 4 cores.
But in reality, you still just have TWO cores, not 4. So if you need to do some CPU intensive problem, then splitting a core in half just means it take twice as long to solve that problem. You get no benefit at all from the hyper-threading. In fact, you probably have some loss of efficiency. Anyway, the parallel toolbox will recognize that what matters is the maximum number of true computational cores.
maxNumCompThreads
ans =
8
On my computer, that is 8, because there are 8 physical cores. So, unless you have explicitly told MATLAB to use less than the number of physical cores on your computer, then it uses all you have automatically.
help maxNumCompThreads
maxNumCompThreads controls the maximum number of computational threads
N = maxNumCompThreads returns the current maximum number of
computational threads N.
LASTN = maxNumCompThreads(N) set the maximum number of computational
threads to N, and returns the previous maximum number of computational
threads LASTN.
LASTN = maxNumCompThreads('automatic') set the maximum number of
computational threads to what MATLAB determines to be the most
desirable. In addition, it returns the previous maximum number of
computational threads LASTN. Currently the maximum number of
computational threads is equal to the number of computational cores on
your machine.
Settings changed by maxNumCompThreads are not propagated to the next
MATLAB session.
In past times, hyper-threading was a great idea, especially when many computers had only one core. It allowed your computer to appear to as if it was doing two things at once. Today, it is not quite so useful, but it still can make for great marketing hype, convincing buyers that they are getting more computer for their money.
It does appear you can force MATLAB to use those hyper-threaded cores, by setting the appropriate preference to 4 instead of 2, however you won't gain any real additional throughput. In the end, hyper-threading is just the manufacturer blowing smoke in your eyes.
  2 commentaires
PENGYUAN TAN
PENGYUAN TAN le 19 Sep 2021
My computer also has 8 physical cores. I want to know how many cores are used for parallel computing will not affect other operations on the computer?
Jason Ross
Jason Ross le 20 Sep 2021
There's no one answer for this -- at some point the operating system is handling how the various processes using the CPU cores (and RAM/swap) are load-balanced. It might be that you can run 8 workers just fine and the OS has enough resources to keep up with it all -- some operations are more CPU intensive than others. On the same token, you might also find that you need to decrease the number of workers running to less than 8 so that other applications get the resources they need to work effecively.
Number of workers = number of cores is "best guess" default. It's a decent enough assmption but it's not guaranteed to be correct.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by