Skip to content

Some Dependencies

LAPACK & BLAS

Two of the most commonly used computational libraries are LAPACK and BLAS. They are super fast in doing linear algebra operations involving matrices and vectors.

  • BLAS (Basic Linear Algebra Subprograms) are routines that provide standard building blocks for performing basic vector and matrix operations.
  • LAPACK (Linear Algebra PACKage) is written in Fortran 90 and provides routines for solving systems of simultaneous linear equations, least-squares solutions of linear systems of equations, eigenvalue problems, and singular value problems.
  • BLAS is needed in LAPACK. BLAS & LAPACK can be installed separately. First, you have to install BLAS before LAPACK, because LAPACK needs it. Download the packages from the following websites. (see here and here)
  • BLAS, see [http://www.netlib.org/blas/]
  • LAPACK, see [http://www.netlib.org/lapack/]
  • Or can install LAPACK by cmake, where soureCode LAPACK also includes BLAS

install LAPACK with cmake

  • see CMAKE options in file CMakeLists.txt,
  • This way also install BLAS, CBLAS, LAPACKE, set -DCBLAS=on -DLAPACKE=on
tar -xvf lapack-3.10.0.tar.gz
cd lapack-3.10.0
mkdir build && cd build
module load tool_dev/cmake-3.21
module load compiler/gcc-11.2
export PATH=/uhome/p001cao/local/app/compiler/gcc-11.2/bin:$PATH
export CC=gcc  export CXX=g++  export FC=gfortran
export LD_LIBRARY_PATH=/uhome/p001cao/local/app/compiler/gcc-11.2/lib64:$LD_LIBRARY_PATH

export myInstallDIR=/uhome/p001cao/local/app/lapack-3.10

cmake .. -DCBLAS=on -DLAPACKE=on \
-DCMAKE_INSTALL_LIBDIR=${myInstallDIR} \
-DCMAKE_INSTALL_INCLUDEDIR=${myInstallDIR}

make -j 8
make install

usage

export myLAPACK=/uhome/p001cao/local/app/lapack-3.10/liblapack.a
export myLAPACKE=/uhome/p001cao/local/app/lapack-3.10/liblapacke.a
export myBLAS=/uhome/p001cao/local/app/lapack-3.10/libblas.a
export myCBLAS=/uhome/p001cao/local/app/lapack-3.10/libcblas.a

ScaLAPACK

ScaLAPACK (Scalable LAPACK) is a library of high-performance linear algebra routines for parallel distributed memory machines. ScaLAPACK can be used as a replacement for both LAPACK and BLAS

  • Installing ScaLAPACK needs BLAS, LAPACK and BLACS libraries. (BLACS now included inside ScaLAPACK)
  • ScaLAPACK now only supports MPI.
  • Installation docs of ScaLAPACK here
  • Some guide here
  • SouceCode
  • see CMAKE options in file CMakeLists.txt
Note

ScaLAPACK just be compiled by MPI compilers

Download

cd /home1/p001cao/local/wSourceCode/tooldev
git clone -b tags/v2.2.1 https://github.com/Reference-ScaLAPACK/scalapack.git ScaLAPACK-2.2.1
cd ScaLAPACK-2.2.1
mkdir build && cd build
  • Or download release
tar -xvf scalapack-2.1.0.tar.gz
cd scalapack-2.1.0
mkdir build && cd build

self-build BLAS and LAPACK

module load tooldev/cmake-3.24
module load mpi/ompi4.1.x-clang14

export PATH=/home1/p001cao/local/app/openmpi/4.1.x-clang14/bin:$PATH
export CC=mpicc  export CXX=mpic++  export F90=mpif90 export F77=mpif77
cmake .. -DUSE_OPTIMIZED_LAPACK_BLAS=on \
-DCMAKE_C_COMPILER=mpicc -DCMAKE_Fortran_COMPILER=mpifort \
-DCMAKE_INSTALL_PREFIX=/home1/p001cao/local/app/tooldev/ScaLAPACK-2.2

make -j 16 && make install

preinstall BLAS and LAPACK

export myLAPACK=/uhome/p001cao/local/app/lapack-3.10/liblapack.a
export myBLAS=/uhome/p001cao/local/app/lapack-3.10/libblas.a

cmake .. -DBLAS_LIBRARIES=${myBLAS} -DLAPACK_LIBRARIES=${myLAPACK} \
-DCMAKE_C_COMPILER=mpicc -DCMAKE_Fortran_COMPILER=mpifort \
-DCMAKE_INSTALL_PREFIX=/home1/p001cao/local/app/tooldev/ScaLAPACK-2.2

Some options if errors

export CFLAGS="-Ofast -march=x86-64"
export FFLAGS="-Ofast -march=x86-64 -fallow-argument-mismatch"
export FFLAGS="-std=legacy"

Module file

set     topdir          /home1/p001cao/local/app/tooldev/ScaLAPACK-2.2

prepend-path    LD_LIBRARY_PATH     $topdir/lib
prepend-path    PKG_CONFIG_PATH     $topdir/lib/pkgconfig

OpenBLAS

OpenBLAS is an open source optimized BLAS (Basic Linear Algebra Subprograms) library based on GotoBLAS2 1.13 BSD version.

  • Installation here
  • SouceCode
  • see CMAKE options in file CMakeLists.txt
- to create dynamic link (file *.so), use: -DBUILD_SHARED_LIBS=yes
git clone https://github.com/xianyi/OpenBLAS.git
cd OpenBLAS
mkdir build && cd build
  • Or download release
tar -xvf OpenBLAS-0.3.19.tar.gz
cd OpenBLAS-0.3.19
mkdir build && cd build

UCS 2

module load tool_dev/cmake-3.20.3
module load mpi/ompi5.0.0-gcc11.2

cmake .. -DCMAKE_INSTALL_PREFIX=/home1/p001cao/local/app/tool_dev/openBLAS-0.3.19

make -j 16 && make install
## Usage
export myBLAS=/home1/p001cao/local/app/tool_dev/openBLAS-0.3.19/lib64/libopenblas.a
cmake .. -DBLAS_LIBRARIES=${myBLAS} -DLAPACK_LIBRARIES=${myBLAS} \