Cpu usage in parrallel running mode

3 visualizaciones (últimos 30 días)
ARMIN M
ARMIN M el 10 de Ag. de 2019
Comentada: ARMIN M el 19 de Ag. de 2019
Hi. I have code that running in parrallel mode. I have 4 worker(my cpu has 2 core) but when i run it, it shows that cpu fluctuate from 2 to 24 % but physical memory is in 96%(2×30% , 1×20,2×10%) ,anybody knows why cpu does not show more usage ;like 90%?thank you.

Respuesta aceptada

Walter Roberson
Walter Roberson el 17 de Ag. de 2019
Editada: Walter Roberson el 17 de Ag. de 2019
Have a look at the attached modified version of your code and see if it does what you want. I am not confident that my changes match your intention.
I did some optimizations in the first parfor, but not in the second one (no point doing that until we know that the first part is acceptable.)
... Be careful you do not remove your own good copy of the file before you are sure that my revised version is right!
  12 comentarios
Walter Roberson
Walter Roberson el 18 de Ag. de 2019
I corrected a minor typing mistake -- I think I had accidentally written "id" in one place where I meant "it".
Using parpool(2) is better since parpool(4) does not improve your performance.
ARMIN M
ARMIN M el 19 de Ag. de 2019
Thank u a lot. So i had understood correct. Sorry two more question 1.i want to simplify the output of this code as much as possible, how can i do this? 2.getting factors of output, takes a lot of time. what can i do to Decrease time of running?

Iniciar sesión para comentar.

Más respuestas (1)

Nicolas B.
Nicolas B. el 12 de Ag. de 2019
Hello Armin,
It is already strange that you have 4 workers for a 2 physical cores CPU. Normally, Matlab runs 1 worker per hardware core. So hyperthreading has no impact on the number of workers.
Looking at your use of RAM (96%), I guess that your PC has to use the swap memory which is running on your harddrive and is much more slower. Therefore, if the access to the memory is slow, your CPU will not be used at 100% (bottleneck principle).
If you want to reach the 100% use of your CPU, I may recommand you to add some RAM on your PC. Otherwise, try to reduce the number of workers.
  7 comentarios
Walter Roberson
Walter Roberson el 17 de Ag. de 2019
Near line 256 you calculate
det_A=sum(H,2)
This is the last place you use H, so if the value of this det_A is not used then you have no reason to calculate H.
Then you do
F(1,iiii)=a4*det(A_4);
which does not use det_A . You do not use det_A anywhere inside that loop.
You
After the loop, you do some more calculations to build the rest of F, and assign into det_A based on F -- the previous det_A going unused.
ARMIN M
ARMIN M el 17 de Ag. de 2019
Hello walter .thank u . Yes .you say right. It should be F(1,iiii)=a4*det_A, actually this code calculated det(A) twice. Which takes more time to complete. thank you.

Iniciar sesión para comentar.

Categorías

Más información sobre Parallel Computing Fundamentals en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by