Skip to content

Commit 68b1713

Browse files
authored
Merge pull request #2811 from martin-frbg/issue2806
Make NO_AVX512 option override the AVX512 compile test in CMAKE builds as well
1 parent 4074770 commit 68b1713

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

cmake/system.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ if (NO_AVX2)
110110
set(GETARCH_FLAGS "${GETARCH_FLAGS} -DNO_AVX2")
111111
endif ()
112112

113+
if (NO_AVX512)
114+
message(STATUS "Disabling Advanced Vector Extensions 512 (AVX512).")
115+
set(GETARCH_FLAGS "${GETARCH_FLAGS} -DNO_AVX512")
116+
endif ()
117+
113118
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
114119
set(GETARCH_FLAGS "${GETARCH_FLAGS} ${CMAKE_C_FLAGS_DEBUG}")
115120
endif ()

cmake/system_check.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,15 @@ else()
109109
endif()
110110

111111
if (X86_64 OR X86)
112+
if (NOT NO_AVX512)
112113
file(WRITE ${PROJECT_BINARY_DIR}/avx512.c "#include <immintrin.h>\n\nint main(void){ __asm__ volatile(\"vbroadcastss -4 * 4(%rsi), %zmm2\"); }")
113114
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)
114115
if (NO_AVX512 EQUAL 1)
115116
set (CCOMMON_OPT "${CCOMMON_OPT} -DNO_AVX512")
116117
endif()
117118
file(REMOVE "avx512.c" "avx512.o")
118119
endif()
120+
endif()
119121

120122
include(CheckIncludeFile)
121123
CHECK_INCLUDE_FILE("stdatomic.h" HAVE_C11)

0 commit comments

Comments
 (0)