source: icGREP/icgrep-devel/icgrep/CMakeLists.txt @ 5346

Last change on this file since 5346 was 5343, checked in by lindanl, 2 years ago

Add count only option for separate compilation of multiple kernels.

File size: 10.9 KB
Line 
1cmake_minimum_required (VERSION 2.8)
2
3project (icgrep)
4
5enable_testing()
6# The version number.
7set (icgrep_VERSION_MAJOR 1)
8set (icgrep_VERSION_MINOR 6)
9
10option(ENABLE_MULTIPLEXING "Compiling the Multiplexing Module")
11option(PRINT_TIMING_INFORMATION "Write compilation and execution timing information to standard error stream")
12option(DISABLE_DUAL_ABI "Disable GCC Dual ABI support" OFF)
13find_package(LLVM REQUIRED CONFIG)
14
15message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION} in: ${LLVM_DIR}")
16set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake") # ensure custom FindXYZ.cmake files are found
17
18# Now set the header and library paths:
19include_directories( ${LLVM_INCLUDE_DIRS} )
20link_directories( ${LLVM_LIBRARY_DIRS} )
21add_definitions( ${LLVM_DEFINITIONS} )
22
23option(ENABLE_CUDA_COMPILE "Compiling with CUDA")
24set(CUDA_LIB "")
25if(ENABLE_CUDA_COMPILE)
26  find_package(CUDA)
27  if(CUDA_FOUND)
28    set(CUDA_INCLUDE ${CUDA_INCLUDE} "/usr/local/cuda-7.5/include")
29    include_directories(${CUDA_INCLUDE})
30    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCUDA_ENABLED")
31    SET(CUDA_LIB "cuda")
32  endif(CUDA_FOUND)
33endif()
34
35# Let's suppose we want to build a JIT compiler with support for
36# binary code (no interpreter):
37set(LLVM_ALL_TARGETS AArch64 AMDGPU ARM BPF CppBackend Hexagon Mips MSP430 NVPTX PowerPC Sparc SystemZ X86 XCore)
38llvm_map_components_to_libnames(REQ_LLVM_LIBRARIES ${LLVM_ALL_TARGETS} mcjit native IRReader Linker)
39
40# Check if boost has been installed on this system.
41set(Boost_USE_STATIC_LIBS ON)
42set(Boost_USE_MULTITHREADED OFF)
43set(Boost_USE_STATIC_RUNTIME OFF)
44find_package(Boost 1.46 REQUIRED COMPONENTS system filesystem iostreams)
45message(STATUS "Found Boost_LIBRARY_DIR: ${Boost_LIBRARY_DIR}")
46
47include_directories("${Boost_INCLUDE_DIRS}")
48link_directories(${Boost_LIBRARY_DIR})
49
50SET(KERNEL_SRC kernels/kernel.cpp kernels/pipeline.cpp kernels/streamset.cpp kernels/interface.cpp)
51SET(KERNEL_SRC ${KERNEL_SRC} kernels/s2p_kernel.cpp kernels/mmap_kernel.cpp kernels/deletion.cpp kernels/swizzle.cpp kernels/p2s_kernel.cpp kernels/stdout_kernel.cpp)
52
53SET(IDISA_SRC IR_Gen/CBuilder.cpp IR_Gen/idisa_builder.cpp IR_Gen/idisa_avx_builder.cpp IR_Gen/idisa_i64_builder.cpp IR_Gen/idisa_sse_builder.cpp IR_Gen/idisa_nvptx_builder.cpp IR_Gen/idisa_target.cpp)
54
55SET(PABLO_SRC pablo/pabloAST.cpp pablo/branch.cpp pablo/codegenstate.cpp pablo/builder.cpp pablo/symbol_generator.cpp pablo/printer_pablos.cpp pablo/pablo_toolchain.cpp)
56SET(PABLO_SRC ${PABLO_SRC} pablo/pablo_kernel.cpp pablo/pablo_compiler.cpp pablo/carry_manager.cpp)
57SET(PABLO_SRC ${PABLO_SRC} pablo/analysis/pabloverifier.cpp)
58SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/pablo_simplifier.cpp pablo/optimizers/codemotionpass.cpp pablo/passes/flattenif.cpp)
59IF(ENABLE_MULTIPLEXING)
60SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/booleanreassociationpass.cpp)
61SET(PABLO_SRC ${PABLO_SRC} pablo/optimizers/schedulingprepass.cpp pablo/optimizers/pablo_automultiplexing.cpp)
62ENDIF()
63
64add_library(CodeGen ${KERNEL_SRC} ${IDISA_SRC} object_cache.cpp)
65add_library(PabloADT ${PABLO_SRC})
66add_library(RegExpADT re/re_re.cpp re/re_cc.cpp re/re_rep.cpp re/re_diff.cpp re/re_intersect.cpp re/printer_re.cpp)
67add_library(RegExpCompiler re/re_parser.cpp re/re_nullable.cpp re/re_simplifier.cpp re/re_compiler.cpp re/re_analysis.cpp re/re_toolchain.cpp re/re_name_resolve.cpp re/re_parser_pcre.cpp re/re_parser_ere.cpp re/re_parser_bre.cpp re/re_parser_prosite.cpp re/re_utility.cpp)
68add_library(CCADT cc/cc_compiler.cpp utf8_encoder.cpp utf16_encoder.cpp UCD/CaseFolding_txt.cpp cc/alphabet.cpp)
69add_library(UCDlib UCD/unicode_set.cpp UCD/ucd_compiler.cpp UCD/PropertyObjects.cpp UCD/resolve_properties.cpp UCD/UnicodeNameData.cpp)
70
71# add the executable
72target_link_libraries (PabloADT CodeGen ${REQ_LLVM_LIBRARIES})
73target_link_libraries (CCADT PabloADT)
74target_link_libraries (UCDlib RegExpADT PabloADT CCADT)
75target_link_libraries (RegExpADT PabloADT CCADT UCDlib)
76target_link_libraries (RegExpCompiler RegExpADT)
77
78add_executable(icgrep icgrep.cpp toolchain.cpp grep_engine.cpp kernels/scanmatchgen.cpp kernels/cc_kernel.cpp kernels/cc_scan_kernel.cpp kernels/unicode_linebreak_kernel.cpp kernels/streams_merge.cpp kernels/match_count.cpp)
79add_executable(u8u16 u8u16.cpp toolchain.cpp)
80add_executable(base64 base64.cpp kernels/radix64.cpp toolchain.cpp)
81add_executable(wc wc.cpp toolchain.cpp)
82add_executable(editd editd/editd.cpp editd/pattern_compiler.cpp toolchain.cpp editd/editdscan_kernel.cpp editd/editd_gpu_kernel.cpp editd/editd_cpu_kernel.cpp)
83add_executable(array-test array-test.cpp toolchain.cpp kernels/alignedprint.cpp)
84
85## IWYU detects superfluous includes and when the include can be replaced with a forward declaration.
86## It can be obtained using "apt-get install iwyu" or from "github.com/include-what-you-use".
87
88#find_program(IWYU_PATH NAMES include-what-you-use iwyu)
89#if(IWYU_PATH)
90#cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
91#execute_process(COMMAND ${CMAKE_CXX_COMPILER} -print-libgcc-file-name OUTPUT_VARIABLE LIBGCC_FILE)
92#get_filename_component(LIBGCC_PATH ${LIBGCC_FILE} DIRECTORY)
93#include_directories("${LIBGCC_PATH}/include")
94#set_property(TARGET CodeGen PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
95#set_property(TARGET PabloADT PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
96#set_property(TARGET RegExpADT PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
97#set_property(TARGET RegExpCompiler PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
98#set_property(TARGET CCADT PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
99#set_property(TARGET UCDlib PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
100#set_property(TARGET icgrep PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
101#set_property(TARGET u8u16 PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
102#set_property(TARGET base64 PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
103#set_property(TARGET wc PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
104#set_property(TARGET editd PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
105#set_property(TARGET array-test PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${IWYU_PATH})
106#endif()
107
108IF (PRINT_TIMING_INFORMATION)
109    find_package(PAPI REQUIRED)
110    include_directories(${PAPI_INCLUDE_DIRS})
111    target_link_libraries(icgrep ${PAPI_LIBRARIES})
112ENDIF()
113
114target_link_libraries (icgrep UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
115target_link_libraries (u8u16 UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
116target_link_libraries (base64 UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
117target_link_libraries (wc UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
118target_link_libraries (editd UCDlib PabloADT RegExpCompiler CCADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
119target_link_libraries (array-test PabloADT CodeGen ${REQ_LLVM_LIBRARIES} ${Boost_LIBRARIES} ${CUDA_LIB})
120
121IF(ENABLE_MULTIPLEXING)
122    message(STATUS "Enabling Multiplexing")
123    find_package(Z3 REQUIRED)
124    include_directories(${Z3_INCLUDE_DIRS})
125    target_link_libraries(PabloADT ${Z3_LIBRARIES})
126    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_MULTIPLEXING")
127ENDIF()
128
129include_directories("${PROJECT_SOURCE_DIR}")
130
131#Check compiler support for 0x / 11
132include(CheckCXXCompilerFlag)
133CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
134if(COMPILER_SUPPORTS_CXX11)
135  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
136else()
137  CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
138  if(COMPILER_SUPPORTS_CXX0X)
139    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
140  else()
141    CHECK_CXX_COMPILER_FLAG("-std=gnu++11" COMPILER_SUPPORTS_GNU11)
142    if(COMPILER_SUPPORTS_GNU11)
143      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
144    else()
145      CHECK_CXX_COMPILER_FLAG("-std=gnu++0x" COMPILER_SUPPORTS_GNU0X)
146      if(COMPILER_SUPPORTS_GNU0X)
147        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
148      endif()
149    endif()
150  endif()
151endif()
152
153#Disable RunTime Type Information
154IF (MSVC) # using Visual Studio C++
155  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
156ELSE() # using Clang, GCC, Intel C++, etc
157  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
158ENDIF()
159
160#Disable Dual ABI support
161IF(DISABLE_DUAL_ABI)
162SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
163ENDIF()
164
165#Enable all warnings
166SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
167
168SET(CMAKE_REQUIRED_FLAGS)
169
170# detect LLVM version and add compiler flags.
171SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLLVM_VERSION_major=${LLVM_VERSION_MAJOR} -DLLVM_VERSION_MINOR=${LLVM_VERSION_MINOR}")
172IF (${LLVM_VERSION_MAJOR} EQUAL 3)
173  IF (${LLVM_VERSION_MINOR} EQUAL 6)
174    message(STATUS "Found LLVM ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}")
175    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_LLVM_3_6")
176  ELSEIF (${LLVM_VERSION_MINOR} EQUAL 7)
177    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_LLVM_3_7")
178  ENDIF()
179ENDIF()
180
181IF (PRINT_TIMING_INFORMATION)
182    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPRINT_TIMING_INFORMATION")
183ENDIF()
184
185SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3 -DNDEBUG")
186SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g -fsanitize=address -fno-omit-frame-pointer")
187
188add_test(
189  NAME greptest
190  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
191  COMMAND python2 greptest.py ${CMAKE_BINARY_DIR}/icgrep)
192
193add_test(
194  NAME proptest
195  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
196  COMMAND python2 greptest.py -d ${PROJECT_SOURCE_DIR}/../QA -t ${PROJECT_SOURCE_DIR}/../QA/proptest.xml ${CMAKE_BINARY_DIR}/icgrep)
197
198add_test(
199  NAME abc_test
200  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA
201  COMMAND ./run_abc ${CMAKE_BINARY_DIR}/icgrep)
202
203add_test(
204  NAME u8u16_test
205  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/u8u16
206  COMMAND ./run_all ${CMAKE_BINARY_DIR}/u8u16)
207
208add_test(
209  NAME editd_test
210  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/editd
211  COMMAND python run_all.py -e ${CMAKE_BINARY_DIR})
212
213add_test(
214  NAME base64_test
215  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/base64
216  COMMAND python base64test.py ${CMAKE_BINARY_DIR}/base64)
217
218add_custom_target (u8u16_test
219  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/u8u16
220  COMMAND ./run_all ${CMAKE_BINARY_DIR}/u8u16)
221
222add_custom_target (editd_test
223  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/editd
224  COMMAND python run_all.py -e ${CMAKE_BINARY_DIR})
225
226add_custom_target (base64_test
227  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA/base64
228  COMMAND python base64test.py ${CMAKE_BINARY_DIR}/base64)
229
230add_custom_target (abc_test
231  COMMAND python2 abc_testgen.py
232  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../QA)
233
234add_custom_target (check
235  COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
236  DEPENDS icgrep abc_test)
237
238add_custom_target (perf_icgrep
239  COMMAND python2 perf.py icgrep
240  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance
241  DEPENDS icgrep)
242
243add_custom_target (viewer
244  COMMAND python2 viewer.py
245  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance)
246
247add_custom_target (text_viewer
248  COMMAND python2 viewer.py -t
249  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../performance)
Note: See TracBrowser for help on using the repository browser.