Computational Cluster Programs

How to Use the BLAS Libraries on ATS-Hosted Clusters

BLAS Libraries

There are potentialy 4 different libraries that include the Basic Linear Algebra Subprograms (BLAS) routines on each ATS-Hosted Cluster. These libraries are:

BLAS library from the Netlib Repository
This library was compiled by ATS using the Intel Compiler or other high-performance Fortran compiler that was purchased for the cluster. This library is the simplest one to link to and use.
ATLAS library
When ATS built this library, it automatically optimized its performance for whatever system it was built on, in this case, these routines are optimized for the cluster compute nodes.
Intel-MKL library
The Intel-MKL library includes the BLAS routines. The Intel-MKL library performed very well in our benchmarks.
GNU Scientific Library (GSL)
GSL includes a C version of the BLAS routines.
For a comparison of these libraries see: ATS's BLAS benchmark.

Installed Locations

Installed locations:

  • The BLAS library from the Netlib Repository is installed in: /u/local/apps/blas/current.
  • The ATLAS library is installed in: /u/local/apps/atlas/current.
  • The Intel-MKL library is installed in: /u/local/compilers/intel/current/current/mkl
  • The GSL library is installed in: /u/local/apps/gsl/current.

How to run BLAS from a Fortran Program

To compile and link with the BLAS library from Netlib:

ifort pgm.f -L$BLAS_HOME -lblas

To compile and link with the ATLAS library:

ifort pgm.f -L$ATLAS_HOME -lf77blas -latlas

To compile and link with the Intel-MKL library please refer to the ATS's Intel-MKL page.

Note:
Replace pgm.f(90) with the name of the file containing your source code and pgm with the name of the executable to be created.
and:
Set BLAS_HOME to: /u/local/apps/blas/current
Set ATLAS_HOME to: /u/local/apps/atlas/current

How to run BLAS from a C program

To use the BLAS routines from GSL

In your program include the appropriate GSL header files as follows:

#include <gsl/gsl_blas.h>

To compile and link enter:

CC pgm.c -I$GSL_HOME/include -L$GSL_HOME/lib -lgsl -lgslcblas -lm [-static] -o pgm
Replace CC with either gcc or icc depending on which compiler you want to use. Replace pgm.c with the name of the file containing your source code and pgm with the name of the executable to be created. If you omit -static, you will have to set the LD_LIBRARY_PATH environmen variable at run time to include GSL_HOME/lib.

How to use a BLAS routine from Netlib, ATLAS or Intel-MKL

To use BLAS from a C program, replace ifort in the commands shown to compile with Fortran to icc and add an _ to the end of the subroutine name. For example to call sgemm code:

extern void sgemm_( char *, char *, int *, int *, int * float *, float *, int *, float *, int *, float *, float *, int * );
If you use gcc instead of icc, you additionally have to add:
-L/usr/lib/gcc/x86_64-redhat-linux/3.4.6 -lg2c
to the command used to compile and link.

How to run BLAS from a C++ program

To use BLAS from a C++ program you must declare each BLAS function you will call as being extern as in the following example:

extern "C" void sgemm_( char *, char *, int *, int *, int * float *, float *, int *, float *, int *, float *, float *, int * );
code the function name (with _ appended) and the argument list for the function you are calling.

To compile and link, replace ifort in the command with icpc.