commit:     03f1689aa0d72075183bd999192a363994c41195
Author:     Michael Orlitzky <mjo <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 12 11:53:59 2022 +0000
Commit:     Michael Orlitzky <mjo <AT> gentoo <DOT> org>
CommitDate: Sat Nov 12 12:05:19 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=03f1689a

sci-libs/openblas: add 0.3.21

I had to rebase the loongarch patch, and removed an old workaround for
FFLAGS="-fcheck=bounds" in the test suite, but other than that a
standard update.

Bug: https://bugs.gentoo.org/726474
Closes: https://bugs.gentoo.org/878883
Signed-off-by: Michael Orlitzky <mjo <AT> gentoo.org>

 sci-libs/openblas/Manifest                         |   1 +
 .../openblas/files/openblas-0.3.21-fix-loong.patch | 237 +++++++++++++++++++++
 sci-libs/openblas/openblas-0.3.21.ebuild           | 196 +++++++++++++++++
 3 files changed, 434 insertions(+)

diff --git a/sci-libs/openblas/Manifest b/sci-libs/openblas/Manifest
index 7f5369e57040..95fc46d6f9d5 100644
--- a/sci-libs/openblas/Manifest
+++ b/sci-libs/openblas/Manifest
@@ -1,3 +1,4 @@
 DIST openblas-0.3.18.tar.gz 12619822 BLAKE2B 
38a5e7b861eb0063a4494c1cfb6f7f5723741437ecdd5cb1fb42645eb73bceb472b3a8c11eec3d0ba4f676981ac89de4ff1ee0d7ea42d1e234746f34ce8fb6b8
 SHA512 
df9a14026a61bdc5285636bfd7a52dce244d24fcf4a0c870ef4e58b8b50e412849828ca5aeac2a2435f635e78e60559762e8bae22ea7bc5dff2e865a96d81152
 DIST openblas-0.3.19.tar.gz 12706050 BLAKE2B 
c29aa27faaf18e3330087f8d2ebed733f53878266d6865239dfbb1624a113f3cabc988bbfcc18a0aa5d971697bc68bb267795ef24e2d8e0e8d50f802cb817b57
 SHA512 
1fcbcfefb7744894b0b0c83c6071b342086ca311dc67f5c2745812d61dcc9d31ef7dd5e1215dfb2731ae7197d497dbdf8f8b26a432eb07d41a7db0983eb86a33
 DIST openblas-0.3.20.tar.gz 12742441 BLAKE2B 
9ae808e2a7da39e28dbe26c7feb5da3c70275f3b48bd68455c22e3b16fc1f2d10b9d84c9593acff2c837fc1514f21f2bbc0e87708075c5fe13514d0d47cf0b5a
 SHA512 
0742d40b74b11b781021280fd627fa5798e6856b49f2ba1111a5927aac1a7823bcb8162187555f4cf3a4dd7eadf5b1f2a4685c0b5e189847b2869166d1bc7391
+DIST openblas-0.3.21.tar.gz 23729571 BLAKE2B 
678bfb13ead69045e7d4d840bbcaed884d9ebedded5425cfa1f55e3d85bda31a3eb43dbbf9f07099d0d198f97ae68ef3b3b2b78aa1bd5b4999dd729dc08f7e28
 SHA512 
4625c8e6ccfa9120281fd714d3f6b7c3ba2265470c1be76121d6b25dc3dacb899d26e5d9a417ddc616d23909f1411495aa995ef8d8d6df8511cd5cefbabcb1c5

