From 7a358aa6b833c8437f8f2c2be6acaba9bda65ee2 Mon Sep 17 00:00:00 2001 From: yangchenguang Date: Mon, 14 Aug 2023 10:42:21 +0800 Subject: [PATCH] Add loongarch64 and rsicv support Signed-off-by: yangchenguang --- modify-the-ABI-for-loongarch.patch | 43 ++++++++++++++++++++++++++++++ openblas.spec | 26 +++++++++++++++--- 2 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 modify-the-ABI-for-loongarch.patch diff --git a/modify-the-ABI-for-loongarch.patch b/modify-the-ABI-for-loongarch.patch new file mode 100644 index 0000000..fdf06c6 --- /dev/null +++ b/modify-the-ABI-for-loongarch.patch @@ -0,0 +1,43 @@ +From 15f793d0d1a38f1e203d7d50df3947201731c34d Mon Sep 17 00:00:00 2001 +From: Wenlong Zhang +Date: Wed, 30 Nov 2022 09:27:01 +0000 +Subject: [PATCH] modify the ABI for loongarch + +--- + OpenBLAS-0.3.18/Makefile.system | 4 ++-- + OpenBLAS-0.3.18/Makefile.system.libname | 4 ++-- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git OpenBLAS-0.3.18/Makefile.system OpenBLAS-0.3.18/Makefile.system +index 17310b0..19f04b5 100644 +--- OpenBLAS-0.3.18/Makefile.system ++++ OpenBLAS-0.3.18/Makefile.system +@@ -869,8 +869,8 @@ endif + + ifeq ($(ARCH), loongarch64) + ifeq ($(CORE), LOONGSON3R5) +-CCOMMON_OPT += -march=loongarch64 -mabi=lp64 +-FCOMMON_OPT += -march=loongarch64 -mabi=lp64 ++CCOMMON_OPT += -march=loongarch64 -mabi=lp64d ++FCOMMON_OPT += -march=loongarch64 -mabi=lp64d + endif + endif + +diff --git OpenBLAS-0.3.18/Makefile.system.libname OpenBLAS-0.3.18/Makefile.system.libname +index 150dbef..f9101af 100644 +--- OpenBLAS-0.3.18/Makefile.system.libname ++++ OpenBLAS-0.3.18/Makefile.system.libname +@@ -869,8 +869,8 @@ endif + + ifeq ($(ARCH), loongarch64) + ifeq ($(CORE), LOONGSON3R5) +-CCOMMON_OPT += -march=loongarch64 -mabi=lp64 +-FCOMMON_OPT += -march=loongarch64 -mabi=lp64 ++CCOMMON_OPT += -march=loongarch64 -mabi=lp64d ++FCOMMON_OPT += -march=loongarch64 -mabi=lp64d + endif + endif + +-- +2.33.0 + diff --git a/openblas.spec b/openblas.spec index 0975956..5656d8b 100644 --- a/openblas.spec +++ b/openblas.spec @@ -2,7 +2,7 @@ Name: openblas Version: 0.3.18 -Release: 4 +Release: 5 Summary: An optimized BLAS library based on GotoBLAS2 1.13 BSD version License: BSD-3-Clause URL: https://github.com/xianyi/OpenBLAS/ @@ -12,6 +12,8 @@ Patch0001: openblas-0.2.5-libname.patch Patch0002: openblas-0.3.7-tests.patch Patch0003: rm-make-test-from-Makefile-and-add-this-to-spec-in-f.patch +Patch1000: modify-the-ABI-for-loongarch.patch + Requires: %{name}-devel = %{version}-%{release} BuildRequires: gcc gcc-gfortran perl-devel gcc-c++ @@ -48,7 +50,7 @@ Obsoletes: openblas-serial64_ < %{version}-%{release} openblas-openmp64_ < Obsoletes: openblas-threads64_ < %{version}-%{release} openblas-Rblas < %{version}-%{release} %endif -ExclusiveArch: x86_64 aarch64 +ExclusiveArch: x86_64 aarch64 loongarch64 riscv64 %description OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD \ @@ -72,6 +74,7 @@ cd OpenBLAS-%{version} %patch0001 -p1 -b .libname %patch0002 -p1 -b .tests %patch0003 -p1 +%patch1000 -p1 # Set source permissions find -name \*.f -exec chmod 644 {} \; @@ -182,6 +185,9 @@ TARGET="TARGET=CORE2 DYNAMIC_ARCH=1 DYNAMIC_OLDER=0" %ifarch aarch64 TARGET="TARGET=ARMV8 DYNAMIC_ARCH=0" %endif +%ifarch riscv64 +TARGET="TARGET=RISCV64_GENERIC DYNAMIC_ARCH=0" +%endif COMMON="%{optflags} -fPIC" FCOMMON="%{optflags} -fPIC -frecursive" @@ -266,7 +272,12 @@ make -C openmp64_ tests $TARGET USE_THREAD=1 USE_OPENMP=1 FC=gfortran CC=gcc CO %install rm -rf %{buildroot} # Install serial library and headers -make -C serial USE_THREAD=0 PREFIX=%{buildroot} OPENBLAS_LIBRARY_DIR=%{buildroot}%{_libdir} OPENBLAS_INCLUDE_DIR=%{buildroot}%{_includedir}/%name OPENBLAS_BINARY_DIR=%{buildroot}%{_bindir} OPENBLAS_CMAKE_DIR=%{buildroot}%{_libdir}/cmake install +%ifarch riscv64 +TARGET="TARGET=RISCV64_GENERIC DYNAMIC_ARCH=0" +%else +TARGET= +%endif +make -C serial $TARGET USE_THREAD=0 PREFIX=%{buildroot} OPENBLAS_LIBRARY_DIR=%{buildroot}%{_libdir} OPENBLAS_INCLUDE_DIR=%{buildroot}%{_includedir}/%name OPENBLAS_BINARY_DIR=%{buildroot}%{_bindir} OPENBLAS_CMAKE_DIR=%{buildroot}%{_libdir}/cmake install # Copy lapacke include files %if %{with system_lapack} && %{lapacke} @@ -277,6 +288,12 @@ cp -a %{_includedir}/lapacke %{buildroot}%{_includedir}/%{name} %ifarch aarch64 suffix="_armv8" %endif +%ifarch loongarch64 +suffix="_loongson3r5" +%endif +%ifarch riscv64 +suffix="_riscv64_generic" +%endif slibname=`basename %{buildroot}%{_libdir}/libopenblas${suffix}-*.so .so` mv %{buildroot}%{_libdir}/${slibname}.a %{buildroot}%{_libdir}/lib%{name}.a if [[ "$suffix" != "" ]]; then @@ -420,6 +437,9 @@ rm -rf %{buildroot}%{_libdir}/pkgconfig %endif %changelog +* Mon Aug 14 2023 yangchenguang - 0.3.18-5 +- Add loongarch64 and rsicv support + * Mon Apr 18 2022 zhouwenpei - 0.3.18-4 - sync master build speed optimization -- Gitee