Does compiling PETSc with an external BLAS/LAPACK library significantly affect performance on sparse matrices, or does it only use those libraries for dense matrix math?

  • $\begingroup$ You can use LU for preconditioning. $\endgroup$
    – stali
    May 25, 2012 at 19:38

1 Answer 1


PETSc uses BLAS for a few vector primitives, but these are generally limited by memory bandwidth and there isn't much variance in "optimization", so it tends not to make much performance difference.

It also uses Lapack for some analysis such as Lanczos or Arnoldi estimates of eigenvalues and singular values, but these are generally not performance-sensitive.

Dense "level 3" operations generally only appear in a performance-sensitive context when using sparse direct solvers from third-party libraries (e.g. MUMPS, SuperLU, UMFPACK), in which case fill eventually leads to dense problems that are large enough to benefit from calling BLAS.

If you rely on these sparse direct solvers applied to large problems, then it's worth building with a tuned BLAS implementation, otherwise it makes very little difference.

  • $\begingroup$ Jed, how does PETSc use LAPACK for eigen/singular values estimation in case of distributed matrices? Is it then block-wise routine or ScaLAPACK? $\endgroup$
    – Alexander
    May 26, 2012 at 7:19
  • $\begingroup$ The Arnoldi iteration generates a Hessenberg matrix of dimension equal to the number of iterations (say 30 or 100). The eigen- or singular values of the Hessenberg matrix is computed redundantly on each process using LAPACK. This is much faster than trying to do it in parallel since the sizes are small and the data is already redundantly distributed. Similar for Lanczos. $\endgroup$
    – Jed Brown
    May 26, 2012 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.