Matlab with dual core uses only 50% cpu (R2010b, Intel Core 2 duo T9300)

3 ビュー (過去 30 日間)
Johan
Johan 2011 年 3 月 14 日
I'm doing a finite difference simulation with matlab which takes around 15 minutes at this moment. When looking at the resource monitor of Windows 7 (32 bit), I see matlab never uses more than 50% of the cpu.
I'm using Matlab R2010b. The computer is a HP with a Intel core 2 duo T9300, 2.5GHz 4GB RAM, of which 3GB is usable (due to 32bit Windows 7)
The question is, how can I make the computer use 100% of its computing power so I can run my simulations faster?
In Windows I already turned all power saving options off, but this didn't help.

採用された回答

Sarah Wait Zaranek
Sarah Wait Zaranek 2011 年 3 月 14 日
It depends which version of MATLAB you are using. MATLAB started including multithreaded functions in R2007a. I believe multithreading was always supported on all platforms.
By R2009a, multithreading became a startup option (-singleCompThread ). Before then, it could toggled in the preferences. As for a list of the functions that are multithreaded, look here:
This list hasn't been updated for the last 2 releases so you can add the following functions:
  • fft for long vectors
  • The two-input form of conv2
  • Integer conversion and arithmetic
For your particular case, you may not be using many of these functions and/or large enough matrices to see much of a difference. You may want to explore using the Parallel Computing Toolbox.
  3 件のコメント
Cris Luengo
Cris Luengo 2011 年 3 月 14 日
You might want to look into "vectorizing" your code, substituting the loops over x and y by matrix operations. Matrix operations are multi-threaded. For example, "for x=1:10, a(x)=b(x)*c(x); end" uses only one processor core, but "a(1:10)=b(1:10).*c(1:10);" uses up to 10 cores.
Walter Roberson
Walter Roberson 2011 年 3 月 14 日
Matrix operations are only multi-threaded if they are "big enough".

サインインしてコメントする。

その他の回答 (3 件)

the cyclist
the cyclist 2011 年 3 月 14 日
From poking around on Google, I gather that there is a multithreading option in Preferences, but that not all MATLAB functions will multithread.
Not sure on this, and I cannot check because I don't think these options exist on a Mac, which is what I use.
  1 件のコメント
Johan
Johan 2011 年 3 月 14 日
The multithreading option in preferences was removed in newer Matlab versions (starting in 2009 if I'm correct) Anyway, in R2010b it is not there. Instead it is enabled by default. I checked this using the command 'maxNumCompThreads' from which I get the answer 2.

サインインしてコメントする。


Jason Ross
Jason Ross 2011 年 3 月 14 日
Keep in mind also that "computing power" is not measured by CPU alone. If you look in Resource Monitor, examine the disk, memory and network connection metrics, as well.
For example, if you are accessing data from a network it's entirely possible that you could be waiting on that operation to complete and the CPU has no data to process.

Richard Crozier
Richard Crozier 2011 年 3 月 17 日
Have a look at the multicore package on the file exchange to speed up computation using multiple cores.

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by