BLAS

Linear Algebra Library

Introduction

From the BLAS homepage ( http://www.netlib.org/blas/ ) :

The BLAS (Basic Linear Algebra Subprograms) are routines that provide standard building blocks for performing basic vector and matrix operations. The Level 1 BLAS perform scalar, vector and vector-vector operations, the Level 2 BLAS perform matrix-vector operations, and the Level 3 BLAS perform matrix-matrix operations. Because the BLAS are efficient, portable, and widely available, they are commonly used in the development of high quality linear algebra software, LAPACK for example.

Use BLAS on HPC cluster

BLAS library can be linked to fortran code. Using an example from BLAS docmuntation we can compile and link a BLAS library located in

/usr/lib64

To run a Simple example (found at http://www.netlib.org/blas/sblat1 ), download the blas test file from the documentation and compile with the following command:

[fsuID_at_hpc-login-39 ~]$ gfortran sblat1.F -lblas

Which compiles and links the entire BLAS library which will give the following output upon execution:

[fsuID_at_hpc-login-39 ~]$ ./a.out   
Real BLAS Test Program Results

Test of subprogram number  1             SDOT 
 ----- PASS -----

Test of subprogram number  2            SAXPY 
 ----- PASS -----

Test of subprogram number  3            SROTG 
----- PASS -----

Test of subprogram number  4             SROT 
----- PASS -----

Test of subprogram number  5            SCOPY 
----- PASS -----

Test of subprogram number  6            SSWAP 
----- PASS -----

Test of subprogram number  7            SNRM2 
----- PASS -----

Test of subprogram number  8            SASUM 
----- PASS -----

Test of subprogram number  9            SSCAL 
----- PASS -----

Test of subprogram number 10            ISAMAX
----- PASS -----

Note

Though BLAS is originally in fortran one can use its sub-routines in c. These are incorporated in the ATLAS libraries.

When considering BLAS 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

/usr/lib64

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,

[fsuID_at_hpc-login-39 ~]$ icc -g mklBLAS.c -DMKL_ILP64 
-openmp -L/panfs/storage.local/opt/intel/new/mkl/lib/lib64 
-lmkl_intel_ilp64 -lmkl_core -lmkl_intel_thread -lmkl_blas95_ilp64    
-lmkl_blacs_ilp64 -lpthread -lm

and,

icc mklBLAS.o -DMKL_ILP64 -openmp 
-L/panfs/storage.local/opt/intel/new/mkl/lib/lib64 
-lmkl_intel_ilp64 -lmkl_core -lmkl_intel_thread -lmkl_blas95_ilp64 
-lmkl_blacs_ilp64 -lpthread -lm

For a reference to linking information for mol the reader is referred to the resource https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor