Why was row (rather than column) pivoting chosen for LU factorisation? #1224
Replies: 5 comments 1 reply
-
|
A few things come to mind:
|
Beta Was this translation helpful? Give feedback.
-
|
Thanks @mgates3! The thing that jumps out to me from your comments is that the pivot search will be faster when searching a column rather than a row (with a column major matrix), so there is a trade-off (that I was not aware of before!) is between efficient column/row searches vs. efficient row/column swaps. For my application the pivot searches are parallelised (ScaLAPACK-style). I wonder if that tips the balance for me towards wanting to optimise the row/column swaps, as the pivot searches are done in parallel on smaller segments. I will have to benchmark more, but now have a better idea what to look out for when making changes. |
Beta Was this translation helpful? Give feedback.
-
|
After some experimentation with 'equivalent' implementations that use row swaps or column swaps, the row-swap version that LAPACK uses seems more efficient (roughly 2x). I suspect it might be related to the 'recursive algorithm' where the memory layouts that occur in the row-swap version are a bit more efficient. The time for pivot searches does not seem to be a significant part of the run time. |
Beta Was this translation helpful? Give feedback.
-
|
Another detail about column swaps is that the permutation appears on the right hand side. in case you want to use this in linear solves (which is why mostly LU is for), it would convert the problems to a permuted solve. Permutations are sometimes not needed for the solves until some goal is achieved (say a parametric solve for many RHS). And permuted solves are not as cache friendly. Even if you remove the recursion overhead for small problems (see https://github.com/ilayn/semicolon-lapack/blob/main/src/d/dgetrf2.c as an example that uses CBLAS interface) I don't think you can make it as fast as the unpermuted solve. |
Beta Was this translation helpful? Give feedback.
-
|
@ilayn but with row swaps, you still have to permute the right hand side before the solve. Why is permuting the solution after the solve slower than permuting the right hand side before the solve? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Does anyone know why LAPACK designers chose to use row-pivoting rather than column-pivoting in the LU factorisation algorithm? I would have thought that when using a column-major matrix format it would be cheaper to swap columns than to swap rows, and as far as I could see (although my brief googling failed to find a reference with a definitive-sounding statement) row pivoting or column pivoting are as good as each other from a numerical stability point of view (anyone know if that is true?).
I'm interested because for various reasons I'm implementing a parallelised LU solver, and considering switching from row pivoting to column pivoting for efficiency. I am wondering if I am missing some reason why this is a bad idea, so interested in the original design decision in LAPACK (or any other thoughts/opinions on this issue).
Beta Was this translation helpful? Give feedback.
All reactions