openblas/Create-independent-kernel-Makfile-configuration-when-building-DYNAMIC_ARCH.patch
Egbert Eich 4d274741c5 Accepting request 965613 from home:eeich:branches:science_alt
- Update to v0.3.20:
  * general:
    some code cleanup, with added casts etc.
    fixed obtaining the cpu count with OpenMP and OMP_PROC_BIND unset
    fixed pivot index calculation by ?LASWP for negative increments other
          than one
    fixed input argument check in LAPACK ? GEQRT2
    improved the check for a Fortran compiler in CMAKE builds
    disabled building OpenBLAS' optimized versions of LAPACK complex SPMV,
          SPR,SYMV,SYR with NO_LAPACK=1
    fixed building of LAPACK on certain distributed filesystems with parallel
          gmake
    fixed building the shared library on MacOS with classic flang
    (v0.3.19)
    reverted unsafe TRSV/ZRSV optimizations introduced in 0.3.16
    fixed a potential thread race in the thread buffer reallocation routines
    that were introduced in 0.3.18
    fixed miscounting of thread pool size on Linux with OMP_PROC_BIND=TRUE
    fixed CBLAS interfaces for CSROT/ZSROT and CROTG/ZROTG
    made automatic library suffix for CMAKE builds with INTERFACE64 available
    to CBLAS-only builds
    (v0.3.18)
    when the build-time number of preconfigured threads is exceeded
        at runtime (by an external program calling BLAS functions from
        a larger number of threads), OpenBLAS will now allocate an
        auxiliary control structure for up to 512 additional threads
        instead of aborting
    added support for Loongson's LoongArch64 cpu architecture
    fixed building OpenBLAS with CMAKE and -DBUILD_BFLOAT16=ON
    added support for building OpenBLAS as a CMAKE subproject

OBS-URL: https://build.opensuse.org/request/show/965613
OBS-URL: https://build.opensuse.org/package/show/science/openblas?expand=0&rev=129
2022-03-30 09:28:45 +00:00

186 lines
6.1 KiB
Diff

