peteryj / rpms / ceph

Forked from rpms/ceph 4 years ago
Clone

Blame SOURCES/0002-cmake-Support-ppc64.patch

f81482
From 2f0a7153460acc3f21462236f470ec3471fa2ee1 Mon Sep 17 00:00:00 2001
f81482
From: Boris Ranto <branto@redhat.com>
f81482
Date: Mon, 31 Jul 2017 19:50:23 +0200
f81482
Subject: [PATCH] cmake: Support ppc64
f81482
f81482
The ppc64 support requires a couple of changes:
f81482
- adding the ppc64 support to cmake
f81482
- changing optimized crc32 code to compile on ppc64le only
f81482
- moving ifdef condition before crc32_align to avoid defined but not
f81482
used warning
f81482
f81482
Signed-off-by: Boris Ranto <branto@redhat.com>
f81482
---
f81482
 cmake/modules/SIMDExt.cmake | 15 ++++++++++++++-
f81482
 src/CMakeLists.txt          |  4 +++-
f81482
 src/arch/ppc.c              |  8 ++++----
f81482
 src/common/crc32c_ppc.c     |  6 +++---
f81482
 4 files changed, 24 insertions(+), 9 deletions(-)
f81482
f81482
diff --git a/cmake/modules/SIMDExt.cmake b/cmake/modules/SIMDExt.cmake
f81482
index 5330835..c47667d 100644
f81482
--- a/cmake/modules/SIMDExt.cmake
f81482
+++ b/cmake/modules/SIMDExt.cmake
f81482
@@ -109,7 +109,20 @@ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i386|i686|amd64|x86_64|AMD64")
f81482
   endif(CMAKE_SYSTEM_PROCESSOR MATCHES "i686|amd64|x86_64|AMD64")
f81482
 elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(powerpc|ppc)64le")
f81482
   set(HAVE_PPC64LE 1)
f81482
-  message(STATUS " we are ppc64le")
f81482
+  message(STATUS " we are ppc64")
f81482
+  CHECK_C_COMPILER_FLAG("-maltivec" HAS_ALTIVEC)
f81482
+  if(HAS_ALTIVEC)
f81482
+    message(STATUS " HAS_ALTIVEC yes")
f81482
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maltivec")
f81482
+    set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -maltivec")
f81482
+  endif()
f81482
+  CHECK_C_COMPILER_FLAG("-mcpu=power8" HAVE_POWER8)
f81482
+  if(HAVE_POWER8)
f81482
+    message(STATUS " HAVE_POWER8 yes")
f81482
+  endif()
f81482
+elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(power|ppc)64")
f81482
+  set(HAVE_PPC64 1)
f81482
+  message(STATUS " we are ppc64")
f81482
   CHECK_C_COMPILER_FLAG("-maltivec" HAS_ALTIVEC)
f81482
   if(HAS_ALTIVEC)
f81482
     message(STATUS " HAS_ALTIVEC yes")
f81482
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
f81482
index 66f0c14..38d1913 100644
f81482
--- a/src/CMakeLists.txt
f81482
+++ b/src/CMakeLists.txt
f81482
@@ -568,7 +568,9 @@ if(HAVE_INTEL)
f81482
   endif(HAVE_GOOD_YASM_ELF64)
f81482
 elseif(HAVE_POWER8)
f81482
   list(APPEND libcommon_files
f81482
-    common/crc32c_ppc.c
f81482
+    common/crc32c_ppc.c)
f81482
+elseif(HAVE_PPC64LE)
f81482
+  list(APPEND libcommon_files
f81482
     common/crc32c_ppc_asm.S
f81482
     common/crc32c_ppc_fast_zero_asm.S)
f81482
 endif(HAVE_INTEL)
f81482
diff --git a/src/arch/ppc.c b/src/arch/ppc.c
f81482
index f21e2fe..11d3a49 100644
f81482
--- a/src/arch/ppc.c
f81482
+++ b/src/arch/ppc.c
f81482
@@ -14,10 +14,10 @@ int ceph_arch_ppc_crc32 = 0;
f81482
 
f81482
 #include <stdio.h>
f81482
 
f81482
-#if __linux__ && __powerpc64__
f81482
+#ifdef HAVE_PPC64LE
f81482
 #include <sys/auxv.h>
f81482
 #include <asm/cputable.h>
f81482
-#endif /* __linux__ && __powerpc64__ */
f81482
+#endif /* HAVE_PPC64LE */
f81482
 
f81482
 #ifndef PPC_FEATURE2_VEC_CRYPTO
f81482
 #define PPC_FEATURE2_VEC_CRYPTO		0x02000000
f81482
@@ -31,9 +31,9 @@ int ceph_arch_ppc_probe(void)
f81482
 {
f81482
   ceph_arch_ppc_crc32 = 0;
f81482
 
f81482
-#if __linux__ && __powerpc64__
f81482
+#ifdef HAVE_PPC64LE
f81482
   if (getauxval(AT_HWCAP2) & PPC_FEATURE2_VEC_CRYPTO) ceph_arch_ppc_crc32 = 1;
f81482
-#endif /* __linux__ && __powerpc64__ */
f81482
+#endif /* HAVE_PPC64LE */
f81482
 
f81482
   return 0;
f81482
 }
f81482
diff --git a/src/common/crc32c_ppc.c b/src/common/crc32c_ppc.c
f81482
index 43756e2..52fd1c4 100644
f81482
--- a/src/common/crc32c_ppc.c
f81482
+++ b/src/common/crc32c_ppc.c
f81482
@@ -20,6 +20,7 @@
f81482
 #define VMX_ALIGN	16
f81482
 #define VMX_ALIGN_MASK	(VMX_ALIGN-1)
f81482
 
f81482
+#ifdef HAVE_PPC64LE
f81482
 #ifdef REFLECT
f81482
 static unsigned int crc32_align(unsigned int crc, unsigned char const *p,
f81482
                                 unsigned long len)
f81482
@@ -38,7 +39,6 @@ static unsigned int crc32_align(unsigned int crc, unsigned char const *p,
f81482
 }
f81482
 #endif
f81482
 
f81482
-#ifdef HAVE_POWER8
f81482
 static inline unsigned long polynomial_multiply(unsigned int a, unsigned int b) {
f81482
         vector unsigned int va = {a, 0, 0, 0};
f81482
         vector unsigned int vb = {b, 0, 0, 0};
f81482
@@ -134,7 +134,7 @@ uint32_t ceph_crc32c_ppc(uint32_t crc, unsigned char const *data, unsigned len)
f81482
   return crc;
f81482
 }
f81482
 
f81482
-#else /* HAVE_POWER8 */
f81482
+#else /* HAVE_PPC64LE */
f81482
 
f81482
 /* This symbol has to exist on non-ppc architectures (and on legacy
f81482
  * ppc systems using power7 or below) in order to compile properly
f81482
@@ -145,4 +145,4 @@ uint32_t ceph_crc32c_ppc(uint32_t crc, unsigned char const *data, unsigned len)
f81482
   return 0;
f81482
 }
f81482
 
f81482
-#endif /* HAVE_POWER8 */
f81482
+#endif /* HAVE_PPC64LE */
f81482
-- 
f81482
2.9.4
f81482