]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: pass -DINTEL* to gf-complete cflags 10956/head
authorKefu Chai <kchai@redhat.com>
Fri, 2 Sep 2016 06:38:21 +0000 (14:38 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 2 Sep 2016 08:23:54 +0000 (16:23 +0800)
* in addition to the -march=foobar, we also need to pass -DFOOBAR to
  gf-complete sources' cflags, so that the SIMD instructions can be
  generated as expected.
* also extract the compiler support for instruction extensions detections
  into SIMDExt.cmake.
* and only check the compiler support if CMAKE_SYSTEM_PROCESSOR matches
  with the instruction-set/arch to be checked.

Signed-off-by: tone.zhang <tone.zhang@linaro.org>
Signed-off-by: Kefu Chai <kchai@redhat.com>
cmake/modules/SIMDExt.cmake [new file with mode: 0644]
src/CMakeLists.txt
src/erasure-code/CMakeLists.txt
src/test/CMakeLists.txt

diff --git a/cmake/modules/SIMDExt.cmake b/cmake/modules/SIMDExt.cmake
new file mode 100644 (file)
index 0000000..bc08514
--- /dev/null
@@ -0,0 +1,66 @@
+# detect SIMD extentions
+#
+# ARM_NEON_FLAGS
+#
+# HAVE_ARMV8_CRC
+# HAVE_NEON
+# HAVE_SSE
+# HAVE_SSE2
+#
+# INTEL_SSE4_1
+# INTEL_SSE4_2
+#
+# SSE3_FLAGS
+# SSE4_FLAGS
+#
+
+if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|AARCH64")
+  CHECK_C_COMPILER_FLAG(-march=armv8-a+crc HAVE_ARMV8_CRC)
+  if(HAVE_ARMV8_CRC)
+    set(ARM_NEON_FLAGS "-march=armv8-a+crc -DARCH_AARCH64")
+  endif()
+  CHECK_C_COMPILER_FLAG(-march=armv8-a+simd HAVE_NEON)
+  if(HAVE_NEON)
+    set(ARM_NEON_FLAGS "-march=armv8-a+simd -DARCH_AARCH64 -DARM_NEON")
+  endif()
+elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm|ARM")
+  CHECK_C_COMPILER_FLAG(-mfpu=neon HAVE_NEON)
+  if(HAVE_NEON)
+    set(ARM_NEON_FLAGS "-mfpu=neon -DARM_NEON")
+  endif()
+elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i386|i686|amd64|x86_64|AMD64")
+  set(SSE3_FLAGS)
+  CHECK_C_COMPILER_FLAG(-msse HAVE_SSE)
+  if(HAVE_SSE)
+    set(SSE3_FLAGS "${SSE3_FLAGS} -msse -DINTEL_SSE")
+  endif()
+
+  CHECK_C_COMPILER_FLAG(-msse2 HAVE_SSE2)
+  if(HAVE_SSE2)
+    set(SSE3_FLAGS "${SSE3_FLAGS} -msse2 -DINTEL_SSE2")
+  endif()
+
+  CHECK_C_COMPILER_FLAG(-msse3 HAVE_SSE3)
+  if(HAVE_SSE3)
+    set(SSE3_FLAGS "${SSE3_FLAGS} -msse3 -DINTEL_SSE3")
+  endif()
+
+  CHECK_C_COMPILER_FLAG(-mssse3 SUPPORTS_SSSE3)
+  if(SUPPORTS_SSSE3)
+    set(SSE3_FLAGS "${SSE3_FLAGS} -mssse3 -DINTEL_SSSE3")
+  endif()
+
+  # pclmul is not enabled in SSE3, otherwise we need another
+  # flavor or an cmake option for enabling it
+
+  set(SSE4_FLAGS ${SSE3_FLAGS})
+  CHECK_C_COMPILER_FLAG(-msse4.1 INTEL_SSE4_1)
+  if(SUPPORTS_SSE41)
+    set(SSE4_FLAGS "${SSE4_FLAGS} -msse41 -DINTEL_SSE4")
+  endif()
+
+  CHECK_C_COMPILER_FLAG(-msse4.2 INTEL_SSE4_2)
+  if(SUPPORTS_SSE42)
+    set(SSE4_FLAGS "${SSE4_FLAGS} -msse42 -DINTEL_SSE4")
+  endif()
+endif()
index 10f6b3079e4762624cf1714f25b1160067ff8c9b..9afe2b3ef91e3839b46b5e2dcdd34445a6b5753f 100644 (file)
@@ -146,78 +146,6 @@ if(COMPILER_SUPPORTS_DIAGNOSTICS_COLOR)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=${DIAGNOSTICS_COLOR}")
 endif()
 
-
-## detect sse support
-
-# create a tmp file with an empty main()
-set(sse_srcs "${CMAKE_BINARY_DIR}/src/erasure-code/jerasure/tmp_sse.c")
-file(WRITE ${sse_srcs} "void main() {}")
-
-# try each -msse flag
-try_compile(INTEL_SSE ${CMAKE_BINARY_DIR} ${sse_srcs}
-  COMPILE_DEFINITIONS "-msse")
-try_compile(INTEL_SSE2 ${CMAKE_BINARY_DIR} ${sse_srcs}
-  COMPILE_DEFINITIONS "-msse2")
-try_compile(INTEL_SSE3 ${CMAKE_BINARY_DIR} ${sse_srcs}
-  COMPILE_DEFINITIONS "-msse3")
-try_compile(INTEL_SSSE3 ${CMAKE_BINARY_DIR} ${sse_srcs}
-  COMPILE_DEFINITIONS "-mssse3")
-try_compile(INTEL_SSE4_1 ${CMAKE_BINARY_DIR} ${sse_srcs}
-  COMPILE_DEFINITIONS "-msse4.1")
-try_compile(INTEL_SSE4_2 ${CMAKE_BINARY_DIR} ${sse_srcs}
-  COMPILE_DEFINITIONS "-msse4.2")
-try_compile(ARM_NEON ${CMAKE_BINARY_DIR} ${sse_srcs}
-  COMPILE_DEFINITIONS "-mfpu=neon")
-try_compile(ARM_NEON2 ${CMAKE_BINARY_DIR} ${sse_srcs}
-  COMPILE_DEFINITIONS "-march=armv8-a+simd")
-try_compile(ARM_CRC ${CMAKE_BINARY_DIR} ${sse_srcs}
-  COMPILE_DEFINITIONS "-march=armv8-a+crc")
-
-# clean up tmp file
-file(REMOVE ${sse_srcs})
-
-if(ARM_CRC)
-  set(HAVE_ARMV8_CRC 1)
-  set(ARM_CRC_FLAGS "-march=armv8-a+crc -DARCH_AARCH64")
-endif(ARM_CRC)
-
-if(ARM_NEON OR ARM_NEON2)
-  set(HAVE_NEON 1)
-  if(ARM_NEON)
-    set(ARM_NEON_FLAGS "-mfpu=neon -DARM_NEON")
-  else(ARM_NEON)
-    set(ARM_NEON_FLAGS "-march=armv8-a+simd -DARCH_AARCH64 -DARM_NEON")
-  endif(ARM_NEON)
-else(ARM_NEON OR ARM_NEON2)
-  message(STATUS "Skipping target ec_jerasure_neon & ec_shec_neon: Architecture not ARM")
-endif(ARM_NEON OR ARM_NEON2)
-
-if(INTEL_SSE)
-  set(HAVE_SSE 1)
-  set(SSE3_FLAGS "-msse")
-  if (INTEL_SSE2)
-    set(HAVE_SSE2 1)
-    set(SSE3_FLAGS "${SSE3_FLAGS} -msse2")
-  endif (INTEL_SSE2)
-  if (INTEL_SSE3)
-    set(SSE3_FLAGS "${SSE3_FLAGS} -msse3")
-  endif (INTEL_SSE3)
-  if (INTEL_SSSE3)
-    set(SSE3_FLAGS "${SSE3_FLAGS} -mssse3")
-  endif (INTEL_SSSE3)
-else(INTEL_SSE)
-  message(STATUS "Skipping target ec_jerasure_sse3 & ec_shec_sse3: -msse not supported")
-endif(INTEL_SSE)
-
-if(INTEL_SSE4_1)
-  set(SSE4_FLAGS "${SSE3_FLAGS} -msse4.1")
-  if (INTEL_SSE4_2)
-    set(SSE4_FLAGS "${SSE4_FLAGS} -msse4.2")
-  endif (INTEL_SSE4_2)
-else(INTEL_SSE4_1)
-  message(STATUS "Skipping target ec_jerasure_sse4 & ec_shec_sse4: -msse4.1 not supported")
-endif(INTEL_SSE4_1)
-
 set(EXTRALIBS rt ${CMAKE_DL_LIBS} ${ATOMIC_OPS_LIBRARIES})
 if(LINUX)
   set(LIB_RESOLV resolv)
index 7859a7f20d1c5cf06d20270cf208769d1928c2e0..86ecbbc813325966406aa8068d6a9f61bf9bd937 100644 (file)
@@ -7,16 +7,17 @@ include_directories(jerasure/jerasure/include)
 include_directories(jerasure/gf-complete/include)
 include_directories(jerasure)
 
+include(SIMDExt)
 
 if(TRUE)
   list(APPEND jerasure_flavors generic)
 endif()
 
-if(ARM_NEON OR ARM_NEON2)
+if(HAVE_NEON)
   list(APPEND jerasure_flavors neon)
 endif()
 
-if(INTEL_SSE)
+if(HAVE_SSE)
   list(APPEND jerasure_flavors sse3)
 endif()
 
index 8c1c2814ad4bcd6614717fc0e2011b8f96cef138..93283537d09bc035789b5647853223431d4f9302 100644 (file)
@@ -363,6 +363,8 @@ target_link_libraries(ceph_multi_stress_watch librados global radostest
   ${BLKID_LIBRARIES} ${CMAKE_DL_LIBS})
 
 #ceph_perf_local
+include(SIMDExt)
+
 add_executable(ceph_perf_local 
   perf_local.cc
   perf_helper.cc)