Setup Armadillo with openblas
OpenBLAS includes not-only BLAS (multithreaded) but also LAPACK (copy from Netlib).
git clone git://github.com/xianyi/OpenBLAS.git
cd OpenBLAS/
git checkout develop # Dev branch, usually stable. 'master' branch is release branch
make
PREFIX=$HOME/foss/installed/openblas make install
It is recommended to turn-off CPU throttling before you compile. Other tweaking you could do (disable shared library, disable CPU affinity in Linux (not recommended!), etc.):
setfreq.sh 1.5GHz
TARGET=NEHALEM USE_THREAD=1 NO_AFFINITY=1 NO_SHARED=1 COMMON_OPT=" -O2 -march=native " make
- Download from homepage
- Move it to the folder where you want to install it.
- Run
./configure - Don't run make!
- Edit the first few lines of
armadillo/include/config.hppso that it resembles something like:
#define ARMA_USE_LAPACK
#define ARMA_USE_BLAS
// #define ARMA_USE_WRAPPERAll this just means that we'll link to BLAS & LAPACK explicitly, so that Armadillo needn't create a wrapper for them. Keep the rest of the contents of config.hpp as it is.
That's all!
You can run some examples from Armadillo itself, just link with OpenBLAS explicitly:
cd armadillo/examples/
g++ -I ../include -I$HOME/openblas/include -L$HOME/openblas/lib -o example1 example1.cpp -lopenblas
g++ -I ../include -I$HOME/openblas/include -L$HOME/openblas/lib -o example2 example2.cpp -lopenblas
You must also include the LDFLAGS and INCLUDES for Boost library if they are in non-standard locations.
However, to run the executable, you must adjust LD_LIBRARY_PATH:
export LD_LIBRARY_PATH=$HOME/openblas/lib
./example2
If you want to get rid of this, just use static libraries, but make sure to pass -static -pthread -lgfortran:
g++ -static -pthread -I ../include -I$HOME/openblas/include -L$HOME/openblas/lib \
-o example2 example2.cpp -lopenblas -lgfortran
./example2