Cpu usage in parrallel running mode
10 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
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
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.
更多回答(1 个)
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
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Parallel Computing Fundamentals 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!