Hyperthreading & Number of Cores. Parallel computing toolbox

I am using:
MATLAB Version: 8.3.0.532 (R2014a)
MATLAB License Number:
Operating System: Microsoft Windows 8.1 Version 6.3 (Build 9600)
Java Version: Java 1.7.0_11-b21 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
----------------------------------------------------------------------------------------------------
MATLAB Version 8.3 (R2014a)
Parallel Computing Toolbox Version 6.4 (R2014a)
I check my number of cores;
feature('numcores')
MATLAB detected: 4 physical cores.
MATLAB detected: 8 logical cores.
MATLAB was assigned: 8 logical cores by the OS.
MATLAB is using: 4 logical cores.
MATLAB is not using all logical cores because hyper-threading is enabled.
ans =
4
I also type;
>> p = parpool(8)
p.NumWorkers
Error using parpool (line 99)
You requested a minimum of 8 workers, but the cluster "local" has the NumWorkers property set to allow a maximum of 4 workers. To run a communicating job on
more workers than this (up to a maximum of 512 for the Local cluster), increase the value of the NumWorkers property for the cluster. The default value of
NumWorkers for a Local cluster is the number of cores on the local machine.
How can I allocate all 8 logical cores for matlab to use when running parfor.m for example? i.e. how can I make MATLAB use/ not use hyperthreading?
thanks

 Accepted Answer

From the MATLAB desktop Parallel menu, select Create and Manage Clusters (or if you are using MATLAB version R2018a or earlier, select Manage Cluster Profiles). This opens the Cluster Profile Manager window. Select a local cluster profile, click the Edit button, and change the value of the NumWorkers property.

9 Comments

