I know that ATLAS is able to optimize itself for the machine it is compiled on and thus maximum benefits are found by compiling from source. Is there any benefit to compiling LAPACK from source? It would be much easier to just install the prebuilt package.
-
$\begingroup$ It may be worth trying this technique to see just why time is being spent. I've found, if I'm working a lot with not-large matrices, the library routines spend over half of their time classifying their input character flags, and other input classification, so you might get a lot of speedup by augmenting the library with a few well-chosen hand-coded routines. $\endgroup$– Mike DunlaveyJun 18, 2013 at 18:58
3 Answers
OpenBlas is quite fast, so you can link it to LAPACK. Have you tried precompiled version of LAPACK/BLAS from your CPU vendor? For example AMD ACML (free) or Intel MKL (free on linux for non-commercial and non-academic use)? You simply need to unpack and run install file.
In my opinion the only advantage of using ATLAS is then when you use some unusual CPU. Otherwise use the one from CPU vendor. Also there are nVIDIA CUDA and AMD OpenCL versions available which really rock.
EDIT: remember that you can always build an Ubuntu DEB package from source which is usually much easier than compiling software from source.
-
$\begingroup$ I think I'm going to go with your suggestion and install MKL. Also thanks for the tip on building DEB packages, I wasn't aware that was possible. $\endgroup$– OSEJun 10, 2013 at 18:05
-
2$\begingroup$ Remember that you need to configure ld (dynamic libraries linker to be able to find those libs). BLAS and LAPACK from Intel MKL is in the
libmkl_rt.so
file usually linked using:-L/opt/intel/mkl/lib/intel64 -lmkl_rt
$\endgroup$– MiseryJun 10, 2013 at 18:21 -
2$\begingroup$ One should point out that Intel's noncommercial license has gotten more and more restrictive with each release, to the point where they are now very explicit about academic use not being covered by it as soon as you are getting any money for your research. $\endgroup$ Jun 11, 2013 at 9:06
-
$\begingroup$ Yest that is worth mentioning. However one can test it for free :] And if it proves useful, it isn't the most expensive thing in the world. $\endgroup$– MiseryJun 11, 2013 at 10:14
The repository package is not safe to use with threading due to the way it was compiled. I reported the bug on the Lapack forum, but it will take a long time for workarounds or solutions to trickle down into the repository. If you compile it yourself, be sure to add the "-frecursive" to gfortran.
In my experience, the best way to use blas/lapack on recent versions of ubuntu is to use the packaged openblas.
For what it's worth, I mostly use blas/lapack through python numpy/scipy, and using openblas speeds up some of the linear algebra by like 200x vs. the default. I've tried using custom ATLAS, but it was a huge pain and didn't give much if any speedup vs. openblas, but I might have been doing it wrong.