Why won't matlab use all logical cores?

52 views (last 30 days)
Christopher
Christopher on 15 Mar 2014
Commented: Mehmet Selim Akay on 16 Apr 2022
I am running a highly vectorized code and have noticed that matlab will not use all of my logical cores. Many vector operations are computed on arrays which are on the order of 10^5-10^6 elements. I am running on an 6 physical, 12 logical core i7 4960x. I am using version 2013b.
When I run my code, windows CPU usage statistics indicate that only a maximum of 50% of CPU power is being used. It seems it is only using 6 cores even when forced to recognize 12. I have tried to set maxNumCompThreads=12 to force more core usage, but nothing changes.
It is trivial to show that this is not a fluke of hyperthreading inefficiency or anything of that sort. I can open up the same code in an additional matlab executable and the decrease in run speed is only 10% but with two codes running simultaneously, obviously demonstrating that the extra logical cores are simply not being used. Simultaneously, when hyperthreading is turned off, the increase in speed is a puny 10%. Thus hypertherthreading is a huge boost in my code. Moreover, my core temperatures are about 40C when one code is running, and 75C when two are. Obviously there is unused power here.
Regardless of the details, matlab is clearly failing to saturate 12 cores and thus my code is only running about 60% of the speed it would run at if all cores were used.
Is there a solution to this problem?
  3 Comments
StefanoM64
StefanoM64 on 6 Mar 2017
Finally, a smart observation about hyper-threading and Matlab. I think it's correct, the various managers give a misleading information about CPUs load ...
Mehmet Selim Akay
Mehmet Selim Akay on 16 Apr 2022
Dear Christopher, have you found a solution? In the previous years' Matlab versions I used to set the threads in the parallel preferences and it was working perfectly, but now it defaults to physical core count.

Sign in to comment.

Answers (2)

ck4e
ck4e on 4 Jan 2020
I just ran into this and found a solution. You can set the number of worker threads (and so the number of "cores" used) using maxNumCompThreads.

per isakson
per isakson on 15 Mar 2014
Edited: per isakson on 16 Mar 2014
  • Matlab is single threaded. However, some functions use more than one core.
  • Solution: Parallel Toolbox allows you to use "all" cores. (The Parallel Toolbox license sets an upper limit for the number of cores that may be used. The limit depend on the Matlab release.)
  3 Comments
per isakson
per isakson on 16 Mar 2014
Edited: per isakson on 16 Mar 2014
Which release of Matlab? What does the Parallel Toolbox license say about number of "local workers"?
Christopher
Christopher on 16 Mar 2014
I am currently using 2013b. In the Parallel computing toolbox preferences it says preferred number of workers is 12. Interestingly, I ran the 'cluster profile manager' and during the validation test CPU usage went up to almost 90% at one point.

Sign in to comment.

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!