mirror of https://github.com/PentHertz/srsLTE.git
Avoid GCC native architecture for AVX512 CPUs when AVX512 is disabled
This commit is contained in:
parent
6297a22697
commit
ef799a9b42
|
@ -406,8 +406,8 @@ if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
|
|||
endif (HAVE_FMA)
|
||||
|
||||
if (HAVE_AVX512)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=${GCC_ARCH} -mavx512f -mavx512cd -mavx512bw -mavx512dq -DLV_HAVE_AVX512")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=${GCC_ARCH} -mavx512f -mavx512cd -mavx512bw -mavx512dq -DLV_HAVE_AVX512")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx512f -mavx512cd -mavx512bw -mavx512dq -DLV_HAVE_AVX512")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx512f -mavx512cd -mavx512bw -mavx512dq -DLV_HAVE_AVX512")
|
||||
endif(HAVE_AVX512)
|
||||
|
||||
if(NOT ${CMAKE_BUILD_TYPE} STREQUAL "Debug")
|
||||
|
|
|
@ -168,6 +168,20 @@ if (ENABLE_SSE)
|
|||
if (HAVE_AVX512)
|
||||
message(STATUS "AVX512 is enabled - target CPU must support it")
|
||||
endif()
|
||||
elseif (${GCC_ARCH} MATCHES "native" AND CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
# When GCC flag -march=native and the CPU supports AVX512 (skylake-avx512 architecture), GCC uses AVX512 instructions
|
||||
# automatically, independently of the rest of flags.
|
||||
|
||||
# Get the CPU architecture
|
||||
execute_process(COMMAND ${CMAKE_C_COMPILER} -march=native -Q --help=target
|
||||
OUTPUT_VARIABLE DETECT_SKYLAKE_AVX512)
|
||||
|
||||
# Check if the native architecture matches with skylake-avx512
|
||||
if (${DETECT_SKYLAKE_AVX512} MATCHES "march=.*skylake-avx512")
|
||||
# Force skylake architecture without AVX512
|
||||
set(GCC_ARCH "skylake")
|
||||
message(STATUS "This is a skylake-avx512 CPU, as AVX512 was disabled the architecture will be set to skylake")
|
||||
endif (${IS_SKYLAKE_AVX512})
|
||||
endif()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue