Skip to Main Content

How to use ATLAS on maya


ATLAS (Automatically Tuned Linear Algebra Software) is an optimized implementation of the BLAS library, and also contains some routines from LAPACK. On this page, we will show how to start using it on maya. Before you begin, make sure to read the tutorial for compiling C programs. Note that the code on this page has been tested with the Intel compiler.

BLAS Example: Matrix Multiply

Consider three matrices Am×k, Bk×n, and Cm×n, where all are represented as double precision floating point numbers. We will demonstrate the use of the “dgemm” function which computes


We will take α=1 and β=0 to compute the simple matrix multiplication C=AB. MKL has several versions of this function; we will use “cblas_dgemm”, which has bit friendlier “C-style” interface than other variants.

The most important line in the code is

cblas_dgemm(CblasColMajor, CblasNoTrans, CblasNoTrans,
   m, n, k, 1.0, A, m, B, k, 0.0, C, m);

Also notice in the Makefile that locations to OpenBLAS headers and libraries are specified. Because we are using the “dynamic” OpenBLAS module, we can compile once on the user node and run on any compute node.

#SBATCH --job-name=atlas
#SBATCH --output=slurm.out
#SBATCH --error=slurm.err
#SBATCH --partition=develop


Download: ../code/atlas/matrix-multiply/run.slurm

[araim1@maya-usr1 matrix-multiply]$ make
mpicc  -O3 -std=c99   -c -o matrix-multiply.o matrix-multiply.c
mpicc  -O3 -std=c99   matrix-multiply.o -o matrix_multiply  -lm -lcblas -L/usr/lib64/atlas
[araim1@maya-usr1 matrix-multiply]$
[araim1@maya-usr1 atlas]$ cat slurm.err 
[araim1@maya-usr1 atlas]$ cat slurm.out
Matrix A (3 x 5) is:
  1.0000  0.7290  0.5314  0.3874  0.2824
  0.9000  0.6561  0.4783  0.3487  0.2542
  0.8100  0.5905  0.4305  0.3138  0.2288

Matrix B (5 x 4) is:
  1.0000  0.5905  0.3487  0.2059
  0.9000  0.5314  0.3138  0.1853
  0.8100  0.4783  0.2824  0.1668
  0.7290  0.4305  0.2542  0.1501
  0.6561  0.3874  0.2288  0.1351

Matrix C (3 x 4) = AB is:
  2.5543  1.5083  0.8906  0.5259
  2.2989  1.3575  0.8016  0.4733
  2.0690  1.2217  0.7214  0.4260
[araim1@maya-usr1 atlas]$