Multi-core system

  • Follow


I'm running 64-bit Matlab R2009b on a multi-core Windows 7 machine.
It appears that nearly all the cpu time is on a single core. This is
in a program where almost all the computation time, according to the
profiler, is in a very few lines containing matrix operations.

So are there any settings I'm missing to make better use of the other
cores? Does it have anything to do with being on a 64-bit version of
Matlab?

I realize this is probably a faq, but the documentation is confusing.
In one spot the documentation says,

If you run MATLAB on a multiple-CPU system (multiprocessor or
multicore), use a new preference to enable multithreaded computation.
This can increase performance in MATLAB for element-wise and BLAS
library computations.

By default the preference is not set, so you must set it to enable
multithreaded computation. 

But in another it says,

Enabling Multithreaded Computation
Multithreaded computation in MATLAB is enabled by default. 

Thanks,
Dick Startz
0
Reply Richard 9/16/2010 6:29:02 PM

You can use the maxNumCompThreads command to inspect the number of threads that BLAS (the library that is responsible for matrix operations) is using. If this number is one, try setting, e.g., maxNumCompThreads(4) on a quad-core machine.

Note that if the matrices you're working on are very small, BLAS may not benefit much from your machine having multiple cores.
0
Reply Laurens 9/17/2010 2:12:06 AM


On Fri, 17 Sep 2010 02:12:06 +0000 (UTC), "Laurens "
<lvdmaaten@hotmail.com> wrote:

>You can use the maxNumCompThreads command to inspect the number of threads that BLAS (the library that is responsible for matrix operations) is using. If this number is one, try setting, e.g., maxNumCompThreads(4) on a quad-core machine.
>
>Note that if the matrices you're working on are very small, BLAS may not benefit much from your machine having multiple cores.

Thanks. The matrices were fairly small, so maybe that explains what I
was seeing.
0
Reply Richard 9/17/2010 1:43:02 PM


"Richard Startz" <richardstartz@comcast.net> wrote in message 
news:32s6965elj3nrqee474hfd1fq3813pb20n@4ax.com...
> On Fri, 17 Sep 2010 02:12:06 +0000 (UTC), "Laurens "
> <lvdmaaten@hotmail.com> wrote:
>
>>You can use the maxNumCompThreads command to inspect the number of threads 
>>that BLAS (the library that is responsible for matrix operations) is 
>>using. If this number is one, try setting, e.g., maxNumCompThreads(4) on a 
>>quad-core machine.
>>
>>Note that if the matrices you're working on are very small, BLAS may not 
>>benefit much from your machine having multiple cores.
>
> Thanks. The matrices were fairly small, so maybe that explains what I
> was seeing.

Indeed.  To take a concrete (if somewhat silly example), suppose you had two 
two-element vectors.

a = [1 2];
b = [3 4];

Now if we were to multithread the operation "c = a+b" then we would need to 
give one core the first element each of a and b and another core the second 
elements of each, and tell each core to perform their addition.  The 
overhead of splitting up the problem vastly outweighs any benefit you may 
have gained by performing the two additions simultaneously, so a problem 
that small is not multithreaded.

-- 
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on 
http://www.mathworks.com 

0
Reply slord (13282) 9/17/2010 2:24:57 PM

Richard Startz <richardstartz@comcast.net> wrote in message <32s6965elj3nrqee474hfd1fq3813pb20n@4ax.com>...
> On Fri, 17 Sep 2010 02:12:06 +0000 (UTC), "Laurens "
> <lvdmaaten@hotmail.com> wrote:
> 
> >You can use the maxNumCompThreads command to inspect the number of threads that BLAS (the library that is responsible for matrix operations) is using. If this number is one, try setting, e.g., maxNumCompThreads(4) on a quad-core machine.
> >
> >Note that if the matrices you're working on are very small, BLAS may not benefit much from your machine having multiple cores.
> 
> Thanks. The matrices were fairly small, so maybe that explains what I
> was seeing.

