Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: pass -DINTEL* to gf-complete cflags #10956

Merged
merged 1 commit into from
Sep 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
66 changes: 66 additions & 0 deletions cmake/modules/SIMDExt.cmake
Original file line number Diff line number Diff line change
@@ -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()
72 changes: 0 additions & 72 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions src/erasure-code/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 2 additions & 0 deletions src/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down