Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
maxNumCompThreads default value limits performance R2011a

Subject: maxNumCompThreads default value limits performance R2011a

From: Igor

Date: 30 Apr, 2011 16:09:05

Message: 1 of 10

Hi all,
on my laptop (i7 740qm – 4 physical cores +Hyper threading)
R2010b maxNumCompThreads default = 8
R2011a maxNumCompThreads default = 4
in following tests t_smartblur_theta3D is a mex c++ function compiled with Intel C Compiler with OpenMP.
R2010b:
>> maxNumCompThreads
Warning: maxNumCompThreads will be removed in a future release. Please remove any instances of this function from your code.
> In maxNumCompThreads at 27

ans =

     8

>> t_smartblur_theta3D
Elapsed time is 0.785039 seconds.
>> t_smartblur_theta3D
Elapsed time is 0.610186 seconds.
>> t_smartblur_theta3D
Elapsed time is 0.622742 seconds.
>> t_smartblur_theta3D
Elapsed time is 0.607610 seconds.


R2011a
>> maxNumCompThreads
Warning: maxNumCompThreads will be removed in a future release. Please remove any instances of this function from your code.
> In maxNumCompThreads at 27
ans =
     4
>> t_smartblur_theta3D
Elapsed time is 0.993783 seconds.
>> t_smartblur_theta3D
Elapsed time is 0.968410 seconds.
>> t_smartblur_theta3D
Elapsed time is 0.996887 seconds.
>> maxNumCompThreads(8)
Warning: maxNumCompThreads will be removed in a future release. Please remove any instances of this function from your code.
> In maxNumCompThreads at 27
ans =
     4
>> maxNumCompThreads
Warning: maxNumCompThreads will be removed in a future release. Please remove any instances of this function from your code.
> In maxNumCompThreads at 27
ans =
     8
>> t_smartblur_theta3D
Elapsed time is 0.628210 seconds.
>> t_smartblur_theta3D
Elapsed time is 0.635789 seconds.
>> t_smartblur_theta3D
Elapsed time is 0.627223 seconds.
>> 0.996887/0.627223
ans =
    1.5894

So, why remove maxNumCompThreads ? Would there be no other 'native' way to use 8 threads?
I've read http://www.mathworks.com/matlabcentral/newsreader/view_thread/260966 but fould no answer....

Subject: maxNumCompThreads default value limits performance R2011a

From: Sebastiaan

Date: 23 Jun, 2011 10:01:05

Message: 2 of 10

Hi,

I seem to be having the same problem. My CPU:

Intel(R) Core(TM) i7 CPU Q 820 @ 1.73GHz

I used to be able to use 8 threads in the past, but with 2011a the default is always 4.

The strange thing however, I cannot get Matlab to use all 8 threads. Not even with my old 2009b version, for which I was sure it used 8 before (default is 8 btw, but only 4 is used).

My testcase:
A = rand(5000,5000);
B = A'*A;

and look at the system CPU usage.

-------------------------------------------------------------------------------------
MATLAB Version 7.12.0.635 (R2011a)
MATLAB License Number: 161052
Operating System: Linux 2.6.32-32-generic #62-Ubuntu SMP Wed Apr 20 21:52:38 UTC 2011 x86_64
Java VM Version: Java 1.6.0_17-b04 with Sun Microsystems Inc. Java HotSpot(TM) 64-Bit Server VM mixed mode
-------------------------------------------------------------------------------------

And yes, I would like to vote again for official support of maxNumCompThreads, even if only for OpenMP.

Sebastiaan

Subject: maxNumCompThreads default value limits performance R2011a

From: Igor

Date: 23 Jun, 2011 14:41:05

Message: 3 of 10

"Sebastiaan" wrote in message <itv2t1$2f9$1@newscl01ah.mathworks.com>...
> The strange thing however, I cannot get Matlab to use all 8 threads. Not even with my old 2009b version, for which I was sure it used 8 before (default is 8 btw, but only 4 is used).
>
> My testcase:
> A = rand(5000,5000);
> B = A'*A;
>
> and look at the system CPU usage.
>
Hi Sebastiaan,

I've got 50% CPU usage regardless of maxNumCompThreads(8) / maxNumCompThreads(4) too. (R2011a)

Subject: maxNumCompThreads default value limits performance R2011a

From: Duncan Po

Date: 28 Jun, 2011 18:38:04

Message: 4 of 10

Hi Igor,

I think your machine has hyperthreading enabled. In R2011a, MATLAB detects your machine has hyperthreading, and thus scale down the number of threads to match the number of physical cores.
Hyperthreading is a CPU feature that makes your machine to "appear" to have double the number of cores as the actual number of physical cores. It does this through sharing a core among two threads. It works well for non-computationally-intensive tasks. But MATLAB computations are always computationally intensive, and thus hyperthreading does not help.

Duncan Po
MathWorks

"Igor" wrote in message <itvja1$jld$1@newscl01ah.mathworks.com>...
> "Sebastiaan" wrote in message <itv2t1$2f9$1@newscl01ah.mathworks.com>...
> > The strange thing however, I cannot get Matlab to use all 8 threads. Not even with my old 2009b version, for which I was sure it used 8 before (default is 8 btw, but only 4 is used).
> >
> > My testcase:
> > A = rand(5000,5000);
> > B = A'*A;
> >
> > and look at the system CPU usage.
> >
> Hi Sebastiaan,
>
> I've got 50% CPU usage regardless of maxNumCompThreads(8) / maxNumCompThreads(4) too. (R2011a)

