BLAS and LAPACK

Introduction

There are several versions of BLAS (Basic Linear Algebra Subprograms) and LAPACK (Linear Algebra PACKage) numerical libraries installed on the system. Currently, there are four versions, Intel’s Maths Kernel Library (MKL) library, AMD’s Core Maths Library (ACML), Automatically Tuned Linear Algebra Software (ATLAS) and the original Netlib. All these libraries, aside from Netlib, are optimised to run on the available hardware. Netlib is only installed for completeness.

Setting the module environment

All available modules can be listed via the module avail command. Numerical libraries will be listed under the /apps/Modules/libraries heading.CHECK-code
To load a specific library, e.g. MKL:


$ module load mkl
to switch to another version of the libraries, e.g. ACML:

$ module switch mkl acml
This will load the appropriate libraries and paths for your chosen compiler and bit environments.

Compiler Flags

To simplify linking to the various versions of the numerical libraries, loading the modules as described above will also set up customised environmental variables, $ARC_LINALG_FFLAGS for use with Fortran and $ARC_LINALG_CFLAGS for C. For the multi-threaded versions of the libraries use $ARC_LINALG_MT_FFLAGS for Fortran and $ARC_LINALG_MT_CFLAGS for C.

Fortran

For instance, to compile a simple Fortran program, named matmul.f90 for example, with the MKL library, first load the module:


$ module load mkl
and to compile the code, with the default Intel compiler use:

$ ifort -o matmul matmul.f90 $ARC_LINALG_FFLAGS
To switch to the PGI compiler and a different version of the libraries, e.g. ATLAS:

$ module switch intel pgi
$ module switch mkl atlas
To compile and link to the libraries use:

$ pgf90 -o matmul matmul.f90 $ARC_LINALG_FFLAGS

C

To compile a simple C program, named matmul.c for example with the MKL library, first load the module:


$ module load mkl
and to compile the code, with the default Intel compiler use:

$ icc -o matmul matmul.c $ARC_LINALG_CFLAGS
To switch to the PGI compiler and a different version of the libraries, e.g. ATLAS:

$ module switch intel pgi
$ module switch mkl atlas
To compile and link to the libraries use:

$ pgcc -o matmul matmul.f90 $ARC_LINALG_CFLAGS