提交 dc9c5e76 编写于 作者: H Haojun Liao

enh: dynamically check the support of fma/avx/sse42/avx2 in cmake files.

上级 eeefd1a4
...@@ -123,21 +123,31 @@ ELSE () ...@@ -123,21 +123,31 @@ ELSE ()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k")
ENDIF () ENDIF ()
IF (TD_INTEL_64 OR TD_INTEL_32) INCLUDE(CheckCCompilerFlag)
ADD_DEFINITIONS("-msse4.2") CHECK_C_COMPILER_FLAG("-msse4.2" GCC_SUPPORT_SSE42)
IF("${FMA_SUPPORT}" MATCHES "true") CHECK_C_COMPILER_FLAG("-mfma" GCC_SUPPORT_FMA)
MESSAGE(STATUS "fma function supported") CHECK_C_COMPILER_FLAG("-mavx" GCC_SUPPORT_AVX)
ADD_DEFINITIONS("-mfma") CHECK_C_COMPILER_FLAG("-mavx2" GCC_SUPPORT_AVX2)
ELSE ()
MESSAGE(STATUS "fma function NOT supported") IF (GCC_SUPPORT_SSE42)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.2")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
ENDIF()
IF (GCC_SUPPORT_FMA)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfma")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfma")
ENDIF()
IF ("${SIMD_SUPPORT}" MATCHES "true")
IF (GCC_SUPPORT_AVX)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx")
ENDIF() ENDIF()
IF (GCC_SUPPORT_AVX2)
IF("${SIMD_SUPPORT}" MATCHES "true") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx2")
ADD_DEFINITIONS("-mavx -mavx2") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx2")
MESSAGE(STATUS "SIMD instructions (AVX/AVX2) is ACTIVATED")
ELSE()
MESSAGE(STATUS "SIMD instruction (AVX/AVX2)is NOT ACTIVATED")
ENDIF() ENDIF()
ENDIF () MESSAGE(STATUS "SIMD instructions (AVX/AVX2) is ACTIVATED")
ENDIF()
ENDIF () ENDIF ()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册