FFT inside parfor loop on a multi-core computer does not accelerate
조회 수: 24 (최근 30일)
이전 댓글 표시
Hello,
I am trying to accelerate my code involving lots of FFT-s by putting it inside a parfor loop. All calculations in the loop are completely independent, and I don't see any error messages about non-classifyable variables. When I use 12 workers on my 12-core machine to run this parfor loop, I see that first 15-20 runs go very fast: it takes about 0.8 s to run a parfor loop. But then, calculation time begins to vary from a run to a run, from 0.8 s to 19 s, although these runs are completely equivalent in terms of computation load.
I am aware that FFT is multi-threaded and runs on many cores, so the communication overhead might interfere with parallelization in parfor. Then it is unclear to me why first 20 runs are so fast. I am using sliced arrays, for both input and output, and output arrays are only changed inside the parfor loop and not run-to-run, so there is no accumulating of the data to be communicated between workers.
If I use a standard for-loop instead of parfor, then calculation time stays very stable, around 4.5 s, which is much longer that initial 0.8s for parfor. Task manager shows that in this case all cores are pretty busy, with about 97% of the total CPU load. When I use parfor, the load is only about 50-60%, and it is still faster.
Any hint is really appreciated! -Thanks
답변 (2개)
Jason Ross
2012년 1월 26일
Is your core count really 12, or are those hyper-threaded cores? If they are hyperthreaded, try with actual number of cores.
Also, take a look at your memory utilization. Are you swapping?
댓글 수: 2
Jason Ross
2012년 1월 26일
Great. I would concur that you shouldn't be swapping, but you should be able to verify with Task Manager. The CPU load points to the CPUs waiting on something or other, disk access was the first thing that popped into mind, especially as something may have accumulated that would consume memory.
Konrad Malkowski
2012년 2월 1일
Is your parfor code inside of a function or a script? If it is inside of a script, please convert it to a function call. In general the performance of functions is in general faster than the performance of scripts.
Also does your code include any clear statements inside of code called by parfor?
참고 항목
카테고리
Help Center 및 File Exchange에서 Parallel for-Loops (parfor)에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!