Last active
April 27, 2024 01:07
-
-
Save gramian/cd245d7dea271bcaae9967c93327429a to your computer and use it in GitHub Desktop.
Build Octave and numerical dependencies from source in Ubuntu 20.04
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# project: build_oct | |
# version: 1.12 (2023-01-01) | |
# authors: C. Himpe (0000-0003-2194-6754), M. Koehler (0000-0003-2338-9904) | |
# license: BSD-2-Clause License (opensource.org/licenses/BSD-2-Clause) | |
# summary: Build Octave and numerical dependencies from source (in Ubuntu 20.04 with GCC >= 10.3). | |
# requires hardware: either X86-64 with AVX2 or ARM64 with NEON. | |
# requires software packages: octave libpcre2-dev libreadline-dev libgmp3-dev libmpfr-dev libfreetype6-dev libgl2ps-dev libfontconfig1-dev libglu1-mesa-dev | |
# add to .bashrc: alias oct='export OMP_NUM_THREADS=5; $HOME/BUILT/bin/octave-cli' | |
DEST="$HOME/opt/OCTAVE" | |
NJOBS=5 | |
XJOBS="-j${NJOBS}" | |
OPTIM="-O3" | |
case `uname -m | head -c3` in | |
x86) | |
OPTIM="$OPTIM -m64 -mavx2 -mfma -march=native -mtune=native -mfpmath=sse -malign-data=cacheline -ftree-vectorize -fno-semantic-interposition" | |
;; | |
arm) | |
OPTIM="$OPTIM -mcpu=native -floop-optimize -falign-loops -falign-labels -falign-functions -falign-jumps" | |
;; | |
esac | |
FLAGS="$OPTIM -fomit-frame-pointer -I$DEST/include -L$DEST/lib -Wl,-rpath=$DEST/lib -pipe" | |
LINK="-L$DEST/lib -Wl,-rpath=$DEST/lib" | |
ALLOC="-fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free -lmimalloc" | |
FLEXI="-lflexiblas -L$DEST/lib" | |
declare -A AMIMALLOC=( [TAR]="mimalloc.tar.gz" [LNK]="https://github.com/microsoft/mimalloc/archive/v" [VER]="1.7.9" ) | |
declare -A AOPENBLAS=( [TAR]="openblas.tar.gz" [LNK]="https://github.com/xianyi/OpenBLAS/archive/v" [VER]="0.3.21" ) | |
declare -A AFLEXIBLAS=( [TAR]="flexiblas.tar.gz" [LNK]="https://github.com/mpimd-csc/flexiblas/archive/v" [VER]="3.2.1" ) | |
declare -A AQRUPDATENG=( [TAR]="qrupdate.tar.gz" [LNK]="https://github.com/mpimd-csc/qrupdate-ng/archive/v" [VER]="1.1.5" ) | |
declare -A ASUITESPARSE=( [TAR]="suitesparse.tar.gz" [LNK]="https://github.com/DrTimothyAldenDavis/SuiteSparse/archive/v" [VER]="5.13.0" ) | |
declare -A AARPACKNG=( [TAR]="arpack.tar.gz" [LNK]="https://github.com/opencollab/arpack-ng/archive/" [VER]="3.8.0" ) | |
declare -A ASUNDIALS=( [TAR]="sundials.tar.gz" [LNK]="https://github.com/LLNL/sundials/archive/v" [VER]="6.5.0" ) | |
declare -A AOCTAVE=( [TAR]="octave.tar.gz" [LNK]="https://ftp.gnu.org/gnu/octave/octave-" [VER]="7.3.0" ) | |
# Setup destination | |
install -d -m 755 "${DEST}" | |
install -d -m 755 "${DEST}/include" | |
install -d -m 755 "${DEST}/lib" | |
install -d -m 755 "${DEST}/share" | |
install -d -m 755 "${DEST}/man" | |
install -d -m 755 "${DEST}/bin" | |
ln -sf "${DEST}/lib" "${DEST}/lib64" | |
export PATH="${DEST}/bin":${PATH} | |
## MIMALLOC | |
wget -nc -O ${AMIMALLOC[TAR]} ${AMIMALLOC[LNK]}${AMIMALLOC[VER]}.tar.gz | |
tar -xf ${AMIMALLOC[TAR]} && cd $(tar -tf ${AMIMALLOC[TAR]} | grep -m1 /) | |
mkdir -p build && cd build && | |
cmake .. -DCMAKE_INSTALL_PREFIX=$DEST -DCMAKE_C_FLAGS="$FLAGS" -DCMAKE_CXX_FLAGS="$FLAGS" && | |
make $XJOBS && | |
make install | |
cd .. | |
cd .. | |
## OPENBLAS | |
wget -nc -O ${AOPENBLAS[TAR]} ${AOPENBLAS[LNK]}${AOPENBLAS[VER]}.tar.gz | |
tar -xf ${AOPENBLAS[TAR]} && cd $(tar -tf ${AOPENBLAS[TAR]} | grep -m1 /) | |
sed -i "s/COMMON_OPT = -O2/COMMON_OPT = -O3/g" Makefile.system | |
make $XJOBS CFLAGS="$FLAGS $ALLOC -fPIC" CXXFLAGS="$FLAGS $ALLOC -fPIC" FFLAGS="$FLAGS -fPIC" && | |
make PREFIX=$DEST install && | |
cd .. | |
## FLEXIBLAS | |
wget -nc -O ${AFLEXIBLAS[TAR]} ${AFLEXIBLAS[LNK]}${AFLEXIBLAS[VER]}.tar.gz | |
tar -xf ${AFLEXIBLAS[TAR]} && cd $(tar -tf ${AFLEXIBLAS[TAR]} | grep -m1 /) | |
mkdir -p build && cd build && | |
cmake .. -DCMAKE_C_FLAGS="$FLAGS $ALLOC" -DCMAKE_CXX_FLAGS="$FLAGS $ALLOC" -DCMAKE_Fortran_FLAGS="$FLAGS" -DCMAKE_LD_FLAGS="$LINK" \ | |
-DCMAKE_INSTALL_PREFIX=$DEST \ | |
-DEXTRA="OPENBLAS" \ | |
-DOPENBLAS_LIBRARY="$DEST/lib/libopenblas.so;gfortran;gomp;m"\ | |
-DFLEXIBLAS_DEFAULT=OPENBLAS && | |
make $XJOBS && | |
make install && | |
cd .. | |
cd .. | |
## QRUPDATENG | |
wget -nc -O ${AQRUPDATENG[TAR]} ${AQRUPDATENG[LNK]}${AQRUPDATENG[VER]}.tar.gz | |
tar -xf ${AQRUPDATENG[TAR]} && cd $(tar -tf ${AQRUPDATENG[TAR]} | grep -m1 /) | |
mkdir -p build && cd build && | |
cmake .. -DCMAKE_C_FLAGS="$FLAGS $ALLOC" -DCMAKE_CXX_FLAGS="$FLAGS $ALLOC" -DCMAKE_Fortran_FLAGS="$FLAGS" -DCMAKE_LD_FLAGS="$LINK" \ | |
-DCMAKE_INSTALL_PREFIX=$DEST \ | |
-DBUILD_SHARED_LIBS=ON \ | |
-DBLAS_LIBRARIES=$DEST/lib/libflexiblas.so \ | |
-DLAPACK_LIBRARIES=$DEST/lib/libflexiblas.so && | |
make $XJOBS && | |
make install && | |
cd .. | |
cd .. | |
## SUITESPARSE | |
wget -nc -O ${ASUITESPARSE[TAR]} ${ASUITESPARSE[LNK]}${ASUITESPARSE[VER]}.tar.gz | |
tar -xf ${ASUITESPARSE[TAR]} && cd $(tar -tf ${ASUITESPARSE[TAR]} | grep -m1 /) | |
sed -i "s/( cd GraphBLAS/#( cd GraphBLAS/g" Makefile # CHECK ON UPDATE | |
sed -i "351s/.*/ LDLIBS += -lrt -L\$(INSTALL_LIB)/" SuiteSparse_config/SuiteSparse_config.mk # CHECK ON UPDATE | |
make JOBS=${NJOBS} $XJOBS library CFLAGS="$FLAGS $ALLOC" CXXFLAGS="$FLAGS $ALLOC" FFLAGS="$FLAGS" LDFLAGS="$LINK" BLAS="$FLEXI" LAPACK="$FLEXI" && | |
make install INSTALL=$DEST BLAS="$FLEXI" LAPACK="$FLEXI" CFLAGS="$FLAGS $ALLOC" CXXFLAGS="$FLAGS $ALLOC" FFLAGS="$FLAGS" LDFLAGS="$LINK" && | |
cd .. | |
## SUNDIALS | |
wget -nc -O ${ASUNDIALS[TAR]} ${ASUNDIALS[LNK]}${ASUNDIALS[VER]}.tar.gz | |
tar -xf ${ASUNDIALS[TAR]} && cd sundials-${ASUNDIALS[VER]} | |
mkdir -p build && cd build && | |
cmake .. -DCMAKE_INSTALL_PREFIX=$DEST \ | |
-DCMAKE_C_FLAGS_RELEASE="$FLAGS $ALLOC" \ | |
-DCMAKE_CXX_FLAGS_RELEASE="$FLAGS $ALLOC" \ | |
-DCMAKE_Fortran_FLAGS_RELEASE="$FLAGS" \ | |
-DCMAKE_LD_FLAGS="$LINK" \ | |
-DCMAKE_BUILD_TYPE=Release -DEXAMPLES_INSTALL_PATH=$DEST/examples \ | |
-DENABLE_LAPACK=ON -DLAPACK_LIBRARIES=$DEST/lib/libflexiblas.so \ | |
-DENABLE_KLU=ON -DKLU_INCLUDE_DIR=$DEST/include -DKLU_LIBRARY_DIR=$DEST/lib \ | |
-DENABLE_OPENMP=ON && | |
make $XJOBS && | |
make install && | |
cd .. | |
cd .. | |
## ARPACKNG | |
wget -nc -O ${AARPACKNG[TAR]} ${AARPACKNG[LNK]}${AARPACKNG[VER]}.tar.gz | |
tar -xf ${AARPACKNG[TAR]} && cd $(tar -tf ${AARPACKNG[TAR]} | grep -m1 /) | |
mkdir -p build && cd build && | |
cmake .. -DCMAKE_C_FLAGS="$FLAGS $ALLOC" -DCMAKE_CXX_FLAGS="$FLAGS $ALLOC" -DCMAKE_Fortran_FLAGS="$FLAGS" \ | |
-DCMAKE_INSTALL_PREFIX=$DEST \ | |
-DBUILD_SHARED_LIBS=ON \ | |
-DBLAS_LIBRARIES="$FLEXI" \ | |
-DLAPACK_LIBRARIES="$FLEXI" && | |
make $XJOBS && | |
make install && | |
cd .. | |
cd .. | |
## OCTAVE | |
wget -nc -O ${AOCTAVE[TAR]} ${AOCTAVE[LNK]}${AOCTAVE[VER]}.tar.gz | |
tar -xf ${AOCTAVE[TAR]} && cd $(tar -tf ${AOCTAVE[TAR]} | grep -m1 /) | |
./configure CFLAGS="$FLAGS $ALLOC" CXXFLAGS="$FLAGS $ALLOC" FFLAGS="$FLAGS" LDFLAGS="$LINK" --prefix=$DEST \ | |
--disable-java --disable-gui --without-qt \ | |
--with-blas="$FLEXI" --with-lapack="$FLEXI" \ | |
--with-qrupdate-includedir=$DEST/include --with-qrupdate-libdir=$DEST/lib \ | |
--with-arpack-includedir=$DEST/include --with-arpack-libdir=$DEST/lib \ | |
--with-klu-includedir=$DEST/include --with-klu-libdir=$DEST/lib \ | |
--with-sundials_ida-includedir=$DEST/include --with-sundials_ida-libdir=$DEST/lib \ | |
--with-sundials_nvecserial-includedir=$DEST/include --with-sundials_nvecserial-libdir=$DEST/lib \ | |
--with-sundials_sunlinsolklu-includedir=$DEST/include --with-sundials_sunlinsolklu-libdir=$DEST/lib \ | |
--with-umfpack-includedir=$DEST/include --with-umfpack-libdir=$DEST/lib \ | |
--with-cxsparse-includedir=$DEST/include --with-cxsparse-libdir=$DEST/lib \ | |
--with-cholmod-includedir=$DEST/include --with-cholmod-libdir=$DEST/lib \ | |
--with-ccolamd-includedir=$DEST/include --with-ccolamd-libdir=$DEST/lib \ | |
--with-colamd-includedir=$DEST/include --with-colamd-libdir=$DEST/lib \ | |
--with-camd-includedir=$DEST/include --with-camd-libdir=$DEST/lib \ | |
--with-amd-includedir=$DEST/include --with-amd-libdir=$DEST/lib \ | |
--with-suitesparseconfig-includedir=$DEST/include --with-suitesparseconfig-libdir=$DEST/lib && | |
make $XJOBS && | |
make install PREFIX=$DEST | |
cd .. | |
exit 0 |
You're right. flexiblas-3.0.4
builds and make test
passes, but
~/BUILT/SuiteSparse-5.10.1/sundials-5.8.0/build $ cmake ..
-- SUNDIALS_GIT_VERSION:
-- Using int64_t for indices
-- Determining Fortran name-mangling scheme... OK
Appending C RELEASE flags
Appending Fortran RELEASE flags
-- Looking for LAPACK libraries... OK
-- LAPACK_LIBRARIES: /home/jwscook/BUILT/lib/libflexiblas.so
-- Skipped LAPACK tests, assuming LAPACK works with SUNDIALS. Set LAPACK_WORKS=FALSE to (re)run compatibility test.
CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
Could NOT find KLU (missing: KLU_LIBRARY KLU_LIBRARIES)
Call Stack (most recent call first):
/usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
cmake/tpl/FindKLU.cmake:94 (find_package_handle_standard_args)
cmake/tpl/SundialsKLU.cmake:48 (find_package)
cmake/SundialsSetupTPLs.cmake:103 (include)
CMakeLists.txt:168 (include)
-- Configuring incomplete, errors occurred!
That's all I've got time for until Monday, I'm afraid.
Alright.
The first thing that strikes me as odd is the path ~/BUILT/SuiteSparse-5.10.1/sundials-5.8.0/build $
. I suggest to make a fresh folder, place the build_oct.sh
inside and re-run it; Sundials should not have been built below SuiteSparse. I assume SuiteSparse already failed to built?
Either installing libpcre3-dev
or starting again from a new directory as suggest worked. Thanks again :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sorry, I cannot reproduce this on my system. Could you check if the sundials package was successfully built?