Cpu usage in parrallel running mode

11 ビュー (過去 30 日間)
ARMIN M
ARMIN M 2019 年 8 月 10 日
コメント済み: ARMIN M 2019 年 8 月 19 日
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.

採用された回答

Walter Roberson
Walter Roberson 2019 年 8 月 17 日
編集済み: Walter Roberson 2019 年 8 月 17 日
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 件のコメント
Walter Roberson
Walter Roberson 2019 年 8 月 18 日
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 2019 年 8 月 19 日
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?

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

その他の回答 (1 件)

Nicolas B.
Nicolas B. 2019 年 8 月 12 日
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 件のコメント
Walter Roberson
Walter Roberson 2019 年 8 月 17 日
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 2019 年 8 月 17 日
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.

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

カテゴリ

Help Center および File ExchangeParallel Computing Fundamentals についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by