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

1 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by