MATLAB2020b Parallel Computing Number of Workers

Hi,
My CPU is Ryzen 3600x 6 Core / 12 Threads, Win10 1909
I used to be able to use 12 workers with 2020a.
All 12 logical processor (i.e. threads) in task manager can acheieve nearlly 100% usage
maxNumCompThreads returns 12.
Now I installed 2020b
maxNumCompThreads returns 6. and same code only run with 6 workders.
The task manager has oddly 7 logical processor at nearly 100% usage and the rest 5 sits at near idle (15% ish).
I don't remember exactally the time of the previous run with 2020a (and I already uninstalled it), but seems to be faster than 2020b.
Could anyone have any suggestion? maybe ways to force 12 threads as a comparasion?
Thanks!

6 Comments

Hi Wenjie,
What does this display
feature numcores
maxNumCompThreads will return the number of logical cores, unless you call maxNumCompThreads with an argument. For example
% Override default to 12
old = maxNumCompThreads(12)
old =
4
% Set back to old value
maxNumCompThreads(old)
ans =
12
% Show that it's been set
maxNumCompThreads
ans =
4
To force 12, can you try
c = parcluster('local');
c.NumWorkers = 12;
p = c.parpool(12);
Raymond
Hi Raymond,
feature numcores
MATLAB detected: 6 physical cores.
MATLAB detected: 12 logical cores.
MATLAB was assigned: 12 logical cores by the OS.
MATLAB is using: 6 logical cores.
MATLAB is not using all logical cores because hyper-threading is enabled.
old = maxNumCompThreads(12)
old =
6
>> maxNumCompThreads(old)
ans =
12
>> maxNumCompThreads
ans =
6
c = parcluster('local');
c.NumWorkers = 12;
p = c.parpool(12);
Starting parallel pool (parpool) using the 'local' profile ...
Connected to the parallel pool (number of workers: 12).
It doesn't seeme to keep maxNumCompThreads at 12 using the first two lines.
The c.parpool code does the trick. In there any way to permetely allow 12 workers?
Thanks
use 6 workers
my code completed in 130s~150s
CPU at 4.1GHz
use 12 workers (hyper threading)
my code completed in 95-100s
CPU at 4.0 - 4.05GHz, all 12 logical cores at 100% in task manager
I would say using HT in my use case is a win.
Edit the cluster profile
Same issue here.
Editing the cluster profile worked for me on a Ryzen 3950x.
In my case, with only 16 workers:
Elapsed time is 30.955337 seconds.
Now, with 32 workers:
Elapsed time is 26.437412 seconds.
Hi Gian,
Thanks for confirming that.
With elapsed time that low, you are spending most of your time setting up the workers and communicating data back and forth.

Sign in to comment.

Answers (1)

Hyperthreading does not provide additional computation capacity.
What hyperthreading is, is some extra state registers that permit fast switching of process context, instead of the operating system having to specifically go in and save state and load the old state. It makes better use of resources, keeping the CPUs more evenly loaded, less time switching tasks.
However, hyperthreading is not pre-emptive and not scheduled. As far as the technology itself is concerned, hyperthreading is ready to go when a thread voluntarily gives up control of a core, such as if the thread needs to wait for a resource to become available (read from disk), or wait for user interaction.
In the case of heavy mathematical calculations, MATLAB is not voluntarily giving up the core -- so hyperthreading kicks in during the phase where MATLAB is transfering data into a worker thread, and during the phase where MATLAB is transfering results out of the worker thread... and nothing in-between.
Meanwhile, the heat budget of CPUs is based in part around the assumption that cores will be given up to wait for events, giving a bit of time for the cores to cool. When hyperthreading is in effect and there are active threads waiting, then those pauses with cooling do not occur (as much), so the cores do not cool as much. In order to account for that, cores will down-clock when they are using hyperthreading actively.
Putting this all together: using hyperthreading for active mathematical calculation can slow the calculations down instead of speeding them up.
But anyhow... You can control the maximum number of threads by editing your cluster profile. The default maximum is the number of cores, so you would have had to have changed it before, and possibly when you installed R2020b that cluster profile did not get copied from your R2020a directories.

2 Comments

Thanks for the detailed explanation.
I am aware some of that.
My CPU has water cooling, so thermal is gereally good.
My code is doing imaging processing, so it is highy scalable with parallel.
I included my performace testing in the ablove reply to Raymond
edit the cluster profile
You did not include performance measurements in your reply to Raymond.
Your original post about 7 logical cores does not show that the physical cores are being underused. You would need to time with both cases, one worker per physical core and one worker per logical core.

Sign in to comment.

Products

Tags

Asked:

on 16 Oct 2020

Commented:

on 19 Oct 2020

Community Treasure Hunt

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

Start Hunting!