1

I am making use of a partial pivoting function by the name of gesv. To get the libraries to make this happen in C++ I used a one line command from Installing BLAS and LAPACK packages.

sudo apt-get install libblas-dev liblapack-dev

Then I was able to link the libraries by adding the following to the compile instructions

g++ main.cpp -llapack -lblas

I got tremendous speed up on my laptop (Linux 2020), but when I started running on a cluster the method is extremely slow when running the same (large) case. I don't think both of the libraries are installed on the cluster. The code runs, so it seems like whichever one provides the speed increase is not on the cluster I am using.

Is it possible to build and then link the lapack and blas libraries by "hand" rather than doing the apt-get command?

Thank you for your time.

1 Answer 1

3

BLAS

  • Download the latest version of BLAS

  • Open a terminal and go to the directory where you have it saved

tar -xvf blas-3.8.0.tgz  # unzip the blas source files
cd BLAS-3.8.0/ 
make
mv blas_LINUX.a libblas.a
mv *.a path/to/lib  # move the blas lib to the library you will be including at compile

LAPACK

  • Download the latest version of LAPACK
tar -xvf lapack-3.9.0.tar.gz
cd lapack-3.9.0/
cp make.inc.example make.inc  # use example make as make
make
cp *.a path/to/lib

Now that the libraries have been built, and are stored in path/to/lib, the short example code in the question can be compiled.

g++ main.cpp -L/path/to/lib -llapack -lblas -lgfortran  # compiles the code
./a.out  # runs the code

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .