Skip to content

LAPACK

Standard software library for linear algebra.


LAPACK requires an environment module

In order to use LAPACK, you must first load the appropriate environment module:

module load gnu

As described in the LAPACK website:

LAPACK is written in Fortran 90 and provides routines for solving systems of simultaneous linear equations, least-squares solutions of linear systems of equations, eigenvalue problems, and singular value problems.

The associated matrix factorizations (LU, Cholesky, QR, SVD, Schur, generalized Schur) are also provided, as are related computations such as reordering of the Schur factorizations and estimating condition numbers. Dense and banded matrices are handled, but not general sparse matrices. In all areas, similar functionality is provided for real and complex matrices, in both single and double precision.

LAPACK builds off of BLAS routines to provide more complex linear algebra operations as aforementioned.

Using LAPACK on HPC Cluster#

On the HPC cluster, LAPACK can be used by linking your source code to the various LAPACK libraries located in /usr/lib64.

Once linked, you can utilize various LAPACK subroutines. Below we have a simple example of compiling, linking and running some LAPACK routines.

1
2
3
[USER@h22-login-25 ~]$ module load gnu
[USER@hpc-login-39 ~]$ gfortran 
lapack_d_test.f90 -llapack

Here we are compiling a lapack test file. Upon executing the command "./a.out", the user should get output which, shows the successful testing of a number of the LAPACK subroutines.

Note

When considering LAPACK type operations one can also use ATLAS, OpenBLAS, and MKL. ATLAS is provided in "C and Fortran77 interfaces to a portably efficient BLAS implementation". OpenBLAS provides an "opensource implementation of BLAS with many hand-crafted optimizations for specific processor types".

All of these libraries are provided in the /usr/lib64 directory.

Finally, MKL "is a library of optimized math routines for science, engineering, and financial applications" which uses BLAS and LAPACK. This is only available in the intel compiler. You must therefore run the intel module through the command module load intel.

Then, you can link all appropriate libraries and options through the following commands:

1
2
3
4
5
[USER@h22-login-25 ~]$ module load intel
[USER@h22-login-25 ~]$ icc -g mklBLAS.c -DMKL_ILP64 
-openmp -L/gpfs/research/software/intel/new/mkl/lib/lib64 
-lmkl_intel_ilp64 -lmkl_core -lmkl_intel_thread -lmkl_blas95_ilp64    
-lmkl_blacs_ilp64 -lpthread -lm
1
2
3
4
icc mklBLAS.o -DMKL_ILP64 -openmp 
-L/gpfs/research/software/intel/new/mkl/lib/lib64 
-lmkl_intel_ilp64 -lmkl_core -lmkl_intel_thread -lmkl_blas95_ilp64 
-lmkl_blacs_ilp64 -lpthread -lm

Additional Resources#