source: trunk/lib_ir/CMakeLists.txt @ 3939

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

test out PEXT with s2p_ideal, put down results

File size: 3.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# test packh_2,4,8 only on avx2
30if (USE_AVX2)
31    add_executable(test_pack_avx2 test_pack_avx2.cpp s2p_optimized.o)
32    add_test(
33      NAME ctest_pack_avx2
34      COMMAND ./test_pack_avx2)
35endif (USE_AVX2)
36
37include_directories("xmlwf/util" "xmlwf/lib")
38add_executable(xmlwf xmlwf/src/xmlwf.cpp s2p_optimized.o)
39
40add_executable(xmlwf_perf xmlwf/src/xmlwf.cpp s2p_optimized.o)
41set_target_properties(xmlwf_perf
42  PROPERTIES
43  COMPILE_FLAGS ${CXX_PERF_FLAGS}
44  )
45
46add_custom_target(asm_s2p
47  COMMAND ${LLVM_LLC} -O3 ${LLVM_SSE_FLAGS} s2p_optimized.bc
48  DEPENDS s2p_optimized.bc)
49
50# compile s2p.ll, and make sure test_s2p depends on it.
51add_custom_command(
52  OUTPUT  s2p_optimized.o s2p_optimized.bc
53  COMMAND ${LLVM_OPT} -O3 -std-compile-opts ${LLVM_SSE_FLAGS} ${PROJECT_SOURCE_DIR}/s2p.ll -o s2p_optimized.bc
54  COMMAND ${LLVM_LLC} -O3 ${LLVM_SSE_FLAGS} -filetype=obj s2p_optimized.bc
55  DEPENDS ${PROJECT_SOURCE_DIR}/s2p.ll)
56
57add_test(
58  NAME ctest_s2p
59  COMMAND python ${PROJECT_SOURCE_DIR}/test_s2p.py)
60add_test(
61  NAME ctest_link
62  COMMAND python ${PROJECT_SOURCE_DIR}/test_link.py)
63add_test(
64  NAME ctest_pack
65  COMMAND ./test_pack)
66add_test(
67  NAME ctest_xmlwf
68  COMMAND python ${PROJECT_SOURCE_DIR}/xmlwf/run_all.py)
69
70add_custom_target (check
71  COMMAND ${CMAKE_CTEST_COMMAND}
72  DEPENDS test_s2p test_link test_pack xmlwf)
73
74# `make check` also depends on test_pack_avx2
75if (USE_AVX2)
76  add_dependencies(check test_pack_avx2)
77endif (USE_AVX2)
78
79add_custom_target (perf_xmlwf
80  COMMAND python ${PROJECT_SOURCE_DIR}/xmlwf/perf_script.py
81  DEPENDS xmlwf_perf)
82
83
84# Try IR inline. Compile the whole xmlwf in IR and inline s2p into it.
85set(LLVM_LINK "llvm-link")
86set(LLVM_CLANG "/usr/local/bin/clang")
87# cxx_include should only be used for ir_inline approach.
88set(CXX_INCLUDE -I${PROJECT_SOURCE_DIR}/xmlwf/util -I${PROJECT_SOURCE_DIR}/xmlwf/lib)
89
90add_custom_target(xmlwf_ir_inline
91  COMMAND ${LLVM_LINK} ${PROJECT_SOURCE_DIR}/s2p.ll xmlwf.ll -o xmlwf_all.bc
92  COMMAND ${LLVM_OPT} -O3 -std-compile-opts -std-link-opts xmlwf_all.bc -o xmlwf_ir_inline.bc
93  COMMAND ${LLVM_LLC} -O3 ${LLVM_SSE_FLAGS} -filetype=obj xmlwf_ir_inline.bc
94  COMMAND ${CMAKE_CXX_COMPILER} xmlwf_ir_inline.o -o xmlwf_ir_inline
95  DEPENDS s2p.ll xmlwf.ll)
96
97add_custom_command(
98  OUTPUT xmlwf.ll
99  COMMAND ${LLVM_CLANG} -S -emit-llvm ${CXX_INCLUDE} ${PROJECT_SOURCE_DIR}/xmlwf/src/xmlwf.cpp ${CXX_PERF_FLAGS} -o xmlwf.ll
100  DEPENDS xmlwf/src/xmlwf.cpp)
101
Note: See TracBrowser for help on using the repository browser.