Slow computation time of parfor loop
1 view (last 30 days)
Show older comments
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 Comments
Alvaro
on 26 Jan 2023
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.
Answers (1)
Alvaro
on 26 Jan 2023
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 Comments
See Also
Categories
Find more on Parallel for-Loops (parfor) in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!