I go to "Preferences" and then "Cluster Profile Manager." then "edit" then "number of workers to start on your local machine, Numworkers" and set this value to 8. I then click done. I then click "validate" and then select "show details" and get:
VALIDATION DETAILS
Profile: local
Scheduler Type: Local
Stage: Cluster connection test (parcluster)
Status: Passed
Description:Validation Passed
Command Line Output:(none)
Error Report:(none)
Debug Log:(none)
Stage: Job test (createJob)
Status: Passed
Description:Validation Passed
Command Line Output:
[Warning: Unable to calculate the dependencies of the files:
C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\+internal\+validator\Validator.m
because:
Undefined function or variable "pkgPrefix".]
[> In <a href="matlab: opentoline('C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\+internal\+apishared\AttachedFiles.m',221,1)">AttachedFiles>AttachedFiles.calculateAttachedFiles at 221</a>
In <a href="matlab: opentoline('C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\@Task\Task.m',535,1)">Task.Task>Task.hCalculateDependentFiles at 535</a>
In <a href="matlab: opentoline('C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\@Task\Task.m',554,1)">Task.Task>Task.hCalculateAndCacheDependentFiles at 554</a>
In <a href="matlab: opentoline('C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\@Job\Job.m',686,1)">Job.Job>@(t)t.hCalculateAndCacheDependentFiles(taskFunctionCache) at 686</a>
In <a href="matlab: opentoline('C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\@Job\Job.m',685,1)">Job.Job>Job.attachRequiredFiles at 685</a>
In <a href="matlab: opentoline('C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\@Job\Job.m',300,1)">Job.Job>Job.submit at 300</a>
In <a href="matlab: opentoline('C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\+internal\+validator\Validator.m',529,1)">Validator>iCreateAndSubmitJob at 529</a>
In <a href="matlab: opentoline('C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\+internal\+validator\Validator.m',258,1)">Validator>Validator.runJobStage at 258</a>
In <a href="matlab: opentoline('C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\+internal\+validator\Validator.m',207,1)">Validator>Validator.runValidationStages at 207</a>
In <a href="matlab: opentoline('C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\+internal\+validator\Validator.m',104,1)">Validator>Validator.validate at 104</a>
In <a href="matlab: opentoline('C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\+internal\+ui\ValidationManager.m',45,1)">ValidationManager>ValidationManager.validate at 45</a>
In <a href="matlab: opentoline('D:\blah.m',90,1)">blah at 90</a>]
Error Report:(none)
Debug Log:(none)
Stage: SPMD job test (createCommunicatingJob)
Status: Passed
Description:Validation Passed
Command Line Output:
[Warning: Unable to calculate the dependencies of the files:
C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\+internal\+validator\Validator.m
because:
Undefined function or variable "pkgPrefix".]
[> In <a href="matlab: opentoline('C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\+internal\+apishared\AttachedFiles.m',221,1)">AttachedFiles>AttachedFiles.calculateAttachedFiles at 221</a>
In <a href="matlab: opentoline('C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\@Task\Task.m',535,1)">Task.Task>Task.hCalculateDependentFiles at 535</a>
In <a href="matlab: opentoline('C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\@Task\Task.m',554,1)">Task.Task>Task.hCalculateAndCacheDependentFiles at 554</a>
In <a href="matlab: opentoline('C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\@Job\Job.m',686,1)">Job.Job>@(t)t.hCalculateAndCacheDependentFiles(taskFunctionCache) at 686</a>
In <a href="matlab: opentoline('C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\@Job\Job.m',685,1)">Job.Job>Job.attachRequiredFiles at 685</a>
In <a href="matlab: opentoline('C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\@Job\Job.m',300,1)">Job.Job>Job.submit at 300</a>
In <a href="matlab: opentoline('C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\+internal\+validator\Validator.m',529,1)">Validator>iCreateAndSubmitJob at 529</a>
In <a href="matlab: opentoline('C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\+internal\+validator\Validator.m',258,1)">Validator>Validator.runJobStage at 258</a>
In <a href="matlab: opentoline('C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\+internal\+validator\Validator.m',207,1)">Validator>Validator.runValidationStages at 207</a>
In <a href="matlab: opentoline('C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\+internal\+validator\Validator.m',104,1)">Validator>Validator.validate at 104</a>
In <a href="matlab: opentoline('C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\+internal\+ui\ValidationManager.m',45,1)">ValidationManager>ValidationManager.validate at 45</a>
In <a href="matlab: opentoline('D:\blah.m',90,1)">blah at 90</a>]
Error Report:(none)
Debug Log:(none)
Stage: Pool job test (createCommunicatingJob)
Status: Passed
Description:Validation Passed
Command Line Output:
[Warning: Unable to calculate the dependencies of the files:
C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\+internal\+validator\Validator.m
because:
Undefined function or variable "pkgPrefix".]
[> In <a href="matlab: opentoline('C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\+internal\+apishared\AttachedFiles.m',221,1)">AttachedFiles>AttachedFiles.calculateAttachedFiles at 221</a>
In <a href="matlab: opentoline('C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\@Task\Task.m',535,1)">Task.Task>Task.hCalculateDependentFiles at 535</a>
In <a href="matlab: opentoline('C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\@Task\Task.m',554,1)">Task.Task>Task.hCalculateAndCacheDependentFiles at 554</a>
In <a href="matlab: opentoline('C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\@Job\Job.m',686,1)">Job.Job>@(t)t.hCalculateAndCacheDependentFiles(taskFunctionCache) at 686</a>
In <a href="matlab: opentoline('C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\@Job\Job.m',685,1)">Job.Job>Job.attachRequiredFiles at 685</a>
In <a href="matlab: opentoline('C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\@Job\Job.m',300,1)">Job.Job>Job.submit at 300</a>
In <a href="matlab: opentoline('C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\+internal\+validator\Validator.m',529,1)">Validator>iCreateAndSubmitJob at 529</a>
In <a href="matlab: opentoline('C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\+internal\+validator\Validator.m',258,1)">Validator>Validator.runJobStage at 258</a>
In <a href="matlab: opentoline('C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\+internal\+validator\Validator.m',207,1)">Validator>Validator.runValidationStages at 207</a>
In <a href="matlab: opentoline('C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\+internal\+validator\Validator.m',104,1)">Validator>Validator.validate at 104</a>
In <a href="matlab: opentoline('C:\Program Files\MATLAB\R2014a\toolbox\distcomp\cluster\+parallel\+internal\+ui\ValidationManager.m',45,1)">ValidationManager>ValidationManager.validate at 45</a>
In <a href="matlab: opentoline('D:\blah.m',90,1)">blah at 90</a>]
Error Report:(none)
Debug Log:(none)
Stage: Parallel pool test (parpool)
Status: Passed
Description:Validation Passed
Command Line Output:
Checking communicating job status.
Currently connected to: 1
connected to 8 workers.
Parallel pool using the 'local' profile is shutting down.
hAwaitWorkerCompletion on job 4 completed with result 1 in 4.284153e-03 seconds.
Error Report:(none)
Debug Log:(none)
I then close that window and apply preferences and go back to matlab and get:
feature('numcores')
MATLAB detected: 4 physical cores.
MATLAB detected: 8 logical cores.
MATLAB was assigned: 8 logical cores by the OS.
MATLAB is using: 4 logical cores.
MATLAB is not using all logical cores because hyper-threading is enabled.
ans =
4
ie suggesting it hasn't worked?
Look forward to your comment.
How can I set Numworkers from the command line?
thanks!
There is only a one-way relationship between
feature('numcores')
and the local cluster profile. The cluster profile picks up its default value from the number of physical cores in your system, as evidenced by the parpool message you quoted in your question: "The default value of NumWorkers for a Local cluster is the number of cores on the local machine."
The error message you quote also states that you can increase the value of NumWorkers for the local cluster profile up to a limit of 512. My answer tells you how to do this.
This change will allow you to create a local parallel pool that has more workers than physical cores in your system. This change only impacts parfor, spmd, and other explicit parallelism features that are found in the Parallel Computing Toolbox.
This change does not update the output of
feature('numcores')
which provides information about the physical hardware you are running on. Your physical hardware has not changed, but you have changed how you are instructing the Parallel Computing Toolbox to use that hardware when creating a parallel pool using a specific cluster profile.
I hope this helps to clarify the relationship between these values.
You only mention that the output of
feature('numcores')
is the same after you have increased the NumWorkers property to 8. Have you tried opening a parallel pool with 8 workers?
p = parpool(8)
This should work now, and I believe that this is what you were trying to accomplish, correct?
I went back and re-read your question, and I see now that the validation is getting caught up in validating required files. What are your settings for the three fields in the "Files and Folders" section of your local cluster profile?
I am having what I believe is a similar problem, but the above resolution hasn't helped me.
I have a 12 core Mac Pro with Hyperthreading, running R2014a. I see similar output from
feature('numcores')
but with 12 physical cores and 24 logical cores. The bottom line issue is that when I run a project with parfor (on the 'local' cluster pool), my CPU load is only 50%, and only 12 of the 24 logical cores are loaded. I have tried the above suggestion of
p=parpool(24)
with no success. Similarly, I have tried setting NumWorkers to 24 through a variety of approaches, and none work. How can I fully use my local machine's CPU (all logical cores)?
BTW, when I try to validate after setting 24 NumWorkers in Cluster Profile Manager, it fails to validate (12 works fine though).
Thanks for any help!
Even if you could bump the core count from 12 to 24, I doubt MATLAB would see any benefit. Hyper-threading may help improve the efficiency of "light-weight" processes (email, ...), but MATLAB is typically compute-bound and really needs a full core. I too run a Mac with PCT routinely, and "50% utilization" is expected.
Here is a good discussion on why hyper-threading typically does not help MATLAB:
Thanks Ken, that link does discuss this quite thoroughly, and I found it helpful. Sounds like I should stop this quest for this "mythical" missing 50% cpu load. It seems that the way that the OSX Activity Monitor does its accounting is pretty misleading about the actual CPU load (misleading at least to those like me).
Seemingly corroborating this, I just tried turning off the hyperthreading on the Mac, and while the Activity Monitor showed 100% load on all the physical cores, my Matlab process run time was essentially identical to when hyperthreading was turned on (reporting a 50% CPU load).
To further follow up and put another nail in the coffin of my question, I did an additional test on a Mac laptop with 4 physical cores and 8 logical cores. When I ran my program (using parfor), it used 4 workers and took ~200 secs to run. The OSX Activity Monitor utility reported 50% CPU usage (essentially 4 of the 8 cores were used according to the monitor).
Then, I opened a second instance of Matlab on the same computer, and ran the program simultaneously in BOTH instances of Matlab. This time, the OSX Activity monitor reported 100% CPU activity and all 8 cores were fully used. HOWEVER , the run time for each instance was now 400 seconds. I.e., it took twice as long to run two instances of the program. This anecdotally shows that when running only one instance, it really is using close to 100% of the cpu resources, despite what OSX Activity Monitor says.
I hope this saves someone some time in the future. I wasted a full day trying to milk more performance out of my system.
Jeff, the 'additional' 4 logical cores share their resources with the actual 4 cores. Hence using 8 will not help when maxing out the resources. Manufactures thus can then sell you '8' cores ;)
~kai

Sign in to comment.

More Answers (1)

To resurrect an old thread, I ran a test on a machine with 24 cores / 48 logical (Xeon Gold 6146 x 2).
With 24 workers my calculation was taking 25.5 seconds. With 36 workers it was down to 21 seconds. With 40 workers it was down to 20.3. With 46 workers it was down to 19.8 seconds.
So it would seem hyperthreading does provide a real benefit - in this case, 22% reduction. I'm sure it's workload-dependent.

1 Comment

Add on: my task takes 33 h with 4 pools and 19 h with 8 pools (i7 4 core). So new edition gives support to that kind of setting?

Sign in to comment.

Categories

Tags

Community Treasure Hunt

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

Start Hunting!