Using the Intel Math Kernel Library (MKL)
The Scilab binary package includes openblas for blas and lapack routines.
The MKL is faster and allows parallel computation, but I found few instructions
on the internet on how to link. The procedure described here makes
it possible to switch between different blas/lapack libraries by
setting an environment variable.
Creating MKL shared object with blas and lapack routines
Instructions are given in the Developer Guide for Intel oneAPI Math
Kernel Library Linux on building custom shared objects:
# 01-Aug-2024, see lilo8:/vol/thchem/lib/oneapi/sequential/job1.sh
# Copy the lists of blas and lapack routines to include in shared object
rsync -v /vol/opt/intel/oneapi/mkl/2023.2.0/tools/builder/{makefile,blas_example_list,lapack_example_list} .
# Merge the lists
cat blas_example_list lapack_example_list > blas_lapack_list
# Select intel compilers environment
module add mkl/latest
# Output:
# Loading mkl version 2023.2.0
# Loading tbb version 2021.10.0
# Loading compiler-rt version 2023.2.1
# Loading mkl/latest
# Loading requirement: tbb/latest compiler-rt/latest
# Create shared object
make libintel64 export=blas_lapack_list interface=lp64 threading=sequential name=libblas_lapack_mkl_sequential
# This creates shared object:
-rwxr-x--- 1 gerritg thchem 66627032 Aug 2 13:08 libblas_lapack_mkl_.so
# To make sure this shared object is use for blas and lapack under several
# possible names set a number of soft links:
for lib in libblas.so.3 libopenblas.so.0 libopenblas_pthreads.so.0 liblapack.so.3 liblapack.so.3gf
do
ln -sf libblas_lapack_mkl_$SP.so "$lib"
done
# For the parallel version of MKL use "threading=parallel" (and directory ../oneapi/parallel etc)
Linking MKL to Scilab
The script to start Scilab is in this directory:
cd /vol/thchem/scilab-2024.1.0/bin
# Make a copy of the bash script that starts scilab:
cp scilab scilab-mkl
# Edit scilab-mkl. Search for "export LD_LIBRARY_PATH"
# This occur on line 675 and on line 839. Just before line 839 add:
export LD_LIBRARY_PATH=${SCI_LD_PATH:+$SCI_LD_PATH:}$LD_LIBRARY_PATH
# Look up "bash shell parameter expansion" for an explanation: if
# $SCI_LD_PATH is not set, $LD_LIBRARY_PATH is not modified
To run Scilab with the MKL library:
# SCI_LD_PATH is the directory
export SCI_LD_PATH=/vol/thchem/lib/oneapi/sequential
/vol/thchem/scilab-2024.1.0/bin/scilab-mkl
It is also possible to switch between versions using the runscilab6 bash script,
which is part of the gsci_lib6 library.
Technical details on the scilab command in where it links blas/lapack
Understanding these details should not be necessary to use Scilab,
but it may be helpful in case of trouble.