s390x/DYNAMIC_ARCH: pass supported arch levels from Makefile to run-time code

... instead of duplicating the (old) mechanism from the Makefile that
aimed to derive supported architecture generations from the gcc
version.

To enable builds with DYNAMIC_ARCH with older compiler releases, the
Makefile and drivers/other/dynamic_arch.c need a common view of the
architecture support built into the library.

We follow the notation from x86 when used with DYNAMIC_LIST, where
defines DYN_<ARCH NAME> denote support for a given generation to be
built in. Since there are far fewer architecture generations in OpenBLAS
for s390x, that does not bloat command lines too much.

Signed-off-by: Marius Hillenbrand <mhillen@linux.ibm.com>
This commit is contained in:
Marius Hillenbrand 2020-09-07 17:04:03 +02:00
parent 0629d8ebdb
commit 4f34bcfb5e
2 changed files with 24 additions and 26 deletions

View File

@ -606,6 +606,7 @@ ZARCH_CC_SUPPORTS_Z13=$(shell $(CC) -march=z13 $(ZARCH_TEST_COMPILE) && echo 1)
ifeq ($(or $(ZARCH_CC_SUPPORTS_ARCH11), $(ZARCH_CC_SUPPORTS_Z13)), 1)
DYNAMIC_CORE += Z13
CCOMMON_OPT += -DDYN_Z13
else
$(info OpenBLAS: Not building Z13 kernels because the compiler $(CC) does not support it)
endif
@ -615,6 +616,7 @@ ZARCH_CC_SUPPORTS_ARCH12=$(shell $(CC) -march=arch12 $(ZARCH_TEST_COMPILE) && ec
ZARCH_CC_SUPPORTS_Z14=$(shell $(CC) -march=z14 $(ZARCH_TEST_COMPILE) && echo 1)
ifeq ($(or $(ZARCH_CC_SUPPORTS_ARCH12), $(ZARCH_CC_SUPPORTS_Z14)), 1)
DYNAMIC_CORE += Z14
CCOMMON_OPT += -DDYN_Z14
else
$(info OpenBLAS: Not building Z14 kernels because the compiler $(CC) does not support it)
endif

View File

@ -1,18 +1,6 @@
#include "common.h"
#include <stdbool.h>
// Gate kernels for z13 and z14 on gcc version
#if (__GNUC__ == 5 && __GNUC_MINOR__ >= 2) || __GNUC__ >= 6 || \
/* RHEL 7 since 7.3: */ \
(__GNUC__ == 4 && __GNUC_MINOR__ == 8 && __GNUC_PATCHLEVEL__ == 5 && \
__GNUC_RH_RELEASE__ >= 11)
#define HAVE_Z13_SUPPORT
#endif
#if __GNUC__ >= 7
#define HAVE_Z14_SUPPORT
#endif
// Guard the use of getauxval() on glibc version >= 2.16
#ifdef __GLIBC__
#include <features.h>
@ -47,10 +35,10 @@ static unsigned long get_hwcap(void) {
#endif // __GLIBC
extern gotoblas_t gotoblas_ZARCH_GENERIC;
#ifdef HAVE_Z13_SUPPORT
#ifdef DYN_Z13
extern gotoblas_t gotoblas_Z13;
#endif
#ifdef HAVE_Z14_SUPPORT
#ifdef DYN_Z14
extern gotoblas_t gotoblas_Z14;
#endif
@ -66,10 +54,10 @@ static char* corename[] = {
};
char* gotoblas_corename(void) {
#ifdef HAVE_Z13_SUPPORT
#ifdef DYN_Z13
if (gotoblas == &gotoblas_Z13) return corename[1];
#endif
#ifdef HAVE_Z14_SUPPORT
#ifdef DYN_Z14
if (gotoblas == &gotoblas_Z14) return corename[2];
#endif
if (gotoblas == &gotoblas_ZARCH_GENERIC) return corename[3];
@ -89,15 +77,15 @@ static gotoblas_t* get_coretype(void) {
unsigned long hwcap __attribute__((unused)) = get_hwcap();
#ifdef DYN_Z14
// z14 and z15 systems: exploit Vector Facility (SIMD) and
// Vector-Enhancements Facility 1 (float SIMD instructions), if present.
#ifdef HAVE_Z14_SUPPORT
if ((hwcap & HWCAP_S390_VX) && (hwcap & HWCAP_S390_VXE))
return &gotoblas_Z14;
#endif
#ifdef DYN_Z13
// z13: Vector Facility (SIMD for double)
#ifdef HAVE_Z13_SUPPORT
if (hwcap & HWCAP_S390_VX)
return &gotoblas_Z13;
#endif
@ -123,19 +111,27 @@ static gotoblas_t* force_coretype(char* coretype) {
}
}
switch (found)
{
#ifdef HAVE_Z13_SUPPORT
case 1: return (&gotoblas_Z13);
if (found == 1) {
#ifdef DYN_Z13
return &gotoblas_Z13;
#else
openblas_warning(1, "Z13 support not compiled in");
return NULL;
#endif
#ifdef HAVE_Z14_SUPPORT
case 2: return (&gotoblas_Z14);
} else if (found == 2) {
#ifdef DYN_Z14
return &gotoblas_Z14;
#else
openblas_warning(1, "Z14 support not compiled in");
return NULL;
#endif
case 3: return (&gotoblas_ZARCH_GENERIC);
default: return NULL;
} else if (found == 3) {
return &gotoblas_ZARCH_GENERIC;
}
snprintf(message, 128, "Core not found: %s\n", coretype);
openblas_warning(1, message);
return NULL;
}
void gotoblas_dynamic_init(void) {