156.1. openblas-0.3.34
Optimised BLAS and LAPACK library
0.3.34-1 · BSD-3-Clause · 16.8 SBU · 37.7 MiB, 20 files · 41_system, 54 of 1047 · ports/core/sci-libs/openblas
Homepage: https://www.openblas.net/
Why it is in KDOS. The comment above it in script/phases/41_system/packages.d/sci-libs.txt:
DYNAMIC_ARCH is the OPPOSITE of
kdos march's discipline and is right here for one reason: OpenBLAS carries a kernel per microarchitecture and picks by cpuid at RUNTIME. That is the dispatch musl closes off everywhere else, and upstream has maintained it for twenty years.
OpenBLAS is an optimised implementation of BLAS, the basic dense linear algebra routines, with LAPACK built on top of it in the same library. It is the one BLAS and LAPACK in KDOS: there is no reference lapack, blas or cblas port, so numpy, scipy, octave, R, gsl, qrupdate and the rest of the numerical ports all land their matrix work here.
Required by (17): arpack-ng, bcftools, calculix, ceres-solver, gsl, highs, libggml, numpy, octave, opencv, qrupdate, R, scipy, suitesparse, sundials, translatelocally, xnec2c.
Sources: openblas-0.3.34.tar.gz (24.2 MiB). Every step kpkg takes applies to this port.
Install: script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install openblas'
build.sh:
make \
DYNAMIC_ARCH=1 \
TARGET=CORE2 \
USE_OPENMP=0 \
USE_THREAD=1 \
NUM_THREADS=64 \
NO_STATIC=1 \
NO_AFFINITY=1 \
FC=gfortran
make \
DYNAMIC_ARCH=1 \
TARGET=CORE2 \
USE_OPENMP=0 \
USE_THREAD=1 \
NUM_THREADS=64 \
NO_STATIC=1 \
NO_AFFINITY=1 \
FC=gfortran \
PREFIX=/usr DESTDIR=$PKG install
ln -sf libopenblas.so $PKG/usr/lib/libblas.so
ln -sf libopenblas.so $PKG/usr/lib/libblas.so.3
ln -sf libopenblas.so $PKG/usr/lib/liblapack.so
ln -sf libopenblas.so $PKG/usr/lib/liblapack.so.3
ln -sf libopenblas.so $PKG/usr/lib/libcblas.so
DYNAMIC_ARCH=1— Compile a kernel set for each x86-64 processor family OpenBLAS knows (Prescott, Core2, Nehalem, Haswell, Zen, SkylakeX, Sapphire Rapids and the rest) into the one library, and choose among them bycpuidwhen it is loaded. This is the run-time dispatch the tree’s rule asks for wherever upstream offers it; a build for one processor would be a machine-specific build, which iskdos march’s choice and not the recipe’s.TARGET=CORE2— The processor assumed for the code outside the per-family kernels. Upstream advises setting it withDYNAMIC_ARCH=1to the oldest model expected: left out, the common code is compiled for the build machine and can die with an illegal instruction on a weaker one before it reaches a kernel.USE_THREAD=1,USE_OPENMP=0— Thread the library with its own pthreads server rather than OpenMP. With threading on, OpenBLAS also takes its own locks, so several threads of one program may call it at once.NUM_THREADS=64— The most threads the library will run, fixed at build time; a program may ask for fewer at run time. Upstream warns that a large value costs memory for internal structures even when fewer threads are used.NO_STATIC=1— Install nolibopenblas.a.NO_AFFINITY=1— Never pin OpenBLAS’s threads to cores. Upstream’s default; it notes that pinning can lock a calling program’s threads onto the same cores, with NumPy and R named as programs it has hurt.FC=gfortran— The Fortran compiler. With one, the LAPACK half is compiled from its Fortran sources; with none found, OpenBLAS falls back to a C translation of LAPACK. gfortran comes with gcc.
Libraries: libblas.so, libcblas.so, liblapack.so, libopenblas.so, libopenblasp-r0.3.34.so.
Directories: /usr/lib/cmake/openblas, /usr/share/licenses/openblas.
The five links build.sh makes after the install, libblas.so, libblas.so.3, liblapack.so, liblapack.so.3 and libcblas.so, all point at libopenblas.so. Consumers look the libraries up by those names: without the links a configure script that tests -lblas or -llapack reports no BLAS, and a binary that asks the loader for libblas.so.3 or liblapack.so.3 does not start. They are owned by this package, so no other port may install a reference BLAS or LAPACK under those names.
Both make lines carry the same variables. make install reads Makefile.system again and decides from them what to copy (NO_STATIC=1 is what keeps libopenblas.a out of the package), so a variable changed in one line and not the other installs something other than what was built.