What exact size are they?  You *might* benefit from a custom mex routine that does the multiply inline instead of calling the BLAS library.

James Tursa
0
Reply James 9/17/2010 3:24:05 PM

Richard Startz <richardstartz@comcast.net> wrote in message <c2o496tf35pts1agvh3sdkea42nhd47f4o@4ax.com>...
> I'm running 64-bit Matlab R2009b on a multi-core Windows 7 machine.
> It appears that nearly all the cpu time is on a single core. This is
> in a program where almost all the computation time, according to the
> profiler, is in a very few lines containing matrix operations.
> 
> So are there any settings I'm missing to make better use of the other
> cores? Does it have anything to do with being on a 64-bit version of
> Matlab?
> 
> I realize this is probably a faq, but the documentation is confusing.
> In one spot the documentation says,
> 
> If you run MATLAB on a multiple-CPU system (multiprocessor or
> multicore), use a new preference to enable multithreaded computation.
> This can increase performance in MATLAB for element-wise and BLAS
> library computations.
> 
> By default the preference is not set, so you must set it to enable
> multithreaded computation. 
> 
> But in another it says,
> 
> Enabling Multithreaded Computation
> Multithreaded computation in MATLAB is enabled by default. 
> 
> Thanks,
> Dick Startz

See 

"Which MATLAB functions are multicore aware?
In order to write fully parallel programs in MATLAB you have a few choices but they are either hard work, expensive or both.  For example you could

Write parallel mex files using C and OpenMP
Drop a load of cash on the parallel computing toolbox from the Mathworks
Use the free parallel toolbox, pMATLAB"

at 

http://www.walkingrandomly.com/?p=1894

/ per
0
Reply per 9/17/2010 4:24:04 PM

On Fri, 17 Sep 2010 16:24:04 +0000 (UTC), "per isakson"
<poi.nospam@bimDOTkthDOT.se> wrote:

>Richard Startz <richardstartz@comcast.net> wrote in message <c2o496tf35pts1agvh3sdkea42nhd47f4o@4ax.com>...
>> I'm running 64-bit Matlab R2009b on a multi-core Windows 7 machine.
>> It appears that nearly all the cpu time is on a single core. This is
>> in a program where almost all the computation time, according to the
>> profiler, is in a very few lines containing matrix operations.
>> 
>> So are there any settings I'm missing to make better use of the other
>> cores? Does it have anything to do with being on a 64-bit version of
>> Matlab?
>> 
>> I realize this is probably a faq, but the documentation is confusing.
>> In one spot the documentation says,
>> 
>> If you run MATLAB on a multiple-CPU system (multiprocessor or
>> multicore), use a new preference to enable multithreaded computation.
>> This can increase performance in MATLAB for element-wise and BLAS
>> library computations.
>> 
>> By default the preference is not set, so you must set it to enable
>> multithreaded computation. 
>> 
>> But in another it says,
>> 
>> Enabling Multithreaded Computation
>> Multithreaded computation in MATLAB is enabled by default. 
>> 
>> Thanks,
>> Dick Startz
>
>See 
>
>"Which MATLAB functions are multicore aware?
>In order to write fully parallel programs in MATLAB you have a few choices but they are either hard work, expensive or both.  For example you could
>
>Write parallel mex files using C and OpenMP
>Drop a load of cash on the parallel computing toolbox from the Mathworks
>Use the free parallel toolbox, pMATLAB"
>
>at 
>
>http://www.walkingrandomly.com/?p=1894
>
>/ per

Thank you Per (also Steve and James.) I am mostly doing matrix
multiplies and inversions (or backslashes). A few lines get called a
lot. In my test programs the matrix sizes are much too small to be
multi-cored, but in some production runs that may change. So it's good
to know that Matlab will automatically do something reasonable in
terms of bringing in other cores.
-Dick Startz
0
Reply Richard 9/17/2010 9:46:00 PM

6 Replies
357 Views

(page loaded in 0.076 seconds)

Similiar Articles:













7/24/2012 12:28:12 AM


Reply: