Lapack compilation

From Docswiki
Jump to navigation Jump to search

I had some problems using the atlas modules, which seem to be not applicable to all machines (e.g. 64-bit P4s). I compiled my own lapack routines (available from [1]. Their documentation is wrong in certain places, but it's kind of obvious what paths they refer to. As Catherine notes, it's not worth doing much tuning, so I just used the bog-standard f77 configuration. I installed it in ~/src/lib/lapack-3.1.1:

jss43@keiko:~/src/lib> wget -O - http://www.netlib.org/lapack/lapack.tgz | tar xvzf -  # Download and extract to lapack-3.1.1
jss43@keiko:~/src/lib> cd lapack-3.1.1
jss43@keiko:~/src/lib/lapack-3.1.1> cp make.inc.example make.inc        # Use g77 configuration.  Other examples exist in the INSTALL directory.
jss43@keiko:~/src/lib/lapack-3.1.1> make                                # A (cursory) glance at the docs implies this makes everything (including BLAS).
[reams of output]
g77: ../../blas_LINUX.a: No such file or directory                      # FIBBERS!
jss43@keiko:~/src/lib/lapack-3.1.1> cd BLAS/SRC && make && cd -         # Fine, we'll make BLAS ourselves...
jss43@keiko:~/src/lib/lapack-3.1.1> make                                # ...and finish the job.

The last make command takes a while to run, so it's worth having a cup of tea as you wait. (You can avoid the error in the middle by editing the Makefile.)

The makefile also runs tests which passed. The libraries are blas_LINUX.a and lapack_LINUX.a, so we can link to them to give them more standard names:

jss43@keiko:~/src/lib/lapack-3.1.1> ln -s lapack_LINUX.a liblapack.a
jss43@keiko:~/src/lib/lapack-3.1.1> ln -s blas_LINUX.a libblas.a

These can now be used in compilation by using:

 -L ~/src/lib/lapack-3.1.1 -llapack -lblas 

in the link line. This is somewhat platform dependent though, so we can make it even easier to use by using enviroment modules to reduce the link line to:

-llapack -lblas

ADDENDUM: Actually, not so straightfoward. I found using zdotc caused a segmentation fault. Some google-fu implied this might be due to how g77 and gfortran return values from routines, and causes problems with 4 routines. Catherine, Greg: did you have this issue?

Anyway, I re-compiled using the INSTALL/make.inc.gfortran as the make.inc. I had to do make cleanall, which is different from make clean. zdotc no longer caused any issues.

Catherine 09:49, 7 July 2008 (BST) I haven't encountered that, but we gave up supporting ATLAS other than by providing the precompiled binaries about the time gfortran succeeded g77 and I haven't tried building it since, so I expect I'd get the same thing.