diff --git a/sci-libs/openblas/files/openblas-0.3.21-fix-loong.patch 
b/sci-libs/openblas/files/openblas-0.3.21-fix-loong.patch
new file mode 100644
index 000000000000..ed112d62380b
--- /dev/null
+++ b/sci-libs/openblas/files/openblas-0.3.21-fix-loong.patch
@@ -0,0 +1,237 @@
+https://github.com/xianyi/OpenBLAS/pull/3626
+
+From 5af7b8638b3b972bd0e25597ec07927fffd52108 Mon Sep 17 00:00:00 2001
+From: WANG Xuerui <xe...@gentoo.org>
+Date: Fri, 13 May 2022 15:26:33 +0800
+Subject: [PATCH 1/3] Move LoongArch make rules to Makefile.loongarch64
+
+---
+ Makefile.loongarch64 | 5 +++--
+ Makefile.system      | 5 -----
+ 2 files changed, 3 insertions(+), 7 deletions(-)
+
+diff --git a/Makefile.loongarch64 b/Makefile.loongarch64
+index 05ea9c679d..fced1a9462 100644
+--- a/Makefile.loongarch64
++++ b/Makefile.loongarch64
+@@ -1,3 +1,4 @@
+-ifdef BINARY64
+-else
++ifeq ($(CORE), LOONGSON3R5)
++CCOMMON_OPT += -march=loongarch64 -mabi=lp64
++FCOMMON_OPT += -march=loongarch64 -mabi=lp64
+ endif
+diff --git a/Makefile.system b/Makefile.system
+index 3be5efa0c2..9c91425b0f 100644
+--- a/Makefile.system
++++ b/Makefile.system
+@@ -895,11 +895,6 @@ ifeq ($(OSNAME), AIX)
+ BINARY_DEFINED = 1
+ endif
+ 
+-ifeq ($(ARCH), loongarch64)
+-CCOMMON_OPT += -march=loongarch64 -mabi=lp64
+-FCOMMON_OPT += -march=loongarch64 -mabi=lp64
+-endif
+-
+ endif
+ 
+ ifndef BINARY_DEFINED
+
+From 869061c783d60ba0b799fab643952c493b57fb0a Mon Sep 17 00:00:00 2001
+From: WANG Xuerui <xe...@gentoo.org>
+Date: Fri, 13 May 2022 15:53:22 +0800
+Subject: [PATCH 2/3] Probe for old-world LASX flavor on LoongArch and use
+ generic DGEMM kernel otherwise
+
+See: https://bugs.gentoo.org/844013
+---
+ Makefile.system                       |  1 +
+ c_check                               | 27 ++++++++++++++++++++++++++-
+ kernel/loongarch64/KERNEL.LOONGSON3R5 |  5 +++++
+ 3 files changed, 32 insertions(+), 1 deletion(-)
+
+diff --git a/Makefile.system b/Makefile.system
+index 9c91425b0f..b86aafbddb 100644
+--- a/Makefile.system
++++ b/Makefile.system
+@@ -1702,6 +1702,7 @@ export TARGET_CORE
+ export NO_AVX512
+ export NO_AVX2
+ export BUILD_BFLOAT16
++export NO_LASX
+ 
+ export SBGEMM_UNROLL_M
+ export SBGEMM_UNROLL_N
+diff --git a/c_check b/c_check
+index 01d4f4a7cf..a37e91f82c 100755
+--- a/c_check
++++ b/c_check
+@@ -112,7 +112,7 @@ case "$architecture" in
+       defined=1
+       ;;
+     arm|arm64) defined=1 ;;
+-    zarch|e2k|alpha|ia64|riscv64|loonarch64)
++    zarch|e2k|alpha|ia64|riscv64|loongarch64)
+       defined=1
+       BINARY=64
+       ;;
+@@ -240,6 +240,29 @@ if [ "$architecture" = "riscv64" ]; then
+     rm -rf "$tmpd"
+ fi
+ 
++no_lasx=0
++if [ "$architecture" = "loongarch64" ]; then
++    tmpd=`mktemp -d`
++    tmpf="$tmpd/a.c"
++    # Old-world assembly flavor: LASX registers named "$xrNN", different
++    # from the ISA manual which suggests "$xNN". This is the flavor we
++    # currently support.
++    #
++    # As the LASX ISA manual is not out yet, we cannot predict what the
++    # new-world flavor would look like, so do not probe flavor for now.
++    # The compiler flags are also unsuitable for new-world gcc.
++    code='"xvld $xr0, $a0, 0\n"'
++    printf "int main(void){ __asm__ volatile(%s); }\n" "$code" >> "$tmpf"
++    args=" -march=loongarch64 -mabi=lp64 -mlasx -c -o $tmpf.o $tmpf"
++    no_lasx=0
++    {
++        $compiler_name $flags $args >/dev/null 2>&1
++    } || {
++        no_lasx=1
++    }
++    rm -rf "$tmpd"
++fi
++
+ c11_atomics=0
+ case "$data" in
+     *HAVE_C11*)
+@@ -350,6 +373,7 @@ done
+ 
+  [ "$makefile" = "-" ] && {
+     [ "$no_rv64gv" -eq 1 ] && printf "NO_RV64GV=1\n"
++    [ "$no_lasx" -eq 1 ] && printf "NO_LASX=1\n"
+     [ "$no_avx512" -eq 1 ] && printf "NO_AVX512=1\n"
+     [ "$no_avx2" -eq 1 ] && printf "NO_AVX2=1\n"
+     [ "$oldgcc" -eq 1 ] && printf "OLDGCC=1\n"
+@@ -380,6 +404,7 @@ done
+         printf "MSA_FLAGS=%s\n" "$msa_flags"
+     }
+     [ "$no_rv64gv" -eq 1 ] && printf "NO_RV64GV=1\n"
++    [ "$no_lasx" -eq 1 ] && printf "NO_LASX=1\n"
+     [ "$no_avx512" -eq 1 ] && printf "NO_AVX512=1\n"
+     [ "$no_avx2" -eq 1 ] && printf "NO_AVX2=1\n"
+     [ "$oldgcc" -eq 1 ] && printf "OLDGCC=1\n"
+diff --git a/kernel/loongarch64/KERNEL.LOONGSON3R5 
b/kernel/loongarch64/KERNEL.LOONGSON3R5
+index cda3590402..79b57d1e4d 100644
+--- a/kernel/loongarch64/KERNEL.LOONGSON3R5
++++ b/kernel/loongarch64/KERNEL.LOONGSON3R5
+@@ -1,3 +1,7 @@
++ifeq ($(NO_LASX), 1)
++# No LASX support in compiler, unable to consume the optimized version
++# leave out DGEMMKERNEL to pull in the generic version
++else
+ DGEMMKERNEL    = dgemm_kernel_16x4.S
+ DGEMMINCOPY    = dgemm_ncopy_16.S
+ DGEMMITCOPY    = dgemm_tcopy_16.S
+@@ -7,6 +11,7 @@ DGEMMINCOPYOBJ = dgemm_incopy$(TSUFFIX).$(SUFFIX)
+ DGEMMITCOPYOBJ = dgemm_itcopy$(TSUFFIX).$(SUFFIX)
+ DGEMMONCOPYOBJ = dgemm_oncopy$(TSUFFIX).$(SUFFIX)
+ DGEMMOTCOPYOBJ = dgemm_otcopy$(TSUFFIX).$(SUFFIX)
++endif
+ 
+ DTRSMKERNEL_LN  = ../generic/trsm_kernel_LN.c
+ DTRSMKERNEL_LT  = ../generic/trsm_kernel_LT.c
+
+From 699c57d3767c9a5a5a69262a4b70a1f80e0bb2e2 Mon Sep 17 00:00:00 2001
+From: WANG Xuerui <xe...@gentoo.org>
+Date: Fri, 13 May 2022 16:23:46 +0800
+Subject: [PATCH 3/3] Fix ABI CFLAGS setting on new-world LoongArch
+
+See: https://bugs.gentoo.org/844013
+---
+ Makefile.loongarch64 | 13 +++++++++++--
+ Makefile.system      |  1 +
+ c_check              | 14 ++++++++++++++
+ 3 files changed, 26 insertions(+), 2 deletions(-)
+
+diff --git a/Makefile.loongarch64 b/Makefile.loongarch64
+index fced1a9462..d6cbe848cd 100644
+--- a/Makefile.loongarch64
++++ b/Makefile.loongarch64
+@@ -1,4 +1,13 @@
+ ifeq ($(CORE), LOONGSON3R5)
+-CCOMMON_OPT += -march=loongarch64 -mabi=lp64
+-FCOMMON_OPT += -march=loongarch64 -mabi=lp64
++CCOMMON_OPT += -march=loongarch64
++FCOMMON_OPT += -march=loongarch64
++
++ifeq ($(LOONGARCH_CC_FLAVOR), NEW)
++CCOMMON_OPT += -mabi=lp64d
++FCOMMON_OPT += -mabi=lp64d
++endif
++ifeq ($(LOONGARCH_CC_FLAVOR), OLD)
++CCOMMON_OPT += -mabi=lp64
++FCOMMON_OPT += -mabi=lp64
++endif
+ endif
+diff --git a/Makefile.system b/Makefile.system
+index b86aafbddb..4360a861cb 100644
+--- a/Makefile.system
++++ b/Makefile.system
+@@ -1702,6 +1702,7 @@ export TARGET_CORE
+ export NO_AVX512
+ export NO_AVX2
+ export BUILD_BFLOAT16
++export LOONGARCH_CC_FLAVOR
+ export NO_LASX
+ 
+ export SBGEMM_UNROLL_M
+diff --git a/c_check b/c_check
+index a37e91f82c..573f0e52fd 100755
+--- a/c_check
++++ b/c_check
+@@ -240,8 +240,19 @@ if [ "$architecture" = "riscv64" ]; then
+     rm -rf "$tmpd"
+ fi
+ 
++loongarch_cc_flavor=""
+ no_lasx=0
+ if [ "$architecture" = "loongarch64" ]; then
++    # Currently there are only 2 flavors: new-world and old-world.
++    # They differ in ABI names accepted, so check it to avoid creating temp
++    # files.
++    loongarch_cc_flavor="NEW"
++    {
++        $compiler_name -mabi=lp64d -E -o - /dev/null >/dev/null 2>&1
++    } || {
++        loongarch_cc_flavor="OLD"
++    }
++
+     tmpd=`mktemp -d`
+     tmpf="$tmpd/a.c"
+     # Old-world assembly flavor: LASX registers named "$xrNN", different
+@@ -260,6 +271,7 @@ if [ "$architecture" = "loongarch64" ]; then
+     } || {
+         no_lasx=1
+     }
++
+     rm -rf "$tmpd"
+ fi
+ 
+@@ -377,6 +389,7 @@ done
+     [ "$no_avx512" -eq 1 ] && printf "NO_AVX512=1\n"
+     [ "$no_avx2" -eq 1 ] && printf "NO_AVX2=1\n"
+     [ "$oldgcc" -eq 1 ] && printf "OLDGCC=1\n"
++    [ -n "$loongarch_cc_flavor" ] && printf "LOONGARCH_CC_FLAVOR=%s\n" 
"$loongarch_cc_flavor"
+     exit 0
+ }
+ 
+@@ -408,6 +421,7 @@ done
+     [ "$no_avx512" -eq 1 ] && printf "NO_AVX512=1\n"
+     [ "$no_avx2" -eq 1 ] && printf "NO_AVX2=1\n"
+     [ "$oldgcc" -eq 1 ] && printf "OLDGCC=1\n"
++    [ -n "$loongarch_cc_flavor" ] && printf "LOONGARCH_CC_FLAVOR=%s\n" 
"$loongarch_cc_flavor"
+ } >> "$makefile"
+ 
+ os=`echo "$os" | tr '[[:lower:]]' '[[:upper:]]'/ `