Subject: maxNumCompThreads default value limits performance R2011a

From: Igor

Date: 28 Jun, 2011 20:32:05

Message: 5 of 10

"Duncan Po" <Duncan.Po@mathworks.com> wrote in message <iud72c$a0b$1@newscl01ah.mathworks.com>...
... But MATLAB computations are always computationally intensive, and thus hyperthreading does not help.

Hi Duncan,
Thanks for your concern! Yes, I've got hypertreading enabled. Yet, it do accelerate computations ~50% (0.996887/0.627223). (my own mex file, compiled with Intel c++ compiler, with openMP parallelization)

See my "performance test" in thread's first post..

Thank you.

Subject: maxNumCompThreads default value limits performance R2011a

From: Sebastiaan

Date: 30 Jun, 2011 12:25:11

Message: 6 of 10

"Duncan Po" <Duncan.Po@mathworks.com> wrote in message <iud72c$a0b$1@newscl01ah.mathworks.com>...

> I think your machine has hyperthreading enabled. In R2011a, MATLAB detects your machine has hyperthreading, and thus scale down the number of threads to match the number of physical cores.

My CPU does not have hyperthreading (nor is there any way of disabling it).

Subject: maxNumCompThreads default value limits performance R2011a

From: Igor

Date: 30 Jun, 2011 13:16:10

Message: 7 of 10

"Sebastiaan" wrote in message <iuhpv6$4n8$1@newscl01ah.mathworks.com>...
> "Duncan Po" <Duncan.Po@mathworks.com> wrote in message <iud72c$a0b$1@newscl01ah.mathworks.com>...
> My CPU does not have hyperthreading (nor is there any way of disabling it).

"Sebastiaan" wrote in message <itv2t1$2f9$1@newscl01ah.mathworks.com>...
> Hi,
>
> I seem to be having the same problem. My CPU:
>
> Intel(R) Core(TM) i7 CPU Q 820 @ 1.73GHz

Em..
is this
http://ark.intel.com/Product.aspx?id=43124&wapkw=%28i7+820qm%29
your CPU?

All i7 CPUs got HyperTreading...

Subject: maxNumCompThreads default value limits performance R2011a

From: Sebastiaan

Date: 8 Jul, 2011 12:59:11

Message: 8 of 10

"Igor" wrote in message <iuhsup$dep$1@newscl01ah.mathworks.com>...
> "Sebastiaan" wrote in message <iuhpv6$4n8$1@newscl01ah.mathworks.com>...
> > "Duncan Po" <Duncan.Po@mathworks.com> wrote in message <iud72c$a0b$1@newscl01ah.mathworks.com>...
> > My CPU does not have hyperthreading (nor is there any way of disabling it).
>
> "Sebastiaan" wrote in message <itv2t1$2f9$1@newscl01ah.mathworks.com>...
> > Hi,
> >
> > I seem to be having the same problem. My CPU:
> >
> > Intel(R) Core(TM) i7 CPU Q 820 @ 1.73GHz
>
> Em..
> is this
> http://ark.intel.com/Product.aspx?id=43124&wapkw=%28i7+820qm%29
> your CPU?
>
> All i7 CPUs got HyperTreading...

Hmm, now I feel scammed, as I really was convinced I ordered 8 genuine cores. Also, which manufacturer does not allow disabling hyperthreading, even it is a laptop? (Well, it is a Dell.)

In that case, I withdraw my post: the way Matlab detects the number of usable cores has improved over the versions and now automatically only uses the real number of cores.

Subject: maxNumCompThreads default value limits performance R2011a

From: Igor

Date: 8 Jul, 2011 13:24:07

Message: 9 of 10

"Sebastiaan" wrote in message <iv6uuv$saq$1@newscl01ah.mathworks.com>...
> "Igor" wrote in message <iuhsup$dep$1@newscl01ah.mathworks.com>...
> > "Sebastiaan" wrote in message <iuhpv6$4n8$1@newscl01ah.mathworks.com>...
> > > "Duncan Po" <Duncan.Po@mathworks.com> wrote in message <iud72c$a0b$1@newscl01ah.mathworks.com>...
> > > My CPU does not have hyperthreading (nor is there any way of disabling it).
> >
> > "Sebastiaan" wrote in message <itv2t1$2f9$1@newscl01ah.mathworks.com>...

> In that case, I withdraw my post: the way Matlab detects the number of usable cores has improved over the versions and now automatically only uses the real number of cores.


In some cases this virtual cores may give you additional 50% boost, they are not useless...
See my first post in this tread..

Subject: maxNumCompThreads default value limits performance R2011a

From: Sebastiaan

Date: 8 Jul, 2011 13:43:07

Message: 10 of 10

 
> In some cases this virtual cores may give you additional 50% boost, they are not useless...
> See my first post in this tread..

I did not suggest it is, but the end-user should be in control, both in BIOS and Matlab.

I also strongly vote for official support for maxNumCompThreads function for many reasons.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us