Why does my fft2 only use 1-3 instead all my 8 cores?

1 回表示 (過去 30 日間)
Tobias Nitschke
Tobias Nitschke 2016 年 5 月 10 日
回答済み: Ahmed Rashid 2016 年 5 月 31 日
I am running Matlab(R2015b) 64bit and I am doing a simulation where most of the computational time goes to fft2 and ifft2. The documentation reads
'[...] numerical functions such as fft, […] are multithreaded in MATLAB. Multithreaded computations have been on by default in MATLAB since Release 2008a. These functions automatically execute on multiple computational threads in a single MATLAB session, allowing them to execute faster on multicore-enabled machines.'
But obviously the computer I am using can't use all of its cores (see screenshots).
A minimal example of my code looks like this:
Nx=64;
Ny=2^18;
psi=rand(Nx,Ny);
psik=zeros(Nx,Ny);
fftw('planner','patient');
for i=1:100
psik(:,:)=fftshift(fft2(psi(:,:)));
end
When I increase the size of the bigger dimension by a factor 2, the problem gets even more obvious:
By searching in the internet I have only found someone with the same question. But his question was not answered ( http://de.mathworks.com/matlabcentral/answers/258370-how-to-run-fft-on-multi-core-without-parallel-computational-toolbox ). What can I do to fully use all available cores?
Regards
Tobias Nitschke
  1 件のコメント
Tobias Nitschke
Tobias Nitschke 2016 年 5 月 31 日
I have directly mailed at the support and got an answer from there. After some more testing I relized that my computer uses a little more than one core. The graphs shown at my graphics probably result from using the beginning of fftw. When I increase the smaller dimension my computer uses more CPU. Anyway I still haven't fully understood why the computer does not use its full power (all cores).

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

回答 (1 件)

Ahmed Rashid
Ahmed Rashid 2016 年 5 月 31 日
You can set the maximum number of threads using the command
maxNumCompThreads(number_of_threads)
If you want to see how many threads Matlab creates, you can type
maxNumCompThreads
By default it is equal to the number of cores that you have.

カテゴリ

Help Center および File ExchangeFourier Analysis and Filtering についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by