source: trunk/lib_ir/CMakeLists.txt

Last change on this file was 4313, checked in by linmengl, 5 years ago

remove redundant cmake file for AgnerFog?. Micro benchmark system uses traditional makefile instead of cmake.

File size: 4.1 KB
Line 
1cmake_minimum_required (VERSION 2.8)
2project (IR_Library)
3
4enable_testing()
5
6option (USE_AVX2 "Compile for Haswell arch with AVX2, BMI, BMI2")
7if (USE_AVX2)
8    message("---- Compiling for AVX2")
9    #set(CXX_SSE_FLAGS "-msse2 -m64")
10    set(CXX_SSE_FLAGS "-mavx2 -m64 -march=core-avx2")
11    #set(LLVM_SSE_FLAGS "-mattr=+sse,+sse2")
12    set(LLVM_SSE_FLAGS -mattr=+sse,+sse2,+avx2,+bmi2,+bmi -march=x86-64)
13else (USE_AVX2)
14    set(CXX_SSE_FLAGS "-msse2")
15    set(LLVM_SSE_FLAGS "-mattr=+sse,+sse2")
16endif (USE_AVX2)
17
18# perf_flags for xmlwf perf script
19set(CXX_PERF_FLAGS "-DBUFFER_PROFILING -DPERF_SCRIPT")
20set(CMAKE_CXX_FLAGS "${CXX_SSE_FLAGS} -std=c++11 ")
21
22set(LL_SOURCE_FILES s2p.ll p2s.ll)
23if (USE_AVX2)
24  #append s2p_ideal.ll to source list
25  set(LL_SOURCE_FILES ${LL_SOURCE_FILES} s2p_ideal.ll)
26endif (USE_AVX2)
27
28set(LLVM_OPT "opt-svn")
29set(LLVM_LLC "llc-svn")
30set(LLVM_LINK "llvm-link")
31
32add_executable(test_s2p test_s2p.cpp ir_impl.o)
33add_executable(test_link test_link.cpp ir_impl.o)
34add_executable(test_pack test_pack.cpp ir_impl.o)
35
36# gen/ is used to test llc backend.
37add_subdirectory(gen)
38
39# test packh_2,4,8 only on avx2
40if (USE_AVX2)
41    add_executable(test_pack_avx2 test_pack_avx2.cpp ir_impl.o)
42    add_test(
43      NAME ctest_pack_avx2
44      COMMAND ./test_pack_avx2)
45endif (USE_AVX2)
46
47include_directories("xmlwf/util" "xmlwf/lib")
48add_executable(xmlwf xmlwf/src/xmlwf.cpp ir_impl.o)
49
50# xmlwf_perf compiles with additional flags and is only used for the perf_xmlwf
51# targets below.
52add_executable(xmlwf_perf xmlwf/src/xmlwf.cpp ir_impl.o)
53set_target_properties(xmlwf_perf
54  PROPERTIES
55  COMPILE_FLAGS ${CXX_PERF_FLAGS}
56  )
57
58add_executable(u8u16 u8u16/src/u8u16.cpp ir_impl.o)
59
60add_custom_target(asm
61  COMMAND ${LLVM_LLC} -O3 ${LLVM_SSE_FLAGS} ir_impl_opt.bc
62  DEPENDS ir_impl_opt.bc)
63
64# link ll source files together into ir_impl.bc
65message("---- Link ${LL_SOURCE_FILES} ----")
66add_custom_command(
67  OUTPUT  ir_impl.bc
68  COMMAND ${LLVM_LINK} ${LL_SOURCE_FILES} -o ${CMAKE_BINARY_DIR}/ir_impl.bc
69  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
70  DEPENDS ${LL_SOURCE_FILES})
71
72# compile ir_impl.bc
73add_custom_command(
74  OUTPUT  ir_impl.o ir_impl_opt.bc
75  COMMAND ${LLVM_OPT} -O3 -std-compile-opts ${LLVM_SSE_FLAGS} ir_impl.bc -o ir_impl_opt.bc
76  COMMAND ${LLVM_LLC} -O3 ${LLVM_SSE_FLAGS} -filetype=obj ir_impl_opt.bc -o ir_impl.o
77  DEPENDS ir_impl.bc)
78
79add_test(
80  NAME ctest_s2p
81  COMMAND python ${PROJECT_SOURCE_DIR}/test_s2p.py)
82add_test(
83  NAME ctest_link
84  COMMAND python ${PROJECT_SOURCE_DIR}/test_link.py)
85add_test(
86  NAME ctest_pack
87  COMMAND ./test_pack)
88add_test(
89  NAME ctest_xmlwf
90  COMMAND python ${PROJECT_SOURCE_DIR}/xmlwf/run_all.py)
91add_test(
92  NAME ctest_u8u16
93  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../../proto/u8u16/QA
94  COMMAND ${PROJECT_SOURCE_DIR}/u8u16/run_all ${CMAKE_BINARY_DIR}/u8u16)
95
96add_custom_target (check
97  COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
98  DEPENDS test_s2p test_link test_pack test_llc xmlwf u8u16)
99
100# `make check` also depends on test_pack_avx2
101if (USE_AVX2)
102  add_dependencies(check test_pack_avx2 test_llc_256)
103endif (USE_AVX2)
104
105# performance scripts here
106add_custom_target (perf_xmlwf
107  COMMAND python ${PROJECT_SOURCE_DIR}/xmlwf/perf_script.py
108  DEPENDS xmlwf_perf)
109
110add_custom_target (perf_u8u16
111  COMMAND python ${PROJECT_SOURCE_DIR}/u8u16/perf_script.py
112  DEPENDS u8u16)
113
114# Try IR inline. Compile the whole xmlwf in IR and inline s2p into it.
115set(LLVM_LINK "llvm-link")
116set(LLVM_CLANG "/usr/local/bin/clang")
117# cxx_include should only be used for ir_inline approach.
118set(CXX_INCLUDE -I${PROJECT_SOURCE_DIR}/xmlwf/util -I${PROJECT_SOURCE_DIR}/xmlwf/lib)
119
120add_custom_target(xmlwf_ir_inline
121  COMMAND ${LLVM_LINK} ${PROJECT_SOURCE_DIR}/s2p.ll xmlwf.ll -o xmlwf_all.bc
122  COMMAND ${LLVM_OPT} -O3 -std-compile-opts -std-link-opts xmlwf_all.bc -o xmlwf_ir_inline.bc
123  COMMAND ${LLVM_LLC} -O3 ${LLVM_SSE_FLAGS} -filetype=obj xmlwf_ir_inline.bc
124  COMMAND ${CMAKE_CXX_COMPILER} xmlwf_ir_inline.o -o xmlwf_ir_inline
125  DEPENDS s2p.ll xmlwf.ll)
126
127add_custom_command(
128  OUTPUT xmlwf.ll
129  COMMAND ${LLVM_CLANG} -S -emit-llvm ${CXX_INCLUDE} ${PROJECT_SOURCE_DIR}/xmlwf/src/xmlwf.cpp ${CXX_PERF_FLAGS} -o xmlwf.ll
130  DEPENDS xmlwf/src/xmlwf.cpp)
131
Note: See TracBrowser for help on using the repository browser.