Blas

The BLAS (Basic Linear Algebra Subprograms) are routines that provide standard building blocks for performing basic vector and matrix operations [1].

Module

If you need to build software the lists BLAS as a dependency, it is sufficient to load the module. List the available versions:

module spider blas

Output:

--------------------------

  blas: blas/3.7.0

--------------------------

...

See how to load the version you need:

module spider blas/<version>

Load any required modules that are reported by the spider command, and then load the blas module:

module load blas/<version>

Compiling

If you are writing code that uses BLAS routines, you will need to load the module as detailed above, and include the appropriate compiler flags. Below we use the C interface to BLAS in a short program demonstrating compiling and linking:

Example

Adapted from [2]. Add the following source to a file named "example.c":

#include<stdlib.h>

#include<stdio.h>

#include "cblas.h"


int main() {

  float X = 1.2;

  float Y = 2.3;

  printf("Before Swap: X=%f, Y=%f\n", X, Y);

  cblas_sswap(1, &X, 1, &Y, 1);

  printf("Post Swap  : X=%f, Y=%f\n", X, Y);

}


Compile using the command:

gcc example.c -o example -lcblas

Test by running the generated executable:

./example

Before Swap: X=1.200000, Y=2.300000

Post Swap  : X=2.300000, Y=1.200000

References