OpenBLAS

Guidance last updated: 20 October 2026

OpenBLAS provides optimised implementations of the Basic Linear Algebra Subprograms (BLAS) and LAPACK routines.

Documentation: https://www.openmathlib.org/OpenBLAS/docs/user_manual/

Usage

After connecting to Stanage (see Establishing a SSH connection), start an interactive session:

salloc

You may load one of the following OpenBLAS modules. This also loads the matching GCC compiler; choose a build matching your application:

module load OpenBLAS/0.3.32-GCC-15.2.0
module load OpenBLAS/0.3.30-GCC-14.3.0
module load OpenBLAS/0.3.27-GCC-13.3.0
module load OpenBLAS/0.3.24-GCC-13.2.0
module load OpenBLAS/0.3.23-GCC-12.3.0
module load OpenBLAS/0.3.21-GCC-12.2.0

Matrix multiplication example

Download openblas-example.c into your job directory. It multiplies two small matrices using the CBLAS interface, checks the result, then checks a larger matrix product.

The following example batch submission script compiles and runs the program with two CPUs:

#!/bin/bash
#SBATCH --partition=sheffield
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=2
#SBATCH --mem-per-cpu=1000
#SBATCH --time=00:05:00

set -euo pipefail
cd "$SLURM_SUBMIT_DIR"
export SLURM_EXPORT_ENV=ALL
module load OpenBLAS/0.3.32-GCC-15.2.0
gcc openblas-example.c -o openblas-example -fopenmp -lopenblas64_ -lm
export OMP_NUM_THREADS="$SLURM_CPUS_PER_TASK"
srun ./openblas-example

Save the script as openblas.slurm and submit it with sbatch openblas.slurm. The small matrix product should be [[19, 22], [43, 50]].

This OpenBLAS build uses OpenMP for threading. Set OMP_NUM_THREADS to the CPUs requested per task; OPENBLAS_NUM_THREADS controls non-OpenMP builds instead. If your application already parallelises work across independent processes, use one BLAS thread per process unless you have allocated additional CPUs per task.

The example uses the 64-bit integer interface supplied by OpenBLAS/0.3.32-GCC-15.2.0: its cblas.h declares names such as cblas_dgemm64_, which match libopenblas64_. Use the supplied header and its blasint type rather than declaring BLAS functions yourself. For this module, pkg-config openblas selects a library that does not match these headers, so the example links -lopenblas64_ explicitly.

Installation notes

OpenBLAS was installed using Easybuild, build details can be found in $EBROOTOPENBLAS/easybuild with a given module loaded.

Direct dependencies for latest version of OpenBLAS