Slow computation time of parfor loop
1 回表示 (過去 30 日間)
古いコメントを表示
Hello,
I need help to optimize the following parallel loop
parfor k=1:N
[Laux{k}, Uaux{k}, Paux{k}, Qaux{k}] = lu(Jtot{k})
end
The computation time of the above loop takes
Elapsed time is 3.569814 seconds.
Jtot contains sparse matrix of ~40k x 40k size in each cell.
I simply tried the following code
Jtot2=Jtot{1}
parfor k=1:N
[Laux, Uaux, Paux, Qaux] = lu(Jtot2)
end
Elapsed time is 0.749602 seconds.
,and then i also tried this one
Jtot2=Jtot{1}
parfor k=1:N
[Laux{k}, Uaux{k}, Paux{k}, Qaux{k}] = lu(Jtot2)
end
Elapsed time is 2.593602 seconds.
It seems like large size of Jtot, and resulted LU decompositions brings the issue.
I've also tried spmd but it was still slow.
spmd(N)
[Laux, Uaux, Paux, Qaux] = lu(Jtot{labindex})
end
The sequential matrix inversion process has to be followed after the parallel loop, so the results of each cell decomposition of Jtot need to be stored.
How can i reduce the computation time? i wish to decrease it not more than ~1sec.
Thank you in advance
3 件のコメント
Alvaro
2023 年 1 月 26 日
How long does this take to run in serial? At the moment it is not clear why you need a faster computing time than 1 second per parfor loop.
回答 (1 件)
Alvaro
2023 年 1 月 26 日
If you wish to parallelize, lu already has built-in support for running in thread-based environments.
Alternatively, you could consider slicing your matrix or working with distributed arrays.
Consider also the thresh parameter in lu which might decrease calculation time at the expense of accuracy.
0 件のコメント
参考
カテゴリ
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!