Skip to content

Commit 34b7f01

Browse files
authored
Declare fma requirement at CMakeLists.txt (infiniflow#1162)
Declare fma requirement at CMakeLists.txt Issue link:infiniflow#1161 ### Type of change - [x] Documentation Update
1 parent 2b1d403 commit 34b7f01

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

src/CMakeLists.txt

+26-8
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,26 @@ add_subdirectory(parser)
1616
# add_definitions(-msse4.2 -mfma)
1717
# add_definitions(-mavx2 -mf16c -mpopcnt)
1818

19-
execute_process(COMMAND grep -q avx2 /proc/cpuinfo
19+
execute_process(COMMAND grep -q fma /proc/cpuinfo
20+
RESULT_VARIABLE SUPPORT_FMA
21+
OUTPUT_QUIET
22+
ERROR_QUIET)
23+
24+
execute_process(COMMAND grep -q sse4_2 /proc/cpuinfo
25+
RESULT_VARIABLE SUPPORT_SSE42
26+
OUTPUT_QUIET
27+
ERROR_QUIET)
28+
29+
execute_process(COMMAND grep -q avx2 /proc/cpuinfo
2030
RESULT_VARIABLE SUPPORT_AVX2
21-
OUTPUT_QUIET
22-
ERROR_QUIET)
31+
OUTPUT_QUIET
32+
ERROR_QUIET)
33+
34+
execute_process(COMMAND grep -q avx512 /proc/cpuinfo
35+
RESULT_VARIABLE SUPPORT_AVX512
36+
OUTPUT_QUIET
37+
ERROR_QUIET)
2338

24-
execute_process(COMMAND grep -q avx512 /proc/cpuinfo
25-
RESULT_VARIABLE SUPPORT_AVX512
26-
OUTPUT_QUIET
27-
ERROR_QUIET)
28-
2939

3040
file(GLOB_RECURSE
3141
main_cpp
@@ -210,6 +220,14 @@ target_include_directories(infinity_core PUBLIC "${CMAKE_SOURCE_DIR}/third_party
210220
target_include_directories(infinity_core PUBLIC "${CMAKE_SOURCE_DIR}/third_party/base64/include")
211221
target_include_directories(infinity_core PUBLIC "${CMAKE_SOURCE_DIR}/third_party/oatpp/src")
212222

223+
if (NOT SUPPORT_FMA EQUAL 0)
224+
message(FATAL_ERROR "This project requires the processor support fused multiply-add (FMA) instructions.")
225+
endif()
226+
227+
if (NOT SUPPORT_SSE42 EQUAL 0)
228+
message(FATAL_ERROR "This project requires the processor support sse4_2 instructions.")
229+
endif()
230+
213231
if (SUPPORT_AVX2 EQUAL 0 OR SUPPORT_AVX512 EQUAL 0)
214232
message("Compiled by AVX2 or AVX512")
215233
add_definitions(-march=native)

0 commit comments

Comments
 (0)