Create independent kernel Makfile & configuration when building DYNAMIC_ARCH

- 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>
This commit is contained in:
Egbert Eich 2022-03-01 10:04:01 +01:00
parent 501bf31e3e
commit 51c11cf4bf
7 changed files with 37 additions and 13 deletions

View File

@ -387,11 +387,11 @@ clean ::
@$(MAKE) -C kernel clean @$(MAKE) -C kernel clean
#endif #endif
@$(MAKE) -C reference clean @$(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) ifeq ($(OSNAME), Darwin)
@rm -rf getarch.dSYM getarch_2nd.dSYM @rm -rf getarch.dSYM getarch_2nd.dSYM
endif 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 @rm -f cblas.tmp cblas.tmp2
@touch $(NETLIB_LAPACK_DIR)/make.inc @touch $(NETLIB_LAPACK_DIR)/make.inc
@$(MAKE) -C $(NETLIB_LAPACK_DIR) clean @$(MAKE) -C $(NETLIB_LAPACK_DIR) clean

View File

@ -8,11 +8,19 @@ override HOST_CFLAGS += -DDYNAMIC_ARCH
endif endif
ifdef TARGET_CORE 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_MAKE = Makefile_kernel.conf
TARGET_CONF = config_kernel.h TARGET_CONF = config_kernel.h
GETARCH_FLAVOR = -$(TARGET_CORE)
endif
else else
TARGET_MAKE = Makefile.conf TARGET_MAKE = Makefile.conf
TARGET_CONF = config.h TARGET_CONF = config.h
GETARCH_FLAVOR =
endif endif
# CPUIDEMU = ../../cpuid/table.o # CPUIDEMU = ../../cpuid/table.o
@ -49,11 +57,11 @@ ifeq ($(TARGET), C910V)
TARGET_FLAGS = -march=rv64gcvxthead -mabi=lp64v TARGET_FLAGS = -march=rv64gcvxthead -mabi=lp64v
endif endif
all: getarch_2nd all: getarch_2nd$(GETARCH_FLAVOR)
./getarch_2nd 0 >> $(TARGET_MAKE) ./getarch_2nd$(GETARCH_FLAVOR) 0 >> $(TARGET_MAKE)
./getarch_2nd 1 >> $(TARGET_CONF) ./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) perl ./c_check $(TARGET_MAKE) $(TARGET_CONF) $(CC) $(TARGET_FLAGS) $(CFLAGS)
ifneq ($(ONLY_CBLAS), 1) ifneq ($(ONLY_CBLAS), 1)
perl ./f_check $(TARGET_MAKE) $(TARGET_CONF) $(FC) $(TARGET_FLAGS) perl ./f_check $(TARGET_MAKE) $(TARGET_CONF) $(FC) $(TARGET_FLAGS)
@ -66,18 +74,18 @@ else
echo "#define BUNDERSCORE _" >> $(TARGET_CONF) echo "#define BUNDERSCORE _" >> $(TARGET_CONF)
echo "#define NEEDBUNDERSCORE 1" >> $(TARGET_CONF) echo "#define NEEDBUNDERSCORE 1" >> $(TARGET_CONF)
endif endif
./getarch 0 >> $(TARGET_MAKE) ./getarch$(GETARCH_FLAVOR) 0 >> $(TARGET_MAKE)
./getarch 1 >> $(TARGET_CONF) ./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) $(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 ifndef TARGET_CORE
$(HOSTCC) -I. $(HOST_CFLAGS) -o $(@F) getarch_2nd.c $(HOSTCC) -I. $(HOST_CFLAGS) -o $(@F) getarch_2nd.c
else 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 endif
dummy: dummy:

View File

@ -298,8 +298,12 @@ HAVE_SSE5=
HAVE_AVX= HAVE_AVX=
HAVE_AVX2= HAVE_AVX2=
HAVE_FMA3= HAVE_FMA3=
ifeq ($(DYNAMIC_ARCH), 1)
include $(TOPDIR)/Makefile_kernel_$(TARGET_CORE).conf
else
include $(TOPDIR)/Makefile_kernel.conf include $(TOPDIR)/Makefile_kernel.conf
endif endif
endif
endif endif

View File

@ -629,7 +629,11 @@ else(NOT CMAKE_CROSSCOMPILING)
endif () endif ()
set(GETARCH_DIR "${PROJECT_BINARY_DIR}/getarch_build") set(GETARCH_DIR "${PROJECT_BINARY_DIR}/getarch_build")
if (DEFINED TARGET_CORE)
set(GETARCH_BIN "getarch-${TARGET_CORE}${CMAKE_EXECUTABLE_SUFFIX}")
else ()
set(GETARCH_BIN "getarch${CMAKE_EXECUTABLE_SUFFIX}") set(GETARCH_BIN "getarch${CMAKE_EXECUTABLE_SUFFIX}")
endif ()
file(MAKE_DIRECTORY ${GETARCH_DIR}) file(MAKE_DIRECTORY ${GETARCH_DIR})
configure_file(${TARGET_CONF_TEMP} ${GETARCH_DIR}/${TARGET_CONF} COPYONLY) configure_file(${TARGET_CONF_TEMP} ${GETARCH_DIR}/${TARGET_CONF} COPYONLY)
if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore") if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")

View File

@ -57,7 +57,11 @@ extern "C" {
#endif #endif
#ifdef BUILD_KERNEL #ifdef BUILD_KERNEL
#ifdef KERNEL_CONFIG
#include KERNEL_CONFIG
#else
#include "config_kernel.h" #include "config_kernel.h"
#endif
#else #else
#include "config.h" #include "config.h"
#endif #endif

View File

@ -2,8 +2,12 @@
#ifndef BUILD_KERNEL #ifndef BUILD_KERNEL
#include "config.h" #include "config.h"
#else #else
#ifdef KERNEL_CONFIG
#include KERNEL_CONFIG
#else
#include "config_kernel.h" #include "config_kernel.h"
#endif #endif
#endif
#if (defined(__WIN32__) || defined(__WIN64__) || defined(__CYGWIN32__) || defined(__CYGWIN64__) || defined(_WIN32) || defined(_WIN64)) && defined(__64BIT__) #if (defined(__WIN32__) || defined(__WIN64__) || defined(__CYGWIN32__) || defined(__CYGWIN64__) || defined(_WIN32) || defined(_WIN64)) && defined(__64BIT__)
typedef long long BLASLONG; typedef long long BLASLONG;
typedef unsigned long long BLASULONG; typedef unsigned long long BLASULONG;

View File

@ -124,7 +124,7 @@ COMMONOBJS += lsame.$(SUFFIX) scabs1.$(SUFFIX) dcabs1.$(SUFFIX)
ifeq ($(DYNAMIC_ARCH), 1) ifeq ($(DYNAMIC_ARCH), 1)
SBLASOBJS += setparam$(TSUFFIX).$(SUFFIX) SBLASOBJS += setparam$(TSUFFIX).$(SUFFIX)
CCOMMON_OPT += -DTS=$(TSUFFIX) CCOMMON_OPT += -DTS=$(TSUFFIX) -DKERNEL_CONFIG=\"config_kernel$(TSUFFIX).h\"
endif endif
KERNEL_INTERFACE = ../common_level1.h ../common_level2.h ../common_level3.h KERNEL_INTERFACE = ../common_level1.h ../common_level2.h ../common_level3.h