File openblas-ppc64be_up2_p8.patch of Package openblas

From 1d6e9be8108677ff9b662fa96737172499d48ed9 Mon Sep 17 00:00:00 2001
From: Michel Normand <normand@linux.vnet.ibm.com>
Date: Wed, 3 Feb 2021 15:39:25 +0100
Subject: [PATCH] openblas ppc64be up2 p8

openblas ppc64be up2 p8

because:
* openblas build failed for ppc64 (BE) in openSUSE
  since version 0.3.12
* ppc64 (BE) not supported by IBM after P8.

Signed-off-by: Michel Normand <normand@linux.vnet.ibm.com>
---
 Makefile.system               | 10 +++++++---
 driver/others/dynamic_power.c | 11 +++++++++++
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/Makefile.system b/Makefile.system
index 38646c3c6..78e7c00a5 100644
--- a/Makefile.system
+++ b/Makefile.system
@@ -792,6 +792,9 @@ ifeq ($(ARCH), power)
 ifneq ($(C_COMPILER), PGI)
 DYNAMIC_CORE = POWER6
 DYNAMIC_CORE += POWER8
+ifeq ($(__BYTE_ORDER__),__ORDER_BIG_ENDIAN__)
+$(info, OpenBLAS: for big endian limit to POWER8 kernels.)
+else
 ifneq ($(C_COMPILER), GCC)
 DYNAMIC_CORE += POWER9
 DYNAMIC_CORE += POWER10
@@ -820,11 +823,12 @@ else
 $(info, OpenBLAS: Your gcc version is too old to build the POWER10 kernels.)
 endif
 endif
-else
+endif # __ORDER_BIG_ENDIAN__
+else # C_COMPILER PGI
 DYNAMIC_CORE = POWER8
 DYNAMIC_CORE += POWER9
-endif
-endif
+endif # C_COMPILER PGI
+endif # ARCH power
 
 # If DYNAMIC_CORE is not set, DYNAMIC_ARCH cannot do anything, so force it to empty
 ifndef DYNAMIC_CORE
diff --git a/driver/others/dynamic_power.c b/driver/others/dynamic_power.c
index 4c1f4a26e..4216da19b 100644
--- a/driver/others/dynamic_power.c
+++ b/driver/others/dynamic_power.c
@@ -3,12 +3,14 @@
 
 extern gotoblas_t gotoblas_POWER6;
 extern gotoblas_t gotoblas_POWER8;
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
 #if ((!defined __GNUC__) || ( __GNUC__ >= 6)) || defined(__clang__)
 extern gotoblas_t gotoblas_POWER9;
 #endif
 #ifdef HAVE_P10_SUPPORT
 extern gotoblas_t gotoblas_POWER10;
 #endif
+#endif
 
 extern void openblas_warning(int verbose, const char *msg);
 
@@ -28,10 +30,12 @@ char *gotoblas_corename(void) {
 #endif
 	if (gotoblas == &gotoblas_POWER8)	return corename[2];
 #if ((!defined __GNUC__) || ( __GNUC__ >= 6)) || defined(__clang__)
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
 	if (gotoblas == &gotoblas_POWER9)	return corename[3];
 #endif
 #ifdef HAVE_P10_SUPPORT
 	if (gotoblas == &gotoblas_POWER10)	return corename[4];
+#endif
 #endif
 	return corename[0];
 }
@@ -257,6 +261,10 @@ static gotoblas_t *get_coretype(void) {
 #endif
 	if (__builtin_cpu_is("power8"))
 		return &gotoblas_POWER8;
+	/* Fall back to the POWER8 implementation for big endian */
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+		return &gotoblas_POWER8;
+#else
 #if ((!defined __GNUC__) || ( __GNUC__ >= 6)) || defined(__clang__)
 	if (__builtin_cpu_is("power9"))
 		return &gotoblas_POWER9;
@@ -273,6 +281,7 @@ static gotoblas_t *get_coretype(void) {
 #if (!defined __GNUC__) || ( __GNUC__ >= 11) || (__GNUC__ == 10 && __GNUC_MINOR__ >= 2)
 	if (__builtin_cpu_is("power10"))
 		return &gotoblas_POWER9;
+#endif
 #endif
 	return NULL;
 }
@@ -298,11 +307,13 @@ static gotoblas_t *force_coretype(char * coretype) {
 	case  1: return (&gotoblas_POWER6);
 #endif
 	case  2: return (&gotoblas_POWER8);
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
 #if ((!defined __GNUC__) || ( __GNUC__ >= 6)) || defined(__clang__)
 	case  3: return (&gotoblas_POWER9);
 #endif
 #ifdef HAVE_P10_SUPPORT
 	case  4: return (&gotoblas_POWER10);
+#endif
 #endif
 	default: return NULL;
 	}
-- 
2.46.1

openSUSE Build Service is sponsored by