Skip to content

Commit 4f34bcf

Browse files
committed
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 <[email protected]>
1 parent 0629d8e commit 4f34bcf

File tree

2 files changed

+24
-26
lines changed

2 files changed

+24
-26
lines changed

Makefile.system

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,7 @@ ZARCH_CC_SUPPORTS_Z13=$(shell $(CC) -march=z13 $(ZARCH_TEST_COMPILE) && echo 1)
606606

607607
ifeq ($(or $(ZARCH_CC_SUPPORTS_ARCH11), $(ZARCH_CC_SUPPORTS_Z13)), 1)
608608
DYNAMIC_CORE += Z13
609+
CCOMMON_OPT += -DDYN_Z13
609610
else
610611
$(info OpenBLAS: Not building Z13 kernels because the compiler $(CC) does not support it)
611612
endif
@@ -615,6 +616,7 @@ ZARCH_CC_SUPPORTS_ARCH12=$(shell $(CC) -march=arch12 $(ZARCH_TEST_COMPILE) && ec
615616
ZARCH_CC_SUPPORTS_Z14=$(shell $(CC) -march=z14 $(ZARCH_TEST_COMPILE) && echo 1)
616617
ifeq ($(or $(ZARCH_CC_SUPPORTS_ARCH12), $(ZARCH_CC_SUPPORTS_Z14)), 1)
617618
DYNAMIC_CORE += Z14
619+
CCOMMON_OPT += -DDYN_Z14
618620
else
619621
$(info OpenBLAS: Not building Z14 kernels because the compiler $(CC) does not support it)
620622
endif

driver/others/dynamic_zarch.c

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
11
#include "common.h"
22
#include <stdbool.h>
33

4-
// Gate kernels for z13 and z14 on gcc version
5-
#if (__GNUC__ == 5 && __GNUC_MINOR__ >= 2) || __GNUC__ >= 6 || \
6-
/* RHEL 7 since 7.3: */ \
7-
(__GNUC__ == 4 && __GNUC_MINOR__ == 8 && __GNUC_PATCHLEVEL__ == 5 && \
8-
__GNUC_RH_RELEASE__ >= 11)
9-
#define HAVE_Z13_SUPPORT
10-
#endif
11-
12-
#if __GNUC__ >= 7
13-
#define HAVE_Z14_SUPPORT
14-
#endif
15-
164
// Guard the use of getauxval() on glibc version >= 2.16
175
#ifdef __GLIBC__
186
#include <features.h>
@@ -47,10 +35,10 @@ static unsigned long get_hwcap(void) {
4735
#endif // __GLIBC
4836

4937
extern gotoblas_t gotoblas_ZARCH_GENERIC;
50-
#ifdef HAVE_Z13_SUPPORT
38+
#ifdef DYN_Z13
5139
extern gotoblas_t gotoblas_Z13;
5240
#endif
53-
#ifdef HAVE_Z14_SUPPORT
41+
#ifdef DYN_Z14
5442
extern gotoblas_t gotoblas_Z14;
5543
#endif
5644

@@ -66,10 +54,10 @@ static char* corename[] = {
6654
};
6755

6856
char* gotoblas_corename(void) {
69-
#ifdef HAVE_Z13_SUPPORT
57+
#ifdef DYN_Z13
7058
if (gotoblas == &gotoblas_Z13) return corename[1];
7159
#endif
72-
#ifdef HAVE_Z14_SUPPORT
60+
#ifdef DYN_Z14
7361
if (gotoblas == &gotoblas_Z14) return corename[2];
7462
#endif
7563
if (gotoblas == &gotoblas_ZARCH_GENERIC) return corename[3];
@@ -89,15 +77,15 @@ static gotoblas_t* get_coretype(void) {
8977

9078
unsigned long hwcap __attribute__((unused)) = get_hwcap();
9179

80+
#ifdef DYN_Z14
9281
// z14 and z15 systems: exploit Vector Facility (SIMD) and
9382
// Vector-Enhancements Facility 1 (float SIMD instructions), if present.
94-
#ifdef HAVE_Z14_SUPPORT
9583
if ((hwcap & HWCAP_S390_VX) && (hwcap & HWCAP_S390_VXE))
9684
return &gotoblas_Z14;
9785
#endif
9886

87+
#ifdef DYN_Z13
9988
// z13: Vector Facility (SIMD for double)
100-
#ifdef HAVE_Z13_SUPPORT
10189
if (hwcap & HWCAP_S390_VX)
10290
return &gotoblas_Z13;
10391
#endif
@@ -123,19 +111,27 @@ static gotoblas_t* force_coretype(char* coretype) {
123111
}
124112
}
125113

126-
switch (found)
127-
{
128-
#ifdef HAVE_Z13_SUPPORT
129-
case 1: return (&gotoblas_Z13);
114+
if (found == 1) {
115+
#ifdef DYN_Z13
116+
return &gotoblas_Z13;
117+
#else
118+
openblas_warning(1, "Z13 support not compiled in");
119+
return NULL;
130120
#endif
131-
#ifdef HAVE_Z14_SUPPORT
132-
case 2: return (&gotoblas_Z14);
121+
} else if (found == 2) {
122+
#ifdef DYN_Z14
123+
return &gotoblas_Z14;
124+
#else
125+
openblas_warning(1, "Z14 support not compiled in");
126+
return NULL;
133127
#endif
134-
case 3: return (&gotoblas_ZARCH_GENERIC);
135-
default: return NULL;
128+
} else if (found == 3) {
129+
return &gotoblas_ZARCH_GENERIC;
136130
}
131+
137132
snprintf(message, 128, "Core not found: %s\n", coretype);
138133
openblas_warning(1, message);
134+
return NULL;
139135
}
140136

141137
void gotoblas_dynamic_init(void) {

0 commit comments

Comments
 (0)