Skip to content

BLAS

Linear Algebra Library


As described in their website, 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."

Using 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 here), download the BLAS test file from the documentation and compile with the following command (We have found that the compilation sometimes produces warnings but it will not affect the final output):

[fsuID_at_hpc-login-39 ~]$ module load gnu
[fsuID_at_hpc-login-39 ~]$ gfortran sblat1.f -lopenblas

The syntax above 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 -----