From: Egbert Eich <eich@suse.com>
Date: Tue Mar 1 10:04:01 2022 +0100
Subject: Create independent kernel Makfile & configuration when building DYNAMIC_ARCH
Patch-mainline: Not yet
Git-commit: c8b95480ec9fd2cab0321da61a7711415be6e9a9
References:
- For 'classic' builds, generate separate config_kernel_<TARGET>.h,
Makfile_<TARGET>.conf and getarch-<TARGET> files/binaries
- For cmake builds, generate separate getarch-<TARGET> binaries
for better debugging.
Signed-off-by: Egbert Eich <eich@suse.com>
Signed-off-by: Egbert Eich <eich@suse.de>
---
Makefile | 4 ++--
Makefile.prebuild | 26 +++++++++++++++++---------
Makefile.system | 4 ++++
cmake/prebuild.cmake | 6 +++++-
common.h | 4 ++++
getarch_2nd.c | 4 ++++
kernel/Makefile | 2 +-
7 files changed, 37 insertions(+), 13 deletions(-)
diff --git a/Makefile b/Makefile
index 1bb3f6b..2a1639c 100644
--- a/Makefile
+++ b/Makefile
@@ -387,11 +387,11 @@ clean ::
@$(MAKE) -C kernel clean
#endif
@$(MAKE) -C reference clean
- @rm -f *.$(LIBSUFFIX) *.so *~ *.exe getarch getarch_2nd *.dll *.lib *.$(SUFFIX) *.dwf $(LIBPREFIX).$(LIBSUFFIX) $(LIBPREFIX)_p.$(LIBSUFFIX) $(LIBPREFIX).so.$(MAJOR_VERSION) *.lnk myconfig.h *.so.renamed *.a.renamed *.so.0
+ @rm -f *.$(LIBSUFFIX) *.so *~ *.exe getarch getarch-* getarch_2nd getarch_2nd-* *.dll *.lib *.$(SUFFIX) *.dwf $(LIBPREFIX).$(LIBSUFFIX) $(LIBPREFIX)_p.$(LIBSUFFIX) $(LIBPREFIX).so.$(MAJOR_VERSION) *.lnk myconfig.h *.so.renamed *.a.renamed *.so.0
ifeq ($(OSNAME), Darwin)
@rm -rf getarch.dSYM getarch_2nd.dSYM
endif
- @rm -f Makefile.conf config.h Makefile_kernel.conf config_kernel.h st* *.dylib
+ @rm -f Makefile.conf config.h Makefile_kernel*.conf config_kernel*.h st* *.dylib
@rm -f cblas.tmp cblas.tmp2
@touch $(NETLIB_LAPACK_DIR)/make.inc
@$(MAKE) -C $(NETLIB_LAPACK_DIR) clean
diff --git a/Makefile.prebuild b/Makefile.prebuild
index 399db95..c9eb8e0 100644
--- a/Makefile.prebuild
+++ b/Makefile.prebuild
@@ -8,11 +8,19 @@ override HOST_CFLAGS += -DDYNAMIC_ARCH
endif
ifdef TARGET_CORE
+ifdef DYNAMIC_ARCH
+TARGET_MAKE = Makefile_kernel_$(TARGET_CORE).conf
+TARGET_CONF = config_kernel_$(TARGET_CORE).h
+GETARCH_FLAVOR = -$(TARGET_CORE)
+else
TARGET_MAKE = Makefile_kernel.conf
TARGET_CONF = config_kernel.h
+GETARCH_FLAVOR = -$(TARGET_CORE)
+endif
else
TARGET_MAKE = Makefile.conf
TARGET_CONF = config.h
+GETARCH_FLAVOR =
endif
# CPUIDEMU = ../../cpuid/table.o
@@ -49,11 +57,11 @@ ifeq ($(TARGET), C910V)
TARGET_FLAGS = -march=rv64gcvxthead -mabi=lp64v
endif
-all: getarch_2nd
- ./getarch_2nd 0 >> $(TARGET_MAKE)
- ./getarch_2nd 1 >> $(TARGET_CONF)
+all: getarch_2nd$(GETARCH_FLAVOR)
+ ./getarch_2nd$(GETARCH_FLAVOR) 0 >> $(TARGET_MAKE)
+ ./getarch_2nd$(GETARCH_FLAVOR) 1 >> $(TARGET_CONF)
-config.h : c_check f_check getarch
+config.h : c_check f_check getarch$(GETARCH_FLAVOR)
perl ./c_check $(TARGET_MAKE) $(TARGET_CONF) $(CC) $(TARGET_FLAGS) $(CFLAGS)
ifneq ($(ONLY_CBLAS), 1)
perl ./f_check $(TARGET_MAKE) $(TARGET_CONF) $(FC) $(TARGET_FLAGS)
@@ -66,18 +74,18 @@ else
echo "#define BUNDERSCORE _" >> $(TARGET_CONF)
echo "#define NEEDBUNDERSCORE 1" >> $(TARGET_CONF)
endif
- ./getarch 0 >> $(TARGET_MAKE)
- ./getarch 1 >> $(TARGET_CONF)
+ ./getarch$(GETARCH_FLAVOR) 0 >> $(TARGET_MAKE)
+ ./getarch$(GETARCH_FLAVOR) 1 >> $(TARGET_CONF)
-getarch : getarch.c cpuid.S dummy $(CPUIDEMU)
+getarch$(GETARCH_FLAVOR) : getarch.c cpuid.S dummy $(CPUIDEMU)
$(HOSTCC) $(HOST_CFLAGS) $(EXFLAGS) -o $(@F) getarch.c cpuid.S $(CPUIDEMU)
-getarch_2nd : getarch_2nd.c config.h dummy
+getarch_2nd$(GETARCH_FLAVOR) : getarch_2nd.c config.h dummy
ifndef TARGET_CORE
$(HOSTCC) -I. $(HOST_CFLAGS) -o $(@F) getarch_2nd.c
else
- $(HOSTCC) -I. $(HOST_CFLAGS) -DBUILD_KERNEL -o $(@F) getarch_2nd.c
+ $(HOSTCC) -I. $(HOST_CFLAGS) -DBUILD_KERNEL -DKERNEL_CONFIG=\"$(TARGET_CONF)\" -o $(@F) getarch_2nd.c
endif
dummy:
diff --git a/Makefile.system b/Makefile.system
index 1057255..5f66d30 100644
--- a/Makefile.system
+++ b/Makefile.system
@@ -298,8 +298,12 @@ HAVE_SSE5=
HAVE_AVX=
HAVE_AVX2=
HAVE_FMA3=
+ifeq ($(DYNAMIC_ARCH), 1)
+include $(TOPDIR)/Makefile_kernel_$(TARGET_CORE).conf
+else
include $(TOPDIR)/Makefile_kernel.conf
endif
+endif
endif
diff --git a/cmake/prebuild.cmake b/cmake/prebuild.cmake
index 4ef0ce9..2f5d472 100644
--- a/cmake/prebuild.cmake
+++ b/cmake/prebuild.cmake
@@ -629,7 +629,11 @@ else(NOT CMAKE_CROSSCOMPILING)
endif ()
set(GETARCH_DIR "${PROJECT_BINARY_DIR}/getarch_build")
- set(GETARCH_BIN "getarch${CMAKE_EXECUTABLE_SUFFIX}")
+ if (DEFINED TARGET_CORE)
+ set(GETARCH_BIN "getarch-${TARGET_CORE}${CMAKE_EXECUTABLE_SUFFIX}")
+ else ()
+ set(GETARCH_BIN "getarch${CMAKE_EXECUTABLE_SUFFIX}")
+ endif ()
file(MAKE_DIRECTORY ${GETARCH_DIR})
configure_file(${TARGET_CONF_TEMP} ${GETARCH_DIR}/${TARGET_CONF} COPYONLY)
if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
diff --git a/common.h b/common.h
index 00d1d0b..d563e3b 100644
--- a/common.h
+++ b/common.h
@@ -57,7 +57,11 @@ extern "C" {
#endif
#ifdef BUILD_KERNEL
+#ifdef KERNEL_CONFIG
+#include KERNEL_CONFIG
+#else
#include "config_kernel.h"
+#endif
#else
#include "config.h"
#endif
diff --git a/getarch_2nd.c b/getarch_2nd.c
index dd1f830..2abeee6 100644
--- a/getarch_2nd.c
+++ b/getarch_2nd.c
@@ -2,8 +2,12 @@
#ifndef BUILD_KERNEL
#include "config.h"
#else
+#ifdef KERNEL_CONFIG
+#include KERNEL_CONFIG
+#else
#include "config_kernel.h"
#endif
+#endif
#if (defined(__WIN32__) || defined(__WIN64__) || defined(__CYGWIN32__) || defined(__CYGWIN64__) || defined(_WIN32) || defined(_WIN64)) && defined(__64BIT__)
typedef long long BLASLONG;
typedef unsigned long long BLASULONG;
diff --git a/kernel/Makefile b/kernel/Makefile
index cbe4cde..94a718b 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -124,7 +124,7 @@ COMMONOBJS += lsame.$(SUFFIX) scabs1.$(SUFFIX) dcabs1.$(SUFFIX)
ifeq ($(DYNAMIC_ARCH), 1)
SBLASOBJS += setparam$(TSUFFIX).$(SUFFIX)
-CCOMMON_OPT += -DTS=$(TSUFFIX)
+CCOMMON_OPT += -DTS=$(TSUFFIX) -DKERNEL_CONFIG=\"config_kernel$(TSUFFIX).h\"
endif
KERNEL_INTERFACE = ../common_level1.h ../common_level2.h ../common_level3.h