diff --git a/sci-libs/openblas/openblas-0.3.21.ebuild 
b/sci-libs/openblas/openblas-0.3.21.ebuild
new file mode 100644
index 000000000000..8684438c1a7a
--- /dev/null
+++ b/sci-libs/openblas/openblas-0.3.21.ebuild
@@ -0,0 +1,196 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+inherit fortran-2 toolchain-funcs
+
+DESCRIPTION="Optimized BLAS library based on GotoBLAS2"
+HOMEPAGE="https://github.com/xianyi/OpenBLAS";
+SRC_URI="https://github.com/xianyi/OpenBLAS/archive/v${PV}.tar.gz -> 
${P}.tar.gz"
+S="${WORKDIR}"/OpenBLAS-${PV}
+
+LICENSE="BSD"
+SLOT="0"
+KEYWORDS="~amd64 ~arm ~arm64 ~loong ~riscv ~x86 ~amd64-linux ~x86-linux 
~x64-macos"
+IUSE="dynamic eselect-ldso index-64bit openmp pthread relapack test"
+REQUIRED_USE="?? ( openmp pthread )"
+RESTRICT="!test? ( test )"
+
+RDEPEND="
+       eselect-ldso? (
+               >=app-eselect/eselect-blas-0.2
+               >=app-eselect/eselect-lapack-0.2
+       )
+"
+BDEPEND="virtual/pkgconfig"
+
+PATCHES=(
+       "${FILESDIR}/${PN}-0.3.12-shared-blas-lapack.patch"
+       "${FILESDIR}/${PN}-0.3.21-fix-loong.patch"
+)
+
+pkg_pretend() {
+       [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
+
+       elog "This software has a massive number of options that"
+       elog "are configurable and it is *impossible* for all of"
+       elog "those to fit inside any manageable ebuild."
+       elog "The Gentoo provided package has enough to build"
+       elog "a fully optimized library for your targeted CPU."
+       elog "You can set the CPU target using the environment"
+       elog "variable - OPENBLAS_TARGET or it will be detected"
+       elog "automatically from the target toolchain (supports"
+       elog "cross compilation toolchains)."
+       elog "You can control the maximum number of threads"
+       elog "using OPENBLAS_NTHREAD, default=64 and number of "
+       elog "parallel calls to allow before further calls wait"
+       elog "using OPENBLAS_NPARALLEL, default=8."
+}
+
+pkg_setup() {
+       fortran-2_pkg_setup
+
+       # List of most configurable options - Makefile.rule
+
+       # https://github.com/xianyi/OpenBLAS/pull/2663
+       tc-export CC FC LD AR AS RANLIB
+
+       # HOSTCC is used for scripting
+       export HOSTCC="$(tc-getBUILD_CC)"
+
+       # threading options
+       [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
+       USE_THREAD=0
+       if use openmp; then
+               USE_THREAD=1; USE_OPENMP=1;
+       elif use pthread; then
+               USE_THREAD=1; USE_OPENMP=0;
+       fi
+       export USE_THREAD USE_OPENMP
+
+       # disable submake with -j and default optimization flags
+       # in Makefile.system
+       # Makefile.rule says to not modify COMMON_OPT/FCOMMON_OPT...
+       export MAKE_NB_JOBS=-1 \
+                  COMMON_OPT=" " \
+                  FCOMMON_OPT=" "
+
+       # Target CPU ARCH options
+       # generally detected automatically from cross toolchain
+       use dynamic && \
+               export DYNAMIC_ARCH=1 \
+                          NO_AFFINITY=1 \
+                          TARGET=GENERIC
+
+       export NUM_PARALLEL=${OPENBLAS_NPARALLEL:-8} \
+                  NUM_THREADS=${OPENBLAS_NTHREAD:-64}
+
+       # setting OPENBLAS_TARGET to override auto detection
+       # in case the toolchain is not enough to detect
+       # https://github.com/xianyi/OpenBLAS/blob/develop/TargetList.txt
+       if ! use dynamic && [[ ! -z "${OPENBLAS_TARGET}" ]] ; then
+               export TARGET="${OPENBLAS_TARGET}"
+       fi
+
+       export NO_STATIC=1
+
+       BUILD_RELAPACK=1
+       if ! use relapack; then
+               BUILD_RELAPACK=0
+       fi
+
+       export PREFIX="${EPREFIX}/usr" BUILD_RELAPACK
+}
+
+src_prepare() {
+       default
+
+       # Don't build the tests as part of "make all". We'll do
+       # it explicitly later if the test phase is enabled.
+       sed -e "/^all ::/s/tests //" -i Makefile || die
+
+       # if 64bit-index is needed, create second library
+       # with LIBPREFIX=libopenblas64
+       if use index-64bit; then
+               cp -aL "${S}" "${S}-index-64bit" || die
+       fi
+}
+
+src_compile() {
+       default
+       cd interface || die
+       emake shared-blas-lapack
+
+       if use index-64bit; then
+               emake -C"${S}-index-64bit" \
+                         INTERFACE64=1 \
+                         LIBPREFIX=libopenblas64
+       fi
+}
+
+src_test() {
+       emake tests
+}
+
+src_install() {
+       emake install DESTDIR="${D}" \
+                                 
OPENBLAS_INCLUDE_DIR='$(PREFIX)'/include/${PN} \
+                                 OPENBLAS_LIBRARY_DIR='$(PREFIX)'/$(get_libdir)
+
+       dodoc GotoBLAS_*.txt *.md Changelog.txt
+
+       if use index-64bit; then
+               dolib.so "${S}-index-64bit"/libopenblas64*.so*
+       fi
+
+       if use eselect-ldso; then
+               insinto /usr/$(get_libdir)/blas/openblas/
+               doins interface/libblas.so.3
+               dosym libblas.so.3 usr/$(get_libdir)/blas/openblas/libblas.so
+               doins interface/libcblas.so.3
+               dosym libcblas.so.3 usr/$(get_libdir)/blas/openblas/libcblas.so
+
+               insinto /usr/$(get_libdir)/lapack/openblas/
+               doins interface/liblapack.so.3
+               dosym liblapack.so.3 
usr/$(get_libdir)/lapack/openblas/liblapack.so
+               doins interface/liblapacke.so.3
+               dosym liblapacke.so.3 
usr/$(get_libdir)/lapack/openblas/liblapacke.so
+       fi
+}
+
+pkg_postinst() {
+       use eselect-ldso || return
+       local libdir=$(get_libdir) me="openblas"
+
+       # check blas
+       eselect blas add ${libdir} "${EROOT}"/usr/${libdir}/blas/${me} ${me}
+       local current_blas=$(eselect blas show ${libdir} | cut -d' ' -f2)
+       if [[ ${current_blas} == "${me}" || -z ${current_blas} ]]; then
+               eselect blas set ${libdir} ${me}
+               elog "Current eselect: BLAS/CBLAS ($libdir) -> 
[${current_blas}]."
+       else
+               elog "Current eselect: BLAS/CBLAS ($libdir) -> 
[${current_blas}]."
+               elog "To use blas [${me}] implementation, you have to issue (as 
root):"
+               elog "\t eselect blas set ${libdir} ${me}"
+       fi
+
+       # check lapack
+       eselect lapack add ${libdir} "${EROOT}"/usr/${libdir}/lapack/${me} ${me}
+       local current_lapack=$(eselect lapack show ${libdir} | cut -d' ' -f2)
+       if [[ ${current_lapack} == "${me}" || -z ${current_lapack} ]]; then
+               eselect lapack set ${libdir} ${me}
+               elog "Current eselect: LAPACK ($libdir) -> [${current_lapack}]."
+       else
+               elog "Current eselect: LAPACK ($libdir) -> [${current_lapack}]."
+               elog "To use lapack [${me}] implementation, you have to issue 
(as root):"
+               elog "\t eselect lapack set ${libdir} ${me}"
+       fi
+}
+
+pkg_postrm() {
+       if use eselect-ldso; then
+               eselect blas validate
+               eselect lapack validate
+       fi
+}

Reply via email to