It has been suggested that using Octave with OpenBLAS compiled in my own computer (rather than precompiled OpenBLAS from repositories) will make the computations faster. I installed GNU Octave (4.2.2) from repositories using apt, and compiled the latest release of OpenBLAS from https://www.openblas.net/.
How to make Octave use this OpenBLAS?
What I have tried so far.
After compiling OpenBLAS, I installed it in opt/openblas
.
Then I entered the commands
sudo update-alternatives --install /usr/lib/libblas.so libblas.so /opt/openblas/lib/libopenblas.so 50
sudo update-alternatives --install /usr/lib/libblas.so.3 libblas.so.3 /opt/openblas/lib/libopenblas.so 50
sudo update-alternatives --install /usr/lib/liblapack.so liblapack.so /opt/openblas/lib/libopenblas.so 50
sudo update-alternatives --install /usr/lib/liblapack.so.3 liblapack.so.3 /opt/openblas/lib/libopenblas.so 50
Then I configured to use the new OpenBLAS with
update-alternatives --config libblas.so
update-alternatives --config libblas.so.3
update-alternatives --config liblapack.so
update-alternatives --config liblapack.so.3
Finally I ran Octave with the new OpenBLAS, but got this error.
$ LD_PRELOAD=/opt/openblas/lib/libopenblas.so octave-cli
octave-cli: symbol lookup error: /usr/lib/x86_64-linux-gnu/libblas.so.3: undefined symbol: gotoblas
Best Answer
I would recommend to start with all the stuff from Ubuntu repository. First thing to try is to install
libopenblas-base
package and allow it to provide BLAS and LAPACK alternative, as simple as:Using our test script we have the following timings for Octave on my i7-3537u:
libblas3
,liblapack3
libopenblas-base
from repositoryIf you want to optimize it even more - compile the OpenBLAS locally by:
And this will change benchmark results to:
libopenblas-base
self-compiledSo it is not useful to compile the optimized library with additional manual optimization.
Conclusion: I'll recommend to optimize your Octave code first by avoiding for-loops and using vectorized functions as much as possible. This will increase performance tremendously.