From 68b1713c300ac152d1efcb3c02f0c59fafcd39e1 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Tue, 1 Sep 2020 17:19:14 +0200 Subject: [PATCH] Merge pull request #2811 from martin-frbg/issue2806 Make NO_AVX512 option override the AVX512 compile test in CMAKE builds as well --- cmake/system.cmake | 5 +++++ cmake/system_check.cmake | 2 ++ 2 files changed, 7 insertions(+) diff --git a/cmake/system.cmake b/cmake/system.cmake index e3617c4..c0f3c6e 100644 --- a/cmake/system.cmake +++ b/cmake/system.cmake @@ -110,6 +110,11 @@ if (NO_AVX2) set(GETARCH_FLAGS "${GETARCH_FLAGS} -DNO_AVX2") endif () +if (NO_AVX512) + message(STATUS "Disabling Advanced Vector Extensions 512 (AVX512).") + set(GETARCH_FLAGS "${GETARCH_FLAGS} -DNO_AVX512") +endif () + if (CMAKE_BUILD_TYPE STREQUAL "Debug") set(GETARCH_FLAGS "${GETARCH_FLAGS} ${CMAKE_C_FLAGS_DEBUG}") endif () diff --git a/cmake/system_check.cmake b/cmake/system_check.cmake index 511a7c7..d06f477 100644 --- a/cmake/system_check.cmake +++ b/cmake/system_check.cmake @@ -109,6 +109,7 @@ else() endif() if (X86_64 OR X86) +if (NOT NO_AVX512) file(WRITE ${PROJECT_BINARY_DIR}/avx512.c "#include \n\nint main(void){ __asm__ volatile(\"vbroadcastss -4 * 4(%rsi), %zmm2\"); }") execute_process(COMMAND ${CMAKE_C_COMPILER} -march=skylake-avx512 -c -v -o ${PROJECT_BINARY_DIR}/avx512.o ${PROJECT_BINARY_DIR}/avx512.c OUTPUT_QUIET ERROR_QUIET RESULT_VARIABLE NO_AVX512) if (NO_AVX512 EQUAL 1) @@ -116,6 +117,7 @@ set (CCOMMON_OPT "${CCOMMON_OPT} -DNO_AVX512") endif() file(REMOVE "avx512.c" "avx512.o") endif() +endif() include(CheckIncludeFile) CHECK_INCLUDE_FILE("stdatomic.h" HAVE_C11) -- 2.7.4