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

4 vues (au cours des 30 derniers jours)
Tobias Nitschke
Tobias Nitschke le 10 Mai 2016
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 commentaire
Tobias Nitschke
Tobias Nitschke le 31 Mai 2016
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).

Connectez-vous pour commenter.

Réponses (1)

Ahmed Rashid
Ahmed Rashid le 31 Mai 2016
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.

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by