source: trunk/lib_ir/CMakeLists.txt @ 4044

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

add script to measure u8u16 performance. add cmake target to run the perf script

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