Uppsala Multidisciplinary Center for Advanced Computational Science

How can I use BLAS/LAPACK routines?

For the PGI compiler, both LAPACK and BLAS are inlcuded in the AMD Core Math Library (ACML) that comes with the PGI-compiler.
To use the compiler you must do module load pgi.

For Fortran programs it is enough to link with "-lacml" to get access to the routines

pgf90 -o test.x test.f90 -lacml

For C programs you should also include the acml include file which requires that you give the appropriate -I flag to the compiler. Use "which pgcc" to find out the proper path to the compiler/libraries and documentation.

For the Intel compiler, you can also use the Intel MKL (Math Kernel Library). The user documentation to this can most easily be found by loading the intel module:

module load intel

then issue "which ifort", which gives you the path to the compiler, for instance for the compiler /sw/comp/intel/Compiler/compilerpro-, the documentation can be found in /sw/comp/intel/Compiler/compilerpro-

The version of the mkl to link to depends on whether you want the sequential version, or the threaded version. For MPI programs you should typically use the sequential version if the program performs multiple calls to the blas/lapack routines. You must also know what size of integers your program uses. If you do not give special compiler options, your program will normally use 32 bit integers, 64 bit longs, and 64 bit pointers. This is termed lp64, and you should for a sequential version of mkl link your program with:

ifort -o test.x test.f90 -lmkl_intel_lp64 -lmkl_sequential -lmkl_core

and for a threaded mkl link with

ifort -o test.x test.